diff options
author | Pedro Alves <palves@redhat.com> | 2015-11-30 16:05:21 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2015-11-30 18:40:30 +0000 |
commit | 65706a29bac50c2c971227a1945e46502845766b (patch) | |
tree | 170c4ec5d7e5ea2620858226b6561cdbd854a3ea /gdb/doc | |
parent | 09df4675f2e4f8f098954f9a38f44d12089f1c4e (diff) | |
download | gdb-65706a29bac50c2c971227a1945e46502845766b.zip gdb-65706a29bac50c2c971227a1945e46502845766b.tar.gz gdb-65706a29bac50c2c971227a1945e46502845766b.tar.bz2 |
Remote thread create/exit events
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.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 62 |
2 files changed, 71 insertions, 0 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 3e0d626..b5eddc9 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,5 +1,14 @@ 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. + +2015-11-30 Pedro Alves <palves@redhat.com> + * gdb.texinfo (Bootstrapping): Add "interrupting remote targets" anchor. (Packets): Document vCtrlC. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 972ace0..d2ec354 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -20235,6 +20235,10 @@ are: @tab @code{exec stop reason} @tab @code{exec} +@item @code{thread-events} +@tab @code{QThreadEvents} +@tab Tracking thread lifetime. + @end multitable @node Remote Stub @@ -35546,6 +35550,15 @@ appropriate @samp{qSupported} feature (@pxref{qSupported}). The remote stub must also supply the appropriate @samp{qSupported} feature indicating support. +@cindex thread create event, remote reply +@anchor{thread create event} +@item create +The packet indicates that the thread was just created. The new thread +is stopped until @value{GDBN} sets it running with a resumption packet +(@pxref{vCont packet}). This packet should not be sent by default; +@value{GDBN} requests it with the @ref{QThreadEvents} packet. See +also the @samp{w} (@ref{thread exit event}) remote reply below. + @end table @item W @var{AA} @@ -35567,6 +35580,14 @@ terminated process, can be used only when @value{GDBN} has reported support for multiprocess protocol extensions; see @ref{multiprocess extensions}. The @var{pid} is formatted as a big-endian hex string. +@anchor{thread exit event} +@cindex thread exit event, remote reply +@item w @var{AA} ; @var{tid} + +The thread exited, and @var{AA} is the exit status. This response +should not be sent by default; @value{GDBN} requests it with the +@ref{QThreadEvents} packet. See also @ref{thread create event} above. + @item O @var{XX}@dots{} @samp{@var{XX}@dots{}} is hex encoding of @sc{ascii} data, to be written as the program's console output. This can happen at any time @@ -35984,6 +36005,39 @@ command (@pxref{Remote Configuration, set remote program-signals}). This packet is not probed by default; the remote stub must request it, by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}). +@anchor{QThreadEvents} +@item QThreadEvents:1 +@itemx QThreadEvents:0 +@cindex thread create/exit events, remote request +@cindex @samp{QThreadEvents} packet + +Enable (@samp{QThreadEvents:1}) or disable (@samp{QThreadEvents:0}) +reporting of thread create and exit events. @xref{thread create +event}, for the reply specifications. For example, this is used in +non-stop mode when @value{GDBN} stops a set of threads and +synchronously waits for the their corresponding stop replies. Without +exit events, if one of the threads exits, @value{GDBN} would hang +forever not knowing that it should no longer expect a stop for that +same thread. @value{GDBN} does not enable this feature unless the +stub reports that it supports it by including @samp{QThreadEvents+} in +its @samp{qSupported} reply. + +Reply: +@table @samp +@item OK +The request succeeded. + +@item E @var{nn} +An error occurred. The error number @var{nn} is given as hex digits. + +@item @w{} +An empty reply indicates that @samp{QThreadEvents} is not supported by +the stub. +@end table + +Use of this packet is controlled by the @code{set remote thread-events} +command (@pxref{Remote Configuration, set remote thread-events}). + @item qRcmd,@var{command} @cindex execute remote command, remote request @cindex @samp{qRcmd} packet @@ -36428,6 +36482,11 @@ These are the currently defined stub features and their properties: @tab @samp{-} @tab No +@item @samp{QThreadEvents} +@tab No +@tab @samp{-} +@tab No + @end multitable These are the currently defined stub features, in more detail: @@ -36640,6 +36699,9 @@ The remote stub reports the @samp{exec} stop reason for exec events. The remote stub reports the supported actions in the reply to @samp{vCont?} packet. +@item QThreadEvents +The remote stub understands the @samp{QThreadEvents} packet. + @end table @item qSymbol:: |