diff options
author | Pedro Alves <palves@redhat.com> | 2013-04-10 14:10:35 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2013-04-10 14:10:35 +0000 |
commit | 2f9d54cfcef6c6085ff4bfcbf42c963527606d89 (patch) | |
tree | ddf41b30c24fcdd146e0d03f1c2856ef1b87fb01 /gdb/tracepoint.c | |
parent | eb9f3f001ff1b478f3ba245aab5b8f89ff76b456 (diff) | |
download | gdb-2f9d54cfcef6c6085ff4bfcbf42c963527606d89.zip gdb-2f9d54cfcef6c6085ff4bfcbf42c963527606d89.tar.gz gdb-2f9d54cfcef6c6085ff4bfcbf42c963527606d89.tar.bz2 |
make -gdb-exit call disconnect_tracing too, and don't lose history if the target errors on "quit"
Gareth mentions in PR gdb/15275:
"The MI '-gdb-exit' command mi_cmd_gdb_exit() never calls disconnect_tracing()
and therefore exits correctly."
It should, so to get out of tfind mode, as quit may detach instead of
kill, and we don't want to confuse the memory/register accesses
etc. of the detach process. So we should push down the disconnect
tracing bits at least to quit_force. But we can't as is, as that
would swallow the error thrown by answering "no" to:
Trace is running but will stop on detach; detach anyway? (y or n)
So to address that, we split disconnect_tracing in two. One part that
does the query, and another part that does the rest, and we make
quit_force call the latter.
Looking at quit_force, it does several things, some of which are a bit
independent of the others. It first kills/detaches, and then writes
history, and then runs the final cleanups. It seems better to me to
do each of these things even if the previous thing throws. E.g., as
is, if something throws while detaching, then we skip writing history.
Tested on x86_64 Fedora 17.
gdb/
2013-04-10 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (quit_command): Call query_if_trace_running
instead of disconnect_tracing.
* infcmd.c (detach_command, disconnect_command): Call
query_if_trace_running. Adjust.
* top.c: Include "tracepoint.h".
(quit_target): Delete. Contents moved ...
(quit_force): ... here. Wrap each stage of teardown in
TRY_CATCH. Call disconnect_tracing before detaching.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index c9ffc77..7b4cfb2 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2204,12 +2204,15 @@ trace_status_mi (int on_stop) } } -/* This function handles the details of what to do about an ongoing - tracing run if the user has asked to detach or otherwise disconnect - from the target. */ +/* Check if a trace run is ongoing. If so, and FROM_TTY, query the + user if she really wants to detach. */ + void -disconnect_tracing (int from_tty) +query_if_trace_running (int from_tty) { + if (!from_tty) + return; + /* It can happen that the target that was tracing went away on its own, and we didn't notice. Get a status update, and if the current target doesn't even do tracing, then assume it's not @@ -2222,7 +2225,7 @@ disconnect_tracing (int from_tty) just going to disconnect and let the target deal with it, according to how it's been instructed previously via disconnected-tracing. */ - if (current_trace_status ()->running && from_tty) + if (current_trace_status ()->running) { process_tracepoint_on_disconnect (); @@ -2239,7 +2242,15 @@ disconnect_tracing (int from_tty) error (_("Not confirmed.")); } } +} +/* This function handles the details of what to do about an ongoing + tracing run if the user has asked to detach or otherwise disconnect + from the target. */ + +void +disconnect_tracing (void) +{ /* Also we want to be out of tfind mode, otherwise things can get confusing upon reconnection. Just use these calls instead of full tfind_1 behavior because we're in the middle of detaching, |