+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>
if (!quit_confirm ())
error (_("Not confirmed."));
- disconnect_tracing (from_tty);
+ query_if_trace_running (from_tty);
quit_force (args, 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);
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 ();
#include <ctype.h>
#include "ui-out.h"
#include "cli-out.h"
+#include "tracepoint.h"
extern void initialize_all_files (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
{
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. */
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);
}
}
}
-/* 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
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 ();
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,
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);