This is done by catching an exception number 0x406d1388 (it has no
documented name, though MSDN dubs it "MS_VC_EXCEPTION" in one code
example), which is thrown by the program. The exception record
contains an ID of a thread and a name to give it.
This requires rolling back some changes in handle_exception(), which
now again returns more than two distinct values. The new
HANDLE_EXCEPTION_IGNORED value means that gdb should just continue,
without returning the thread ID up the stack (which would result in
further handling of the exception, which is not what we want).
gdb/ChangeLog:
2016-08-10 Руслан Ижбулатов <lrn1986@gmail.com>
Pedro Alves <palves@redhat.com>
* windows-nat.c (MS_VC_EXCEPTION): New define.
(handle_exception_result): New enum.
(windows_delete_thread): Free the thread's name.
(handle_exception): Handle MS_VC_EXCEPTION.
(get_windows_debug_event): Handle HANDLE_EXCEPTION_IGNORED.
(windows_thread_name): New function.
(windows_target): Install it as to_thread_name method.
* NEWS: Mention the thread naming support on MS-Windows.
An earlier patch added three new breakpoint-related events to the
Python API. However, at that time, I forgot to update NEWS. This
patch supplies the missing entry.
2016-08-03 Tom Tromey <tom@tromey.com>
* NEWS: Mention new Python breakpoint events.
This patch allows gdbserver to continue recording after disconnect. On
reconnect, the recorded data is accessible to gdb as if no disconnect happened.
A possible application for this feature is remotely examine bugs that occur
at irregular intervals, where maintaining a gdb connection is inconvenient.
This also fixes the issue mentioned here:
https://sourceware.org/ml/gdb-patches/2015-11/msg00424.html
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com>
gdb/ChangeLog:
* NEWS: Resume btrace on reconnect.
* record-btrace.c: Added record-btrace.h include.
(record_btrace_open): Split into this and ...
(record_btrace_push_target): ... this.
(record_btrace_disconnect): New function.
(init_record_btrace_ops): Use record_btrace_disconnect.
* record-btrace.h: New file.
* remote.c: Added record-btrace.h include.
(remote_start_remote): Check recording status.
(remote_btrace_maybe_reopen): New function.
gdb/doc/ChangeLog:
* gdb.texinfo: Resume btrace on reconnect.
gdb/testsuite/ChangeLog:
* gdb.btrace/reconnect.c: New file.
* gdb.btrace/reconnect.exp: New file.
Change-Id: I95e8b0ab8a89e58591aba0e63818cee82fd211bc
Implement support to add catchpoints for a group of related syscalls
using the syntax:
(gdb) catch syscall group:<group>
or
(gdb) catch syscall g:<group>
Several groups are predefined in the xml files for all architectures
supported by GDB over Linux. They are based on the groups defined by
strace.
gdb/
* xml-syscall.c (get_syscalls_by_group): New.
(get_syscall_group_names): New.
(struct syscall_group_desc): New structure to store group data.
(struct syscalls_info): Include field to store the group list.
(sysinfo_free_syscall_group_desc): New.
(free_syscalls_info): Free group list.
(syscall_group_create_syscall_group_desc): New.
(syscall_group_add_syscall): New.
(syscall_create_syscall_desc): Add syscall to its groups.
(syscall_start_syscall): Load group attribute.
(syscall_group_get_group_by_name): New.
(xml_list_syscalls_by_group): New.
(xml_list_of_groups): New.
* xml-syscall.h (get_syscalls_by_group): Export function
to retrieve a list of syscalls filtered by the group name.
(get_syscall_group_names): Export function to retrieve the list
of syscall groups.
* break-catch-syscall.c (catch_syscall_split_args): Verify if
argument is a syscall group and expand it to a list of syscalls
when creating catchpoints.
(catch_syscall_completer): Add word completion for system call
groups.
* configure.ac: Include dependency for xsltproc when building
in maintainer-mode.
* break-catch-syscall.c (_initialize_breakpoint): Update catch
syscall command documentation.
* NEWS: Include section about catching groups of syscalls.
* configure: Regenerate.
* data-directory/Makefile.in: Generate syscall xml when building
in maintainer mode.
* syscalls/gdb-syscalls.dtd: Include group attribute to the
syscall element.
* syscalls/apply-defaults.xsl: New.
* syscalls/linux-defaults.xml.in: New.
* syscalls/aarch64-linux.xml: Rename to aarch64-linux.xml.in.
* syscalls/amd64-linux.xml: Rename to amd64-linux.xml.in.
* syscalls/arm-linux.xml: Rename to arm-linux.xml.in.
* syscalls/bfin-linux.xml: Rename to bfin-linux.xml.in.
* syscalls/i386-linux.xml: Rename to i386-linux.xml.in.
* syscalls/mips-n32-linux.xml: Rename to mips-n32-linux.xml.in.
* syscalls/mips-n64-linux.xml: Rename to mips-n64-linux.xml.in.
* syscalls/mips-o32-linux.xml: Rename to mips-o32-linux.xml.in.
* syscalls/ppc-linux.xml: Rename to ppc-linux.xml.in.
* syscalls/ppc64-linux.xml: Rename to ppc64-linux.xml.in.
* syscalls/s390-linux.xml: Rename to s390-linux.xml.in.
* syscalls/s390x-linux.xml: Rename to s390x-linux.xml.in.
* syscalls/sparc-linux.xml: Rename to sparc-linux.xml.in.
* syscalls/sparc64-linux.xml: Rename to sparc64-linux.xml.in.
* syscalls/aarch64-linux.xml: Regenerate.
* syscalls/amd64-linux.xml: Regenerate.
* syscalls/arm-linux.xml: Regenerate.
* syscalls/i386-linux.xml: Regenerate.
* syscalls/mips-n32-linux.xml: Regenerate.
* syscalls/mips-n64-linux.xml: Regenerate.
* syscalls/mips-o32-linux.xml: Regenerate.
* syscalls/ppc-linux.xml: Regenerate.
* syscalls/ppc64-linux.xml: Regenerate.
* syscalls/s390-linux.xml: Regenerate.
* syscalls/s390x-linux.xml: Regenerate.
* syscalls/sparc-linux.xml: Regenerate.
* syscalls/sparc64-linux.xml: Regenerate.
gdb/testsuite/
* gdb.base/catch-syscall.exp (do_syscall_tests): Add call
to test_catch_syscall_group.
(test_catch_syscall_group): New.
gdb/doc/
* gdb.texinfo (Set Catchpoints): Add 'group' argument to catch
syscall.
This patch adds a "pending" attribute to gdb.Breakpoint.
Built and regtested on x86-64 Fedora 23.
2016-07-13 Tom Tromey <tom@tromey.com>
PR python/17698:
* NEWS: Update.
* python/py-breakpoint.c (bppy_get_pending): New function.
(breakpoint_object_getset): Add entry for "pending".
* breakpoint.h (pending_breakpoint_p): Declare.
* breakpoint.c (pending_breakpoint_p): New function.
2016-07-13 Tom Tromey <tom@tromey.com>
PR python/17698:
* python.texi (Breakpoints In Python): Document
Breakpoint.pending.
2016-07-13 Tom Tromey <tom@tromey.com>
PR python/17698:
* gdb.python/py-breakpoint.exp (test_bkpt_basic): Add "pending"
test.
(test_watchpoints): Likewise.
(test_bkpt_pending): New proc.
gdb/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* NEWS: Mention support for running interpreters on separate
UIs and the new new-ui command.
gdb/doc/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Interpreters): Update intepreter-exec section,
document new-ui and explain use case.
This change adds support for specifying a negative repeat count to
all the formats of the 'x' command to examine memory backward.
A new testcase 'examine-backward' is added to cover this new feature.
Here's the example output from the new feature:
<format 'i'>
(gdb) bt
#0 Func1 (n=42, p=0x40432e "hogehoge") at main.cpp:5
#1 0x00000000004041fa in main (argc=1, argv=0x7fffffffdff8) at main.cpp:19
(gdb) x/-4i 0x4041fa
0x4041e5 <main(int, char**)+11>: mov %rsi,-0x10(%rbp)
0x4041e9 <main(int, char**)+15>: lea 0x13e(%rip),%rsi
0x4041f0 <main(int, char**)+22>: mov $0x2a,%edi
0x4041f5 <main(int, char**)+27>: callq 0x404147
<format 'x'>
(gdb) x/-4xw 0x404200
0x4041f0 <main(int, char**)+22>: 0x00002abf 0xff4de800 0x76e8ffff 0xb8ffffff
(gdb) x/-4
0x4041e0 <main(int, char**)+6>: 0x7d8910ec 0x758948fc 0x358d48f0 0x0000013e
gdb/ChangeLog:
* NEWS: Mention that GDB now supports a negative repeat count in
the 'x' command.
* printcmd.c (decode_format): Allow '-' in the parameter
"string_ptr" to accept a negative repeat count.
(find_instruction_backward): New function.
(read_memory_backward): New function.
(integer_is_zero): New function.
(find_string_backward): New function.
(do_examine): Use new functions to examine memory backward.
(_initialize_printcmd): Mention that 'x' command supports a negative
repeat count.
gdb/doc/ChangeLog:
* gdb.texinfo (Examining Memory): Document negative repeat
count in the 'x' command.
gdb/testsuite/ChangeLog:
* gdb.base/examine-backward.c: New file.
* gdb.base/examine-backward.exp: New file.
Eclipse CDT now supports enabling execution recording using two methods
(full and btrace) and both formats for btrace (bts and pt). In the
event that recording is enabled behind the back of the GUI (by the user
on the command line, or a script), we need to know which method/format
are being used, so it can be correctly reflected in the interface. This
patch adds this information to the =record-started async record.
Before:
=record-started,thread-group="i1"
After:
=record-started,thread-group="i1",method="btrace",format="bts"
=record-started,thread-group="i1",method="btrace",format="pt"
=record-started,thread-group="i1",method="full"
The "format" field is only present when the current method supports
multiple formats (only the btrace method as of now).
gdb/ChangeLog:
* NEWS: Mention the new fields in =record-started.
* common/btrace-common.h (btrace_format_short_string): New function
declaration.
* common/btrace-common.c (btrace_format_short_string): New
function.
* mi/mi-interp.c (mi_record_changed): Output method and format
fields in the =record-started record.
* record-btrace.c (record_btrace_open): Adapt record_changed
notification.
* record-full.c (record_full_open): Likewise.
* record.c (cmd_record_stop): Likewise.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI Async Records): Document method and
format fields in =record-started.
* observer.texi (record_changed): Add method and format
parameters.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-record-changed.exp: Adjust =record-started output
matching.
Standardize the QCatchSyscalls NEWS entry.
gdb/ChangeLog
2016-05-29 Jan Kratochvil <jan.kratochvil@redhat.com>
* NEWS (QCatchSyscalls): Remove the parameter. Include ...
(QCatchSyscalls:1 in qSupported) ... this separate entry which got
deleted.
This patch adds documentation for the new Rust support in gdb.
2016-05-17 Tom Tromey <tom@tromey.com>
* NEWS: Add Rust item.
2016-05-17 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Supported Languages): Mention Rust. Update menu.
(Rust): New node.
I wanted to unit test the Rust lexer, so I added a simple unit testing
command to gdb.
The intent is that self tests will only be compiled into gdb in
development mode. In release mode they simply won't exist. So, this
exposes $development to C code as GDB_SELF_TEST.
In development mode, test functions are registered with the self test
module. A test function is just a function that does some checks, and
throws an exception on failure.
Then this adds a new "maint selftest" command which invokes the test
functions, and a new dejagnu test case that invokes it.
2016-05-17 Tom Tromey <tom@tromey.com>
* NEWS: Add "maint selftest" entry.
* selftest.h: New file.
* selftest.c: New file.
* maint.c: Include selftest.h.
(maintenance_selftest): New function.
(_initialize_maint_cmds): Add "maint selftest" command.
* configure.ac (GDB_SELF_TEST): Maybe define.
* config.in, configure: Rebuild.
* Makefile.in (SFILES): Add selftest.c.
(COMMON_OBS): Add selftest.o.
2016-05-17 Tom Tromey <tom@tromey.com>
* gdb.texinfo (Maintenance Commands): Document "maint selftest".
2016-05-17 Tom Tromey <tom@tromey.com>
* gdb.gdb/unittest.exp: New file.
Fortran supports dynamic types for which bounds, size and location
can vary during their lifetime. As a result of the dynamic
behaviour, they have to be resolved at every query.
This patch will resolve the type of a structure field when it
is dynamic.
2016-04-26 Bernhard Heckel <bernhard.heckel@intel.com>
2016-04-26 Keven Boell <keven.boell@intel.com>
Before:
(gdb) print threev%ivla(1)
Cannot access memory at address 0x3
(gdb) print threev%ivla(5)
no such vector element
After:
(gdb) print threev%ivla(1)
$9 = 1
(gdb) print threev%ivla(5)
$10 = 42
gdb/Changelog:
* NEWS: Add new supported features for fortran.
* gdbtypes.c (remove_dyn_prop): New.
(resolve_dynamic_struct): Keep type length for fortran structs.
* gdbtypes.h: Forward declaration of new function.
* value.c (value_address): Return dynamic resolved location of a value.
(set_value_component_location): Adjust the value address
for single value prints.
(value_primitive_field): Support value types with a dynamic location.
(set_internalvar): Remove dynamic location property of
internal variables.
gdb/testsuite/Changelog:
* gdb.fortran/vla-type.f90: New file.
* gdb.fortran/vla-type.exp: New file.
This removes support for:
| target | source |
|-------------------+-----------------------|
| target m32rsdi | gdb/remote-m32r-sdi.c |
| target mips | gdb/remote-mips.c |
| target pmon | gdb/remote-mips.c |
| target ddb | gdb/remote-mips.c |
| target rockhopper | gdb/remote-mips.c |
| target lsi | gdb/remote-mips.c |
That is:
- Remote M32R debugging over SDI.
- Debugging boards using the MIPS remote debugging protocol
over a serial line, PMON, and a few variants.
These are the last non-"target remote" remote targets in the tree, if
you don't count "target sim".
Refs:
https://sourceware.org/ml/gdb/2016-03/msg00004.htmlhttps://sourceware.org/ml/gdb-patches/2016-03/msg00580.html
gdb/ChangeLog:
2016-03-31 Pedro Alves <palves@redhat.com>
* NEWS: Mention that support for "target m32rsdi", "target mips",
"target pmon", "target ddb", "target rockhopper", and "target lsi"
was removed.
* Makefile.in (ALL_TARGET_OBS): Remove remote-m32r-sdi.o and
remote-mips.o.
(ALLDEPFILES): Remove remote-m32r-sdi.c and remote-mips.c.
* configure.tgt: Remove all references to remote-m32r-sdi.o and
remote-mips.o.
* mips-tdep.c (deprecated_mips_set_processor_regs_hack): Delete
function.
* mips-tdep.h (deprecated_mips_set_processor_regs_hack): Delete
declaration.
* remote-m32r-sdi.c, remote-mips.c: Delete files.
* symfile.c (generic_load, generic_load): Remove comments.
gdb/doc/ChangeLog:
2016-03-31 Pedro Alves <palves@redhat.com>
* gdb.texinfo (M32R/SDI): Delete node.
(MIPS Embedded): Remove references to the MIPS remote debugging
protocol, PMON and variants, and the associated commands.
Add a new command 'maint info line-table' to display the contents of
GDB's internal line table structure. Useful when trying to understand
problems (within gdb) relating to line tables.
gdb/ChangeLog:
* symmisc.c (maintenance_info_line_tables): New function.
(maintenance_print_one_line_table): New function.
(_initialize_symmisc): Register 'maint info line-table' command.
* NEWS: Mention new command.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Document new 'maint info line-table'
command.
gdb/testsuite/ChangeLog:
* gdb.base/maint.exp: New tests for 'maint info line-table'.
This patch is a follow-up to "Add printf format specifier for printing
enumerator":
https://sourceware.org/ml/gdb-patches/2016-02/msg00144.html
Instead of having a solution specific to the printf command, Pedro
suggested adding a general purpose function $_as_string() that would
cover this use case and more.
So, in order to print the textual label of an enum, one can use:
(gdb) printf "Visiting node of type %s\n", $_as_string(node)
Visiting node of type NODE_INTEGER
gdb/ChangeLog:
* data-directory/Makefile.in (PYTHON_FILE_LIST): Install
gdb/function/as_string.py.
* python/lib/gdb/function/as_string.py: New file.
* NEWS: Mention the new $_as_string function.
gdb/testsuite/ChangeLog:
* gdb.python/py-as-string.exp: New file.
* gdb.python/py-as-string.c: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Convenience Functions): Document $_as_string.
gdb/ChangeLog:
Extend "skip" command to support -file, -gfile, -function, -rfunction.
* NEWS: Document new features.
* skip.c: #include "fnmatch.h", "gdb_regex.h".
(skiplist_entry) <file>: Renamed from filename.
<function>: Renamed from function_name.
<file_is_glob, function_is_regexp>: New members.
<compiled_function_regexp, compiled_function_regexp_is_valid>:
New members.
(make_skip_entry): New function.
(free_skiplist_entry, free_skiplist_entry_cleanup): New functions.
(make_free_skiplist_entry_cleanup): New function.
(skip_file_command): Update.
(skip_function, skip_function_command): Update.
(compile_skip_regexp): New functions.
(skip_command): Add support for new options.
(skip_info): Update.
(skip_file_p, skip_gfile_p): New functions.
(skip_function_p, skip_rfunction_p): New functions.
(function_name_is_marked_for_skip): Update and simplify.
(_initialize_step_skip): Update.
* symtab.c: #include "fnmatch.h".
(compare_glob_filenames_for_search): New function.
* symtab.h (compare_glob_filenames_for_search): Declare.
* utils.c (count_path_elements): New function.
(strip_leading_path_elements): New function.
* utils.h (count_path_elements): Declare.
(strip_leading_path_elements): Declare.
gdb/doc/ChangeLog:
* gdb.texinfo (Skipping Over Functions and Files): Document new
options to "skip" command. Update docs of output of "info skip".
gdb/testsuite/ChangeLog:
* gdb.base/skip.c (test_skip): New function.
(end_test_skip_file_and_function): New function.
(test_skip_file_and_function): New function.
* gdb.base/skip1.c (test_skip): New function.
(skip1_test_skip_file_and_function): New function.
* gdb.base/skip.exp: Add tests for new skip options.
* gdb.base/skip-solib.exp: Update expected output.
* gdb.perf/skip-command.cc: New file.
* gdb.perf/skip-command.exp: New file.
* gdb.perf/skip-command.py: New file.
With Intel Memory Protection Extensions it was introduced the concept of
boundary violation. A boundary violations is presented to the inferior as
a segmentation fault having SIGCODE 3. This patch adds a
handler for a boundary violation extending the information displayed
when a bound violation is presented to the inferior. In the stop mode
case the debugger will also display the kind of violation: "upper" or
"lower", bounds and the address accessed.
On no stop mode the information will still remain unchanged. Additional
information about bound violations are not meaningful in that case user
does not know the line in which violation occurred as well.
When the segmentation fault handler is stop mode the out puts will be
changed as exemplified below.
The usual output of a segfault is:
Program received signal SIGSEGV, Segmentation fault
0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050,
c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68
68 value = *(p + len);
In case it is a bound violation it will be presented as:
Program received signal SIGSEGV, Segmentation fault
Upper bound violation while accessing address 0x7fffffffc3b3
Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3]
0x0000000000400d7c in upper (p=0x603010, a=0x603030, b=0x603050,
c=0x603070, d=0x603090, len=7) at i386-mpx-sigsegv.c:68
68 value = *(p + len);
In mi mode the output of a segfault is:
*stopped,reason="signal-received",signal-name="SIGSEGV",
signal-meaning="Segmentation fault", frame={addr="0x0000000000400d7c",
func="upper",args=[{name="p", value="0x603010"},{name="a",value="0x603030"}
,{name="b",value="0x603050"}, {name="c",value="0x603070"},
{name="d",value="0x603090"},{name="len",value="7"}],
file="i386-mpx-sigsegv.c",fullname="i386-mpx-sigsegv.c",line="68"},
thread-id="1",stopped-threads="all",core="6"
in the case of a bound violation:
*stopped,reason="signal-received",signal-name="SIGSEGV",
signal-meaning="Segmentation fault",
sigcode-meaning="Upper bound violation",
lower-bound="0x603010",upper-bound="0x603023",bound-access="0x60302f",
frame={addr="0x0000000000400d7c",func="upper",args=[{name="p",
value="0x603010"},{name="a",value="0x603030"},{name="b",value="0x603050"},
{name="c",value="0x603070"},{name="d",value="0x603090"},
{name="len",value="7"}],file="i386-mpx-sigsegv.c",
fullname="i386-mpx-sigsegv.c",line="68"},thread-id="1",
stopped-threads="all",core="6"
2016-02-18 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* NEWS: Add entry for bound violation.
* amd64-linux-tdep.c (amd64_linux_init_abi_common):
Add handler for segmentation fault.
* gdbarch.sh (handle_segmentation_fault): New.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-linux-tdep.c (i386_linux_handle_segmentation_fault): New.
(SIG_CODE_BONDARY_FAULT): New define.
(i386_linux_init_abi): Use i386_mpx_bound_violation_handler.
* i386-linux-tdep.h (i386_linux_handle_segmentation_fault) New.
* i386-tdep.c (i386_mpx_enabled): Add as external.
* i386-tdep.c (i386_mpx_enabled): Add as external.
* infrun.c (handle_segmentation_fault): New function.
(print_signal_received_reason): Use handle_segmentation_fault.
gdb/testsuite/ChangeLog:
* gdb.arch/i386-mpx-sigsegv.c: New file.
* gdb.arch/i386-mpx-sigsegv.exp: New file.
* gdb.arch/i386-mpx-simple_segv.c: New file.
* gdb.arch/i386-mpx-simple_segv.exp: New file.
gdb/doc/ChangeLog:
* gdb.texinfo (Signals): Add bound violation display hints for
a SIGSEGV.
For languages with dynamic types, an incorrect program, or uninitialised
variables within a program, could result in an incorrect, overly large
type being associated with a value. Currently, attempting to print such
a variable will result in gdb trying to allocate an overly large buffer.
If this large memory allocation fails then the result can be gdb either
terminating, or (due to memory contention) becoming unresponsive for the
user.
A new user visible variable in gdb helps guard against such problems,
two new commands are available:
set max-value-size
show max-value-size
The 'max-value-size' is the maximum size of memory in bytes that gdb
will allocate for the contents of a value. Any attempt to allocate a
value with a size greater than this will result in an error. The
initial default for this limit is set at 64k, this is based on a similar
limit that exists within the ada specific code.
It is possible for the user to set max-value-size to unlimited, in which
case the old behaviour is restored.
gdb/ChangeLog:
* value.c (max_value_size): New variable.
(MIN_VALUE_FOR_MAX_VALUE_SIZE): New define.
(show_max_value_size): New function.
(check_type_length_before_alloc): New function.
(allocate_value_contents): Call check_type_length_before_alloc.
(set_value_enclosing_type): Likewise.
(_initialize_values): Add set/show handler for max-value-size.
* NEWS: Mention new set/show command.
gdb/doc/ChangeLog:
* gdb.texinfo (Value Sizes): New section.
(Data): Add the 'Value Sizes' node to the menu.
gdb/testsuite/ChangeLog:
* gdb.base/max-value-size.c: New file.
* gdb.base/max-value-size.exp: New file.
* gdb.base/huge.exp: Disable max-value-size for this test.
Older versions of FreeBSD supported userland threading via a pure
user-space threading library (N threads scheduled on 1 process) and
a N:M model (N threads scheduled on M LWPs). However, modern FreeBSD
versions only support a M:M threading model where each user thread is
backed by a dedicated LWP. This thread target only supports this
threading model. It also uses ptrace to query and alter LWP state
directly rather than using libthread_db to simplify the implementation.
FreeBSD recently gained support for reporting LWP events (birth and death
of LWPs). GDB will use LWP events when present. For older systems it
fetches the list of LWPs in the to_update_thread_list target op to update
the list of threads on each stop.
This target supports scheduler locking by using ptrace to suspend
individual LWPs as necessary before resuming a process.
gdb/ChangeLog:
* configure.ac: Check for support for LWP names on FreeBSD.
* fbsd-nat.c [PT_LWPINFO] New variable debug_fbsd_lwp.
[TDP_RFPPWAIT || HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME]
(fbsd_fetch_kinfo_proc): Move function earlier.
[PT_LWPINFO] (fbsd_thread_alive): New function.
[PT_LWPINFO] (fbsd_pid_to_str): New function.
[HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME] (fbsd_thread_name): New function.
[PT_LWP_EVENTS] (fbsd_enable_lwp_events): New function.
[PT_LWPINFO] (fbsd_add_threads): New function.
[PT_LWPINFO] (fbsd_update_thread_list): New function.
[PT_LWPINFO] New variable super_resume.
[PT_LWPINFO] (resume_one_thread_cb): New function.
[PT_LWPINFO] (resume_all_threads_cb): New function.
[PT_LWPINFO] (fbsd_resume): New function.
(fbsd_remember_child): Save full ptid instead of plain pid.
(fbsd_is_child_pending): Return ptid of saved child process.
(fbsd_wait): Include lwp in returned ptid and switch to LWP ptid on
first stop.
[PT_LWP_EVENTS] Handle LWP events.
[TDP_RFPPWAIT] Include LWP in child ptid.
(fbsd_post_startup_inferior) [PT_LWP_EVENTS]: Enable LWP events.
(fbsd_post_attach) [PT_LWP_EVENTS]: Enable LWP events.
Add threads for existing processes.
(fbsd_nat_add_target) [PT_LWPINFO]: Set "to_thread_alive" to
"fbsd_thread_alive".
Set "to_pid_to_str" to "fbsd_pid_to_str".
[HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME]: Set "to_thread_name" to
"fbsd_thread_name".
[PT_LWPINFO]: Set "to_update_thread_list" to "fbsd_update_thread_list".
Set "to_has_thread_control" to "tc_schedlock".
Set "to_resume" to "fbsd_resume".
(_initialize_fbsd_nat): New function.
* configure: Regenerate.
* config.in: Regenerate.
gdb/doc/ChangeLog:
* gdb.texinfo (Debugging Output): Document "set/show debug fbsd-lwp".
This commit changes GDB like this:
- Program received signal SIGINT, Interrupt.
+ Thread 1 "main" received signal SIGINT, Interrupt.
- Breakpoint 1 at 0x40087a: file threads.c, line 87.
+ Thread 3 "bar" hit Breakpoint 1 at 0x40087a: file threads.c, line 87.
... once the program goes multi-threaded. Until GDB sees a second
thread spawn, the output is still the same as before, per the
discussion back in 2012:
https://www.sourceware.org/ml/gdb/2012-11/msg00010.html
This helps non-stop mode, where you can't easily tell which thread hit
a breakpoint or received a signal:
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7ffff7fc1740 (LWP 19362) "main" (running)
2 Thread 0x7ffff7fc0700 (LWP 19366) "foo" (running)
3 Thread 0x7ffff77bf700 (LWP 19367) "bar" (running)
(gdb)
Program received signal SIGUSR1, User defined signal 1.
0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
92 lll_wait_tid (pd->tid);
(gdb) b threads.c:87
Breakpoint 1 at 0x40087a: file threads.c, line 87.
(gdb)
Breakpoint 1, thread_function1 (arg=0x1) at threads.c:87
87 usleep (1); /* Loop increment. */
The best the user can do is run "info threads" and try to figure
things out.
It actually also affects all-stop mode, in case of "handle SIG print
nostop":
...
Program received signal SIGUSR1, User defined signal 1.
Program received signal SIGUSR1, User defined signal 1.
Program received signal SIGUSR1, User defined signal 1.
Program received signal SIGUSR1, User defined signal 1.
...
The above doesn't give any clue that these were different threads
getting the SIGUSR1 signal.
I initially thought of lowercasing "breakpoint" in
"Thread 3 hit Breakpoint 1"
but then after trying it I realized that leaving "Breakpoint"
uppercase helps the eye quickly find the relevant information. It's
also easier to implement not showing anything about threads until the
program goes multi-threaded this way.
Here's a larger example session in non-stop mode:
(gdb) c -a&
Continuing.
(gdb) interrupt -a
(gdb)
Thread 1 "main" stopped.
0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
92 lll_wait_tid (pd->tid);
Thread 2 "foo" stopped.
0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
Thread 3 "bar" stopped.
0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
b threads.c:87
Breakpoint 4 at 0x40087a: file threads.c, line 87.
(gdb) b threads.c:67
Breakpoint 5 at 0x400811: file threads.c, line 67.
(gdb) c -a&
Continuing.
(gdb)
Thread 3 "bar" hit Breakpoint 4, thread_function1 (arg=0x1) at threads.c:87
87 usleep (1); /* Loop increment. */
Thread 2 "foo" hit Breakpoint 5, thread_function0 (arg=0x0) at threads.c:68
68 (*myp) ++;
info threads
Id Target Id Frame
* 1 Thread 0x7ffff7fc1740 (LWP 31957) "main" (running)
2 Thread 0x7ffff7fc0700 (LWP 31961) "foo" thread_function0 (arg=0x0) at threads.c:68
3 Thread 0x7ffff77bf700 (LWP 31962) "bar" thread_function1 (arg=0x1) at threads.c:87
(gdb) shell kill -SIGINT 31957
(gdb)
Thread 1 "main" received signal SIGINT, Interrupt.
0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
92 lll_wait_tid (pd->tid);
info threads
Id Target Id Frame
* 1 Thread 0x7ffff7fc1740 (LWP 31957) "main" 0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
2 Thread 0x7ffff7fc0700 (LWP 31961) "foo" thread_function0 (arg=0x0) at threads.c:68
3 Thread 0x7ffff77bf700 (LWP 31962) "bar" thread_function1 (arg=0x1) at threads.c:87
(gdb) t 2
[Switching to thread 2, Thread 0x7ffff7fc0700 (LWP 31961)]
#0 thread_function0 (arg=0x0) at threads.c:68
68 (*myp) ++;
(gdb) catch syscall
Catchpoint 6 (any syscall)
(gdb) c&
Continuing.
(gdb)
Thread 2 "foo" hit Catchpoint 6 (call to syscall nanosleep), 0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
I'll work on documentation next if this looks agreeable.
This patch applies on top of the star wildcards thread IDs series:
https://sourceware.org/ml/gdb-patches/2016-01/msg00291.html
For convenience, I've pushed this to the
users/palves/show-which-thread-caused-stop branch.
gdb/doc/ChangeLog:
2016-01-18 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Threads): Mention that GDB displays the ID and name
of the thread that hit a breakpoint or received a signal.
gdb/ChangeLog:
2016-01-18 Pedro Alves <palves@redhat.com>
* NEWS: Mention that GDB now displays the ID and name of the
thread that hit a breakpoint or received a signal.
* break-catch-sig.c (signal_catchpoint_print_it): Use
maybe_print_thread_hit_breakpoint.
* break-catch-syscall.c (print_it_catch_syscall): Likewise.
* break-catch-throw.c (print_it_exception_catchpoint): Likewise.
* breakpoint.c (maybe_print_thread_hit_breakpoint): New function.
(print_it_catch_fork, print_it_catch_vfork, print_it_catch_solib)
(print_it_catch_exec, print_it_ranged_breakpoint)
(print_it_watchpoint, print_it_masked_watchpoint, bkpt_print_it):
Use maybe_print_thread_hit_breakpoint.
* breakpoint.h (maybe_print_thread_hit_breakpoint): Declare.
* gdbthread.h (show_thread_that_caused_stop): Declare.
* infrun.c (print_signal_received_reason): Print which thread
received signal.
* thread.c (show_thread_that_caused_stop): New function.
gdb/testsuite/ChangeLog:
2016-01-18 Pedro Alves <palves@redhat.com>
* gdb.base/async-shell.exp: Adjust expected output.
* gdb.base/dprintf-non-stop.exp: Adjust expected output.
* gdb.base/siginfo-thread.exp: Adjust expected output.
* gdb.base/watchpoint-hw-hit-once.exp: Adjust expected output.
* gdb.java/jnpe.exp: Adjust expected output.
* gdb.threads/clone-new-thread-event.exp: Adjust expected output.
* gdb.threads/continue-pending-status.exp: Adjust expected output.
* gdb.threads/leader-exit.exp: Adjust expected output.
* gdb.threads/manythreads.exp: Adjust expected output.
* gdb.threads/pthreads.exp: Adjust expected output.
* gdb.threads/schedlock.exp: Adjust expected output.
* gdb.threads/siginfo-threads.exp: Adjust expected output.
* gdb.threads/signal-command-multiple-signals-pending.exp: Adjust
expected output.
* gdb.threads/signal-delivered-right-thread.exp: Adjust expected
output.
* gdb.threads/sigthread.exp: Adjust expected output.
* gdb.threads/watchpoint-fork.exp: Adjust expected output.
Add support for specifying "all threads of inferior N", by writing "*"
as thread number/range in thread ID lists.
E.g., "info threads 2.*" or "thread apply 2.* bt".
gdb/ChangeLog:
2016-01-15 Pedro Alves <palves@redhat.com>
* NEWS: Mention star wildcard ranges.
* cli/cli-utils.c (get_number_or_range): Check state->in_range first.
(number_range_setup_range): New function.
* cli/cli-utils.h (number_range_setup_range): New declaration.
* thread.c (thread_apply_command): Support star TID ranges.
* tid-parse.c (tid_range_parser_finished)
(tid_range_parser_string, tid_range_parser_skip)
(get_tid_or_range, get_tid_or_range): Handle
TID_RANGE_STATE_STAR_RANGE.
(tid_range_parser_star_range): New function.
* tid-parse.h (enum tid_range_state) <TID_RANGE_STATE_STAR_RANGE>:
New value.
(tid_range_parser_star_range): New declaration.
gdb/doc/ChangeLog:
2016-01-15 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Threads) <thread ID lists>: Document star ranges.
gdb/testsuite/ChangeLog:
2016-01-15 Pedro Alves <palves@redhat.com>
* gdb.multi/tids.exp: Test star wildcard ranges.
This commit adds a new $_gthread convenience variable, that is like
$_thread, but holds the current thread's global thread id.
gdb/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* NEWS: Mention $_gthread.
* gdbthread.h (struct thread_info) <global_num>: Mention
$_gthread.
* thread.c (thread_num_make_value_helper): New function.
(thread_id_make_value): Delete.
(thread_id_per_inf_num_make_value, global_thread_id_make_value):
New.
(thread_funcs): Adjust.
(gthread_funcs): New.
(_initialize_thread): Register $_gthread variable.
gdb/testsuite/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* gdb.base/default.exp: Expect $_gthread as well.
* gdb.multi/tids.exp: Test $_gthread.
* gdb.threads/thread-specific.exp: Test $_gthread.
gdb/doc/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Threads): Document the $_gthread convenience
variable.
(Convenience Vars): Likewise.
This commit adds a new Python InferiorThread.global_num attribute.
This can be used to pass the correct thread ID to Breakpoint.thread,
which takes a global thread ID, not a per-inferior thread number.
gdb/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* NEWS: Mention InferiorThread.global_num.
* python/py-infthread.c (thpy_get_global_num): New function.
(thread_object_getset): Register "global_num".
gdb/testsuite/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* gdb.multi/tids.exp: Test InferiorThread.global_num and
Breakpoint.thread.
* gdb.python/py-infthread.exp: Test InferiorThread.global_num.
gdb/doc/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* python.texi (Breakpoints In Python) <Breakpoint.thread>: Add
anchor.
(Threads In Python): Document new InferiorThread.global_num
attribute.
This commit changes GDB to track thread numbers per-inferior. Then,
if you're debugging multiple inferiors, GDB displays
"inferior-num.thread-num" instead of just "thread-num" whenever it
needs to display a thread:
(gdb) info inferiors
Num Description Executable
1 process 6022 /home/pedro/gdb/tests/threads
* 2 process 6037 /home/pedro/gdb/tests/threads
(gdb) info threads
Id Target Id Frame
1.1 Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running)
1.2 Thread 0x7ffff77c0700 (LWP 6028) "threads" (running)
1.3 Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running)
2.1 Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running)
2.2 Thread 0x7ffff77c0700 (LWP 6038) "threads" (running)
* 2.3 Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running)
(gdb)
...
(gdb) thread 1.1
[Switching to thread 1.1 (Thread 0x7ffff7fc2740 (LWP 8155))]
(gdb)
...
etc.
You can still use "thread NUM", in which case GDB infers you're
referring to thread NUM of the current inferior.
The $_thread convenience var and Python's InferiorThread.num attribute
are remapped to the new per-inferior thread number. It's a backward
compatibility break, but since it only matters when debugging multiple
inferiors, I think it's worth doing.
Because MI thread IDs need to be a single integer, we keep giving
threads a global identifier, _in addition_ to the per-inferior number,
and make MI always refer to the global thread IDs. IOW, nothing
changes from a MI frontend's perspective.
Similarly, since Python's Breakpoint.thread and Guile's
breakpoint-thread/set-breakpoint-thread breakpoint methods need to
work with integers, those are adjusted to work with global thread IDs
too. Follow up patches will provide convenient means to access
threads' global IDs.
To avoid potencially confusing users (which also avoids updating much
of the testsuite), if there's only one inferior and its ID is "1",
IOW, the user hasn't done anything multi-process/inferior related,
then the "INF." part of thread IDs is not shown. E.g,.:
(gdb) info inferiors
Num Description Executable
* 1 process 15275 /home/pedro/gdb/tests/threads
(gdb) info threads
Id Target Id Frame
* 1 Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
(gdb) add-inferior
Added inferior 2
(gdb) info threads
Id Target Id Frame
* 1.1 Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
(gdb)
No regressions on x86_64 Fedora 20.
gdb/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* NEWS: Mention that thread IDs are now per inferior and global
thread IDs.
* Makefile.in (SFILES): Add tid-parse.c.
(COMMON_OBS): Add tid-parse.o.
(HFILES_NO_SRCDIR): Add tid-parse.h.
* ada-tasks.c: Adjust to use ptid_to_global_thread_id.
* breakpoint.c (insert_breakpoint_locations)
(remove_threaded_breakpoints, bpstat_check_breakpoint_conditions)
(print_one_breakpoint_location, set_longjmp_breakpoint)
(check_longjmp_breakpoint_for_call_dummy)
(set_momentary_breakpoint): Adjust to use global IDs.
(find_condition_and_thread, watch_command_1): Use parse_thread_id.
(until_break_command, longjmp_bkpt_dtor)
(breakpoint_re_set_thread, insert_single_step_breakpoint): Adjust
to use global IDs.
* dummy-frame.c (pop_dummy_frame_bpt): Adjust to use
ptid_to_global_thread_id.
* elfread.c (elf_gnu_ifunc_resolver_stop): Likewise.
* gdbthread.h (struct thread_info): Rename field 'num' to
'global_num. Add new fields 'per_inf_num' and 'inf'.
(thread_id_to_pid): Rename thread_id_to_pid to
global_thread_id_to_ptid.
(pid_to_thread_id): Rename to ...
(ptid_to_global_thread_id): ... this.
(valid_thread_id): Rename to ...
(valid_global_thread_id): ... this.
(find_thread_id): Rename to ...
(find_thread_global_id): ... this.
(ALL_THREADS, ALL_THREADS_BY_INFERIOR): Declare.
(print_thread_info): Add comment.
* tid-parse.h: New file.
* tid-parse.c: New file.
* infcmd.c (step_command_fsm_prepare)
(step_command_fsm_should_stop): Adjust to use the global thread
ID.
(until_next_command, until_next_command)
(finish_command_fsm_should_stop): Adjust to use the global thread
ID.
(attach_post_wait): Adjust to check the inferior number too.
* inferior.h (struct inferior) <highest_thread_num>: New field.
* infrun.c (handle_signal_stop)
(insert_exception_resume_breakpoint)
(insert_exception_resume_from_probe): Adjust to use the global
thread ID.
* record-btrace.c (record_btrace_open): Use global thread IDs.
* remote.c (process_initial_stop_replies): Also consider the
inferior number.
* target.c (target_pre_inferior): Clear the inferior's highest
thread num.
* thread.c (clear_thread_inferior_resources): Adjust to use the
global thread ID.
(new_thread): New inferior parameter. Adjust to use it. Set both
the thread's global ID and the thread's per-inferior ID.
(add_thread_silent): Adjust.
(find_thread_global_id): New.
(find_thread_id): Make static. Adjust to rename.
(valid_thread_id): Rename to ...
(valid_global_thread_id): ... this.
(pid_to_thread_id): Rename to ...
(ptid_to_global_thread_id): ... this.
(thread_id_to_pid): Rename to ...
(global_thread_id_to_ptid): ... this. Adjust.
(first_thread_of_process): Adjust.
(do_captured_list_thread_ids): Adjust to use global thread IDs.
(should_print_thread): New function.
(print_thread_info): Rename to ...
(print_thread_info_1): ... this, and add new show_global_ids
parameter. Handle it. Iterate over inferiors.
(print_thread_info): Reimplement as wrapper around
print_thread_info_1.
(show_inferior_qualified_tids): New function.
(print_thread_id): Use it.
(tp_array_compar): Compare inferior numbers too.
(thread_apply_command): Use tid_range_parser.
(do_captured_thread_select): Use parse_thread_id.
(thread_id_make_value): Adjust.
(_initialize_thread): Adjust "info threads" help string.
* varobj.c (struct varobj_root): Update comment.
(varobj_create): Adjust to use global thread IDs.
(value_of_root_1): Adjust to use global_thread_id_to_ptid.
* windows-tdep.c (display_tib): No longer accept an argument.
* cli/cli-utils.c (get_number_trailer): Make extern.
* cli/cli-utils.h (get_number_trailer): Declare.
(get_number_const): Adjust documentation.
* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Adjust to use global
thread IDs.
* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
(mi_on_normal_stop, mi_output_running_pid, mi_on_resume):
* mi/mi-main.c (mi_execute_command, mi_cmd_execute): Likewise.
* guile/scm-breakpoint.c (gdbscm_set_breakpoint_thread_x):
Likewise.
* python/py-breakpoint.c (bppy_set_thread): Likewise.
* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
* python/py-infthread.c (thpy_get_num): Add comment and return the
per-inferior thread ID.
(thread_object_getset): Update comment of "num".
gdb/testsuite/ChangeLog:
2016-01-07 Pedro Alves <palves@redhat.com>
* gdb.base/break.exp: Adjust to output changes.
* gdb.base/hbreak2.exp: Likewise.
* gdb.base/sepdebug.exp: Likewise.
* gdb.base/watch_thread_num.exp: Likewise.
* gdb.linespec/keywords.exp: Likewise.
* gdb.multi/info-threads.exp: Likewise.
* gdb.threads/thread-find.exp: Likewise.
* gdb.multi/tids.c: New file.
* gdb.multi/tids.exp: New file.
gdb/doc/ChangeLog:
2016-01-07 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Threads): Document per-inferior thread IDs,
qualified thread IDs, global thread IDs and thread ID lists.
(Set Watchpoints, Thread-Specific Breakpoints): Adjust to refer to
thread IDs.
(Convenience Vars): Document the $_thread convenience variable.
(Ada Tasks): Adjust to refer to thread IDs.
(GDB/MI Async Records, GDB/MI Thread Commands, GDB/MI Ada Tasking
Commands, GDB/MI Variable Objects): Update to mention global
thread IDs.
* guile.texi (Breakpoints In Guile)
<breakpoint-thread/set-breakpoint-thread breakpoint>: Mention
global thread IDs instead of thread IDs.
* python.texi (Threads In Python): Adjust documentation of
InferiorThread.num.
(Breakpoint.thread): Mention global thread IDs instead of thread
IDs.
So a script can easily get at a thread's inferior and its number.
gdb/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* NEWS: Mention InferiorThread.inferior.
* python/py-infthread.c (thpy_get_inferior): New.
(thread_object_getset): Register "inferior".
gdb/testsuite/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* gdb.python/py-infthread.exp: Test InferiorThread.inferior.
gdb/doc/ChangeLog:
2016-01-13 Pedro Alves <palves@redhat.com>
* python.texi (Threads In Python): Document
InferiorThread.inferior.
This adds a new QCatchSyscalls packet to enable 'catch syscall', and new
stop reasons "syscall_entry" and "syscall_return" for those events. It
is currently only supported on Linux x86 and x86_64.
gdb/ChangeLog:
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the
syscall_entry and syscall_return stop reasons. Mention GDB
support for remote catch syscall.
* remote.c (PACKET_QCatchSyscalls): New enum.
(remote_set_syscall_catchpoint): New function.
(remote_protocol_features): New element for QCatchSyscalls.
(remote_parse_stop_reply): Parse syscall_entry/return stops.
(init_remote_ops): Install remote_set_syscall_catchpoint.
(_initialize_remote): Config QCatchSyscalls.
* linux-nat.h (struct lwp_info) <syscall_state>: Comment typo.
gdb/doc/ChangeLog:
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet.
(Stop Reply Packets): List the syscall entry and return stop reasons.
(General Query Packets): Describe QCatchSyscalls, and add it to the
table and the detailed list of stub features.
gdb/gdbserver/ChangeLog:
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* inferiors.h: Include "gdb_vecs.h".
(struct process_info): Add syscalls_to_catch.
* inferiors.c (remove_process): Free syscalls_to_catch.
* remote-utils.c (prepare_resume_reply): Report syscall_entry and
syscall_return stops.
* server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define.
* server.c (handle_general_set): Handle QCatchSyscalls.
(handle_query): Report support for QCatchSyscalls.
* target.h (struct target_ops): Add supports_catch_syscall.
(target_supports_catch_syscall): New macro.
* linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo.
(struct lwp_info): Add syscall_state.
* linux-low.c (handle_extended_wait): Mark syscall_state as an entry.
Maintain syscall_state and syscalls_to_catch across exec.
(get_syscall_trapinfo): New function, proxy to the_low_target.
(linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD.
(linux_low_filter_event): Toggle syscall_state entry/return for
syscall traps, and set it ignored for all others.
(gdb_catching_syscalls_p): New function.
(gdb_catch_this_syscall_p): New function.
(linux_wait_1): Handle SYSCALL_SIGTRAP.
(linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility.
(linux_supports_catch_syscall): New function.
(linux_target_ops): Install it.
* linux-x86-low.c (x86_get_syscall_trapinfo): New function.
(the_low_target): Install it.
gdb/testsuite/ChangeLog:
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/catch-syscall.c (do_execve): New variable.
(main): Conditionally trigger an execve.
* gdb.base/catch-syscall.exp: Enable testing for remote targets.
(test_catch_syscall_execve): New, check entry/return across execve.
(do_syscall_tests): Call test_catch_syscall_execve.
The GNU Coding Standards say:
"Please do not include any trademark acknowledgements in GNU
software packages or documentation."
gdb/ChangeLog:
2016-01-12 Pedro Alves <palves@redhat.com>
Remove use of the registered trademark symbol throughout.
gdb/gdbserver/ChangeLog:
2016-01-12 Pedro Alves <palves@redhat.com>
Remove use of the registered trademark symbol throughout.
gdb/doc/ChangeLog:
2016-01-12 Pedro Alves <palves@redhat.com>
Remove use of the registered trademark symbol throughout.
This patch implements documentation updates for target remote mode fork and
exec events. A summary of the rationale for the changes made here:
* Connecting to a remote target -- explain that the two protocols exist.
* Connecting in target remote mode -- explain invoking gdbserver for target
remote mode, and move remote-specific text from original "Connecting to a
remote target" section.
* Connecting in target extended-remote mode -- promote this section from
"Using the gdbserver Program | Running gdbserver | Multi-Process Mode for
gdbserver". Put it next to the target remote mode section.
* Host and target files -- collect paragraphs dealing with how to locate
symbol files from original sections "Connecting to a remote target" and
"Using the gdbserver program | Connecting to gdbserver".
* Steps for connecting to a remote target -- used to be "Using the
gdbserver program | Connecting to gdbserver"
* Remote connection commands -- used to be the bulk of "Connecting to a
remote target". Added "target extended-remote" commands and information.
gdb/ChangeLog:
* NEWS: Announce fork and exec event support for target remote.
gdb/doc/ChangeLog:
* gdb.texinfo (Forks): Correct Linux kernel version where
fork and exec events are supported, add notes about support
of these events in target remote mode.
(Connecting): Reorganize and clarify distinctions between
target remote, extended-remote, and multiprocess.
Reorganize related text from separate sections into new
sections.
(Server): Note effects of target extended-remote mode.
Delete section on Multi-Process Mode for gdbserver.
Move some text to "Connecting" node.
This set of patches add support for the zero-padded hexadecimal format for
varobj's, defined as "zero-hexadecimal". We currently only support regular
non-zero-padded hexadecimal.
Talking with IDE developers, they would like to have this option that is
already available to GDB's print/x commands, in the CLI, as 'z'.
gdb/ChangeLog:
2015-12-09 Luis Machado <lgustavo@codesourcery.com>
* gdb/mi/mi-cmd-var.c (mi_parse_format): Handle new "zero-hexadecimal"
format.
* gdb/varobj.c (varobj_format_string): Add "zero-hexadecimal" entry.
(format_code): Add 'z' entry.
(varobj_set_display_format): Handle FORMAT_ZHEXADECIMAL.
* gdb/varobj.h (varobj_display_formats) <FORMAT_ZHEXADECIMAL>: New enum
field.
* NEWS: Add new note to MI changes citing the new zero-hexadecimal
format for -var-set-format.
gdb/doc/ChangeLog:
2015-12-09 Luis Machado <lgustavo@codesourcery.com>
* gdb.texinfo (GDB/MI Variable Objects): Update text to mention
-var-set-format's new zero-hexadecimal format.
gdb/testsuite/ChangeLog:
2015-12-09 Luis Machado <lgustavo@codesourcery.com>
* gdb.mi/mi-var-display.exp: Add new checks for the zero-hexadecimal
format and change test names to make them unique.
gdb/ChangeLog:
* NEWS: Announce this enhancement and the corresponding new
option.
gdb/doc/ChangeLog:
* gdb.texinfo (Ada Mode Into): Move overloading support
description to its own node.
(Overloading support for Ada): New node.
Testing with "maint set target-non-stop on" causes regressions in
tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on
the RSP. In real all-stop, gdbserver detects the situation and
reporst error to GDB, and so the tests (e.g.,
gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with
"maint set target-non-stop on", GDB instead hangs forever waiting for
a stop reply that never comes, and so the tests take longer to time
out.
This adds a new "N" stop reply packet that maps 1-1 to
TARGET_WAITKIND_NO_RESUMED.
gdb/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
PR 14618
* NEWS (New remote packets): Mention the N stop reply.
* remote.c (remote_protocol_features): Add "no-resumed" entry.
(remote_query_supported): Report no-resumed+ support.
(remote_parse_stop_reply): Handle 'N'.
(process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED.
(remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED.
(_initialize_remote): Register "set/show remote
no-resumed-stop-reply" commands.
gdb/doc/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
PR 14618
* gdb.texinfo (Stop Reply Packets): Document the N stop reply.
(Remote Configuration): Add the "set/show remote
no-resumed-stop-reply" to the available settings table.
(General Query Packets): Document the "no-resumed" qSupported
feature.
gdb/gdbserver/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
PR 14618
* linux-low.c (linux_wait_1): If the last resumed thread is gone,
report TARGET_WAITKIND_NO_RESUMED.
* remote-utils.c (prepare_resume_reply): Handle
TARGET_WAITKIND_NO_RESUMED.
* server.c (report_no_resumed): New global.
(handle_query) <qSupported>: Handle "no-resumed+". Report
"no-resumed+" support.
(resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only
return error if the client doesn't support no-resumed events.
(push_stop_notification): New function.
(handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED
events if the client supports them.
gdb/testsuite/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
When testing with "maint set target-non-stop on", a few
threading-related tests expose an issue that requires new RSP packets.
Say there are 3 threads running, 1-3. If GDB tries to stop thread 1,
2 and 3, and then waits for their stops, but meanwhile say, thread 2
exits, GDB hangs forever waiting for a stop for thread 2 that won't
ever happen.
This patch fixes the issue by adding support for thread exit events to
the protocol. However, we don't want these always enabled, as they're
useless most of the time, and would slow down remote debugging. So I
made it so that GDB can enable/disable them, and then made gdb do that
around the cases that need it, which currently is only
infrun.c:stop_all_threads.
In turn, if we have thread exit events, then the extra "thread x
exited" traffic slows down attach-many-short-lived-threads.exp enough
that gdb has trouble keeping up with new threads that are spawned
while gdb tries to stop existing ones. To fix that I added support
for the counterpart thread created events too. Enabling those when we
try to stop threads ensures that new threads never get a chance to
themselves start new threads, killing the race.
gdb/doc/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Remote Configuration): List "set/show remote
thread-events" command in configuration table.
(Stop Reply Packets): Document "T05 create" stop
reason and 'w' stop reply.
(General Query Packets): Document QThreadEvents packet. Document
QThreadEvents qSupported feature.
gdb/gdbserver/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* linux-low.c (handle_extended_wait): Assert that the LWP's
waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about
thread create events, leave the new child's status pending.
(linux_low_filter_event): If GDB wants to hear about thread exit
events, leave the LWP marked dead and don't delete it.
(linux_wait_for_event_filtered): Don't check for thread exit.
(filter_exit_event): New function.
(linux_wait_1): Use it, when returning an exit event.
(linux_resume_one_lwp_throw): Assert that the LWP's
waitstatus is TARGET_WAITKIND_IGNORE.
* remote-utils.c (prepare_resume_reply): Handle
TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED.
* server.c (report_thread_events): New global.
(handle_general_set): Handle QThreadEvents.
(handle_query) <qSupported>: Handle and report QThreadEvents+;
(handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and
TARGET_WAITKIND_THREAD_EXITED.
* server.h (report_thread_events): Declare.
gdb/ChangeLog:
2015-11-30 Pedro Alves <palves@redhat.com>
* NEWS (New commands): Mention "set/show remote thread-events"
commands.
(New remote packets): Mention thread created/exited stop reasons
and QThreadEvents packet.
* infrun.c (disable_thread_events): New function.
(stop_all_threads): Disable/enable thread create/exit events.
Handle TARGET_WAITKIND_THREAD_EXITED.
(handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED
and TARGET_WAITKIND_THREAD_EXITED.
* remote.c (remove_child_of_pending_fork): Also remove threads of
threads that have TARGET_WAITKIND_THREAD_EXITED events.
(remote_parse_stop_reply): Handle "create" magic register. Handle
'w' stop reply.
(initialize_remote): Install remote_thread_events as
to_thread_events target hook.
(remote_thread_events): New function.
* target-delegates.c: Regenerate.
* target.c (target_thread_events): New function.
* target.h (struct target_ops) <to_thread_events>: New field.
(target_thread_events): Declare.
* target/waitstatus.c (target_waitstatus_to_string): Handle
TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED.
* target/waitstatus.h (enum target_waitkind)
<TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED):
New values.
There's currently no non-stop equivalent of the all-stop ^C (\003)
"packet" that GDB sends when a ctrl-c is pressed while a foreground
command is active. There's vCont;t, but that's defined to cause a
"signal 0" stop.
This fixes many tests that type ^C, when testing with extended-remote
with "maint set target-non-stop on". E.g.:
Continuing.
talk to me baby
PASS: gdb.base/interrupt.exp: process is alive
a
a
PASS: gdb.base/interrupt.exp: child process ate our char
^C
[Thread 22730.22730] #1 stopped.
0x0000003615ee6650 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:81
81 T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) FAIL: gdb.base/interrupt.exp: send_gdb control C
p func1 ()
gdb/
2015-11-30 Pedro Alves <palves@redhat.com>
* NEWS (New remote packets): Mention vCtrlC.
* remote.c (PACKET_vCtrlC): New enum value.
(async_remote_interrupt): Call target_interrupt instead of
target_stop.
(remote_interrupt_as): Remove 'ptid' parameter.
(remote_interrupt_ns): New function.
(remote_stop): Adjust.
(remote_interrupt): If the target is in non-stop mode, try
interrupting with vCtrlC.
(initialize_remote): Install set remote ctrl-c packet.
gdb/doc/
2015-11-30 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Bootstrapping): Add "interrupting remote targets"
anchor.
(Packets): Document vCtrlC.
gdb/gdbserver/
2015-11-30 Pedro Alves <palves@redhat.com>
* server.c (handle_v_requests): Handle vCtrlC.
This patch adds support for thread names in the remote protocol, and
updates gdb/gdbserver to use it. The information is added to the XML
description sent in response to the qXfer:threads:read packet.
gdb/ChangeLog:
* linux-nat.c (linux_nat_thread_name): Replace implementation by call
to linux_proc_tid_get_name.
* nat/linux-procfs.c (linux_proc_tid_get_name): New function,
implementation inspired by linux_nat_thread_name.
* nat/linux-procfs.h (linux_proc_tid_get_name): New declaration.
* remote.c (struct private_thread_info) <name>: New field.
(free_private_thread_info): Free name field.
(remote_thread_name): New function.
(thread_item_t) <name>: New field.
(clear_threads_listing_context): Free name field.
(start_thread): Get name xml attribute.
(thread_attributes): Add "name" attribute.
(remote_update_thread_list): Copy name field.
(init_remote_ops): Assign remote_thread_name callback.
* target.h (target_thread_name): Update comment.
* NEWS: Mention remote thread name support.
gdb/gdbserver/ChangeLog:
* linux-low.c (linux_target_ops): Use linux_proc_tid_get_name.
* server.c (handle_qxfer_threads_worker): Refactor to include thread
name in reply.
* target.h (struct target_ops) <thread_name>: New field.
(target_thread_name): New macro.
gdb/doc/ChangeLog:
* gdb.texinfo (Thread List Format): Mention thread names.
gdb/ChangeLog:
2015-11-24 Pedro Alves <palves@redhat.com>
* NEWS: Mention that a few "info" commands now list the
corresponding items in ascending ID order.
Add support for the /s modifier of the "record instruction-history" command. It
behaves exactly like /m and prints disassembled instructions in the order in
which they were recorded with interleaved sources. We accept /s in addition
to /m to align with the "disassemble" command.
The "record instruction-history" modifiers were not documented. Document
all of them.
gdb/
* record.c (get_insn_history_modifiers): Set DISASSEMBLY_SOURCE
instead of DISASSEMBLY_SOURCE_DEPRECATED. Also accept /s.
(_initialize_record): Document the /s modifier.
* NEWS: Announce record instruction-history's new /s modifier.
doc/
* gdb.texinfo (Process Record and Replay): Document "record
instruction-history" modifiers.