From 33da3f1cb51cb8851ab5b12d1f5fa61e45232276 Mon Sep 17 00:00:00 2001 From: Stan Shebs Date: Fri, 9 Apr 2010 03:00:58 +0000 Subject: 2010-04-08 Stan Shebs Pedro Alves * tracepoint.h (struct trace_status): New fields disconnected_tracing and circular_buffer. (disconnect_tracing): Rename from disconnect_or_stop_tracing. * tracepoint.c (trace_status_command): Display target's status for disconnected tracing and circular buffer. (disconnect_tracing): Rename from disconnect_or_stop_tracing, add query for non-disconnected-tracing case, remove the stop_tracing call. (tfile_open): Clear disconnected and circular buffer status. (trace_save): Save disconnected and circular buffer status. (parse_trace_status): Parse disconnected and circular buffer status, also recognize disconnected as a stop reason. * remote.c (remote_set_disconnected_tracing): Only set QTDisconnected if the remote end supports disconnected tracing. Warn otherwise, if trying to enable disconnected tracing. * infcmd.c (detach_command): Update disconnect_tracing call. * cli/cli-cmds.c (quit_command): Ditto. * gdb.texinfo (Tracepoint Packets): Describe disconn and circular trace status fields. --- gdb/ChangeLog | 21 +++++++++++++++++ gdb/cli/cli-cmds.c | 4 ++-- gdb/doc/ChangeLog | 5 ++++ gdb/doc/gdb.texinfo | 20 ++++++++++++---- gdb/infcmd.c | 2 +- gdb/remote.c | 15 ++++++++---- gdb/tracepoint.c | 66 ++++++++++++++++++++++++++++++++++++++++------------- gdb/tracepoint.h | 12 +++++++++- 8 files changed, 116 insertions(+), 29 deletions(-) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 217295e..123d345f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,24 @@ +2010-04-08 Stan Shebs + Pedro Alves + + * tracepoint.h (struct trace_status): New fields disconnected_tracing + and circular_buffer. + (disconnect_tracing): Rename from disconnect_or_stop_tracing. + * tracepoint.c (trace_status_command): Display target's status for + disconnected tracing and circular buffer. + (disconnect_tracing): Rename from disconnect_or_stop_tracing, add + query for non-disconnected-tracing case, remove the stop_tracing + call. + (tfile_open): Clear disconnected and circular buffer status. + (trace_save): Save disconnected and circular buffer status. + (parse_trace_status): Parse disconnected and circular buffer status, + also recognize disconnected as a stop reason. + * remote.c (remote_set_disconnected_tracing): Only set + QTDisconnected if the remote end supports disconnected tracing. + Warn otherwise, if trying to enable disconnected tracing. + * infcmd.c (detach_command): Update disconnect_tracing call. + * cli/cli-cmds.c (quit_command): Ditto. + 2010-04-08 H.J. Lu * i387-tdep.c (i387_collect_xsave): Replace abort with diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index ae0be7a..aaf0586 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -38,7 +38,7 @@ #include "objfiles.h" #include "source.h" #include "disasm.h" -extern void disconnect_or_stop_tracing (int from_tty); +#include "tracepoint.h" #include "ui-out.h" @@ -337,7 +337,7 @@ quit_command (char *args, int from_tty) if (!quit_confirm ()) error (_("Not confirmed.")); - disconnect_or_stop_tracing (from_tty); + disconnect_tracing (from_tty); quit_force (args, from_tty); } diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index e3ca994..9b98dc0 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2010-04-08 Stan Shebs + + * gdb.texinfo (Tracepoint Packets): Describe disconn and circular + trace status fields. + 2010-04-08 H.J. Lu * gdb.texinfo (i386 Features): Make org.gnu.gdb.i386.avx diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 01ede98..bd2b441 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -31508,10 +31508,11 @@ The trace stopped for some other reason. @end table -Additional optional fields supply statistical information. Although -not required, they are extremely useful for users monitoring the -progress of a trace run. If a trace has stopped, and these numbers -are reported, they must reflect the state of the just-stopped trace. +Additional optional fields supply statistical and other information. +Although not required, they are extremely useful for users monitoring +the progress of a trace run. If a trace has stopped, and these +numbers are reported, they must reflect the state of the just-stopped +trace. @table @samp @@ -31528,6 +31529,17 @@ The total size of the trace buffer, in bytes. @item tfree:@var{n} The number of bytes still unused in the buffer. +@item circular:@var{n} +The value of the circular trace buffer flag. @code{1} means that the +trace buffer is circular and old trace frames will be discarded if +necessary to make room, @code{0} means that the trace buffer is linear +and may fill up. + +@item disconn:@var{n} +The value of the disconnected tracing flag. @code{1} means that +tracing will continue after @value{GDBN} disconnects, @code{0} means +that the trace run will stop. + @end table @item qTV:@var{var} diff --git a/gdb/infcmd.c b/gdb/infcmd.c index a803bcb..16d32a6 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2547,7 +2547,7 @@ detach_command (char *args, int from_tty) if (ptid_equal (inferior_ptid, null_ptid)) error (_("The program is not being run.")); - disconnect_or_stop_tracing (from_tty); + disconnect_tracing (from_tty); target_detach (args, from_tty); diff --git a/gdb/remote.c b/gdb/remote.c index 685be7a..0809260 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -9776,11 +9776,16 @@ remote_set_disconnected_tracing (int val) { struct remote_state *rs = get_remote_state (); - sprintf (rs->buf, "QTDisconnected:%x", val); - putpkt (rs->buf); - remote_get_noisy_reply (&target_buf, &target_buf_size); - if (strcmp (target_buf, "OK")) - error (_("Target does not support this command.")); + if (rs->disconnected_tracing) + { + sprintf (rs->buf, "QTDisconnected:%x", val); + putpkt (rs->buf); + remote_get_noisy_reply (&target_buf, &target_buf_size); + if (strcmp (target_buf, "OK")) + error (_("Target does not support this command.")); + } + else if (val) + warning (_("Target does not support disconnected tracing.")); } static int diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index c25be70..41fcc97 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1626,10 +1626,6 @@ trace_status_command (char *args, int from_tty) else if (ts->running) { printf_filtered (_("Trace is running on the target.\n")); - if (disconnected_tracing) - printf_filtered (_("Trace will continue if GDB disconnects.\n")); - else - printf_filtered (_("Trace will stop if GDB disconnects.\n")); } else { @@ -1699,6 +1695,14 @@ trace_status_command (char *args, int from_tty) ts->buffer_free); } + if (ts->disconnected_tracing) + printf_filtered (_("Trace will continue if GDB disconnects.\n")); + else + printf_filtered (_("Trace will stop if GDB disconnects.\n")); + + if (ts->circular_buffer) + printf_filtered (_("Trace buffer is circular.\n")); + /* Now report on what we're doing with tfind. */ if (traceframe_number >= 0) printf_filtered (_("Looking at trace frame %d, tracepoint %d.\n"), @@ -1801,9 +1805,11 @@ trace_status_mi (int on_stop) ui_out_field_int (uiout, "buffer-free", (int) ts->buffer_free); } - +/* 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_or_stop_tracing (int from_tty) +disconnect_tracing (int from_tty) { /* 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 @@ -1812,18 +1818,23 @@ disconnect_or_stop_tracing (int from_tty) if (target_get_trace_status (current_trace_status ()) < 0) current_trace_status ()->running = 0; + /* If running interactively, give the user the option to cancel and + then decide what to do differently with the run. Scripts are + 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) { - int cont = query (_("Trace is running. Continue tracing after detach? ")); - /* Note that we send the query result without affecting the - user's setting of disconnected_tracing, so that the answer is - a one-time-only. */ - send_disconnected_tracing_value (cont); - - /* Also ensure that we do the equivalent of a tstop command if - tracing is not to continue after the detach. */ - if (!cont) - stop_tracing (); + if (current_trace_status ()->disconnected_tracing) + { + if (!query (_("Trace is running and will continue after detach; detach anyway? "))) + error (_("Not confirmed.")); + } + else + { + if (!query (_("Trace is running but will stop on detach; detach anyway? "))) + error (_("Not confirmed.")); + } } /* Also we want to be out of tfind mode, otherwise things can get @@ -2599,6 +2610,10 @@ trace_save (const char *filename, int target_does_save) fprintf (fp, ";tfree:%x", ts->buffer_free); if (ts->buffer_size >= 0) fprintf (fp, ";tsize:%x", ts->buffer_size); + if (ts->disconnected_tracing) + fprintf (fp, ";disconn:%x", ts->disconnected_tracing); + if (ts->circular_buffer) + fprintf (fp, ";circular:%x", ts->circular_buffer); fprintf (fp, "\n"); /* Note that we want to upload tracepoints and save those, rather @@ -3167,6 +3182,8 @@ tfile_open (char *filename, int from_tty) ts->stop_reason = trace_stop_reason_unknown; ts->traceframe_count = -1; ts->buffer_free = 0; + ts->disconnected_tracing = 0; + ts->circular_buffer = 0; /* Read through a section of newline-terminated lines that define things like tracepoints. */ @@ -3282,6 +3299,8 @@ parse_trace_status (char *line, struct trace_status *ts) ts->traceframes_created = -1; ts->buffer_free = -1; ts->buffer_size = -1; + ts->disconnected_tracing = 0; + ts->circular_buffer = 0; while (*p++) { @@ -3310,6 +3329,11 @@ Status line: '%s'\n"), p, line); p = unpack_varlen_hex (++p1, &val); ts->stop_reason = tstop_command; } + else if (strncmp (p, stop_reason_names[trace_disconnected], p1 - p) == 0) + { + p = unpack_varlen_hex (++p1, &val); + ts->stop_reason = trace_disconnected; + } else if (strncmp (p, stop_reason_names[tracepoint_error], p1 - p) == 0) { p2 = strchr (++p1, ':'); @@ -3348,6 +3372,16 @@ Status line: '%s'\n"), p, line); p = unpack_varlen_hex (++p1, &val); ts->buffer_size = val; } + else if (strncmp (p, "disconn", p1 - p) == 0) + { + p = unpack_varlen_hex (++p1, &val); + ts->disconnected_tracing = val; + } + else if (strncmp (p, "circular", p1 - p) == 0) + { + p = unpack_varlen_hex (++p1, &val); + ts->circular_buffer = val; + } else { /* Silently skip unknown optional info. */ diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h index 13e956f..98d56ba 100644 --- a/gdb/tracepoint.h +++ b/gdb/tracepoint.h @@ -106,6 +106,16 @@ struct trace_status /* Unused bytes left in the target's trace buffer. */ int buffer_free; + + /* 1 if the target will continue tracing after disconnection, else + 0. If the target does not report a value, assume 0. */ + + int disconnected_tracing; + + /* 1 if the target is using a circular trace buffer, else 0. If the + target does not report a value, assume 0. */ + + int circular_buffer; }; struct trace_status *current_trace_status (void); @@ -189,7 +199,7 @@ extern struct breakpoint *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_or_stop_tracing (int from_tty); +extern void disconnect_tracing (int from_tty); extern void start_tracing (void); extern void stop_tracing (void); -- cgit v1.1