diff options
-rw-r--r-- | gdb/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/cli/cli-cmds.c | 2 | ||||
-rw-r--r-- | gdb/infcmd.c | 7 | ||||
-rw-r--r-- | gdb/top.c | 66 | ||||
-rw-r--r-- | gdb/tracepoint.c | 21 | ||||
-rw-r--r-- | gdb/tracepoint.h | 3 |
6 files changed, 76 insertions, 34 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d37981d..bd222cc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +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. + 2013-04-10 Hui Zhu <hui@codesourcery.com> Yao Qi <yao@codesourcery.com> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index c05f77f..c4721bd 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -322,7 +322,7 @@ quit_command (char *args, int from_tty) if (!quit_confirm ()) error (_("Not confirmed.")); - disconnect_tracing (from_tty); + query_if_trace_running (from_tty); quit_force (args, from_tty); } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index c60f19a..af6a4db 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2721,7 +2721,9 @@ detach_command (char *args, int from_tty) if (ptid_equal (inferior_ptid, null_ptid)) error (_("The program is not being run.")); - disconnect_tracing (from_tty); + query_if_trace_running (from_tty); + + disconnect_tracing (); target_detach (args, from_tty); @@ -2751,7 +2753,8 @@ static void disconnect_command (char *args, int from_tty) { dont_repeat (); /* Not for the faint of heart. */ - disconnect_tracing (from_tty); + query_if_trace_running (from_tty); + disconnect_tracing (); target_disconnect (args, from_tty); no_shared_libraries (NULL, from_tty); init_thread_list (); @@ -64,6 +64,7 @@ #include <ctype.h> #include "ui-out.h" #include "cli-out.h" +#include "tracepoint.h" extern void initialize_all_files (void); @@ -1282,29 +1283,6 @@ quit_confirm (void) return qr; } -/* Helper routine for quit_force that requires error handling. */ - -static int -quit_target (void *arg) -{ - struct qt_args *qt = (struct qt_args *)arg; - - /* Kill or detach all inferiors. */ - iterate_over_inferiors (kill_or_detach, qt); - - /* Give all pushed targets a chance to do minimal cleanup, and pop - them all out. */ - pop_all_targets (); - - /* Save the history information if it is appropriate to do so. */ - if (write_history_p && history_filename) - write_history (history_filename); - - do_final_cleanups (all_cleanups ()); /* Do any final cleanups before - exiting. */ - return 0; -} - /* Quit without asking for confirmation. */ void @@ -1312,6 +1290,7 @@ quit_force (char *args, int from_tty) { int exit_code = 0; struct qt_args qt; + volatile struct gdb_exception ex; /* An optional expression may be used to cause gdb to terminate with the value of that expression. */ @@ -1327,9 +1306,46 @@ quit_force (char *args, int from_tty) qt.args = args; qt.from_tty = from_tty; + /* Wrappers to make the code below a bit more readable. */ +#define DO_TRY \ + TRY_CATCH (ex, RETURN_MASK_ALL) + +#define DO_PRINT_EX \ + if (ex.reason < 0) \ + exception_print (gdb_stderr, ex) + /* We want to handle any quit errors and exit regardless. */ - catch_errors (quit_target, &qt, - "Quitting: ", RETURN_MASK_ALL); + + /* Get out of tfind mode, and kill or detach all inferiors. */ + DO_TRY + { + disconnect_tracing (); + iterate_over_inferiors (kill_or_detach, &qt); + } + DO_PRINT_EX; + + /* Give all pushed targets a chance to do minimal cleanup, and pop + them all out. */ + DO_TRY + { + pop_all_targets (); + } + DO_PRINT_EX; + + /* Save the history information if it is appropriate to do so. */ + DO_TRY + { + if (write_history_p && history_filename) + write_history (history_filename); + } + DO_PRINT_EX; + + /* Do any final cleanups before exiting. */ + DO_TRY + { + do_final_cleanups (all_cleanups ()); + } + DO_PRINT_EX; exit (exit_code); } 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, diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h index f88394b..18762ca 100644 --- a/gdb/tracepoint.h +++ b/gdb/tracepoint.h @@ -387,7 +387,8 @@ extern struct tracepoint *create_tracepoint_from_upload (struct uploaded_tp *utp extern void merge_uploaded_tracepoints (struct uploaded_tp **utpp); extern void merge_uploaded_trace_state_variables (struct uploaded_tsv **utsvp); -extern void disconnect_tracing (int from_tty); +extern void query_if_trace_running (int from_tty); +extern void disconnect_tracing (void); extern void start_tracing (char *notes); extern void stop_tracing (char *notes); |