Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.264 diff -p -r1.264 infcmd.c *** infcmd.c 4 Apr 2010 22:12:04 -0000 1.264 --- infcmd.c 9 Apr 2010 02:59:41 -0000 *************** detach_command (char *args, int from_tty *** 2547,2553 **** if (ptid_equal (inferior_ptid, null_ptid)) error (_("The program is not being run.")); ! disconnect_or_stop_tracing (from_tty); target_detach (args, from_tty); --- 2547,2553 ---- if (ptid_equal (inferior_ptid, null_ptid)) error (_("The program is not being run.")); ! disconnect_tracing (from_tty); target_detach (args, from_tty); Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.399 diff -p -r1.399 remote.c *** remote.c 2 Apr 2010 01:18:34 -0000 1.399 --- remote.c 9 Apr 2010 02:59:41 -0000 *************** remote_set_disconnected_tracing (int val *** 9776,9786 **** { 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.")); } static int --- 9776,9791 ---- { struct remote_state *rs = get_remote_state (); ! 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 Index: tracepoint.c =================================================================== RCS file: /cvs/src/src/gdb/tracepoint.c,v retrieving revision 1.173 diff -p -r1.173 tracepoint.c *** tracepoint.c 6 Apr 2010 17:47:40 -0000 1.173 --- tracepoint.c 9 Apr 2010 02:59:41 -0000 *************** trace_status_command (char *args, int fr *** 1626,1635 **** 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 { --- 1626,1631 ---- *************** trace_status_command (char *args, int fr *** 1699,1704 **** --- 1695,1708 ---- 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"), *************** trace_status_mi (int on_stop) *** 1801,1809 **** ui_out_field_int (uiout, "buffer-free", (int) ts->buffer_free); } ! void ! disconnect_or_stop_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 --- 1805,1815 ---- 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_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 *************** disconnect_or_stop_tracing (int from_tty *** 1812,1829 **** if (target_get_trace_status (current_trace_status ()) < 0) current_trace_status ()->running = 0; 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 (); } /* Also we want to be out of tfind mode, otherwise things can get --- 1818,1840 ---- 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) { ! 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 *************** trace_save (const char *filename, int ta *** 2599,2604 **** --- 2610,2619 ---- 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 *************** tfile_open (char *filename, int from_tty *** 3167,3172 **** --- 3182,3189 ---- 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. */ *************** parse_trace_status (char *line, struct t *** 3282,3287 **** --- 3299,3306 ---- ts->traceframes_created = -1; ts->buffer_free = -1; ts->buffer_size = -1; + ts->disconnected_tracing = 0; + ts->circular_buffer = 0; while (*p++) { *************** Status line: '%s'\n"), p, line); *** 3310,3315 **** --- 3329,3339 ---- 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, ':'); *************** Status line: '%s'\n"), p, line); *** 3348,3353 **** --- 3372,3387 ---- 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. */ Index: tracepoint.h =================================================================== RCS file: /cvs/src/src/gdb/tracepoint.h,v retrieving revision 1.34 diff -p -r1.34 tracepoint.h *** tracepoint.h 6 Apr 2010 17:47:40 -0000 1.34 --- tracepoint.h 9 Apr 2010 02:59:41 -0000 *************** struct trace_status *** 106,111 **** --- 106,121 ---- /* 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); *************** extern struct breakpoint *create_tracepo *** 189,195 **** 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 start_tracing (void); extern void stop_tracing (void); --- 199,205 ---- 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 start_tracing (void); extern void stop_tracing (void); Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.698 diff -p -r1.698 gdb.texinfo *** doc/gdb.texinfo 8 Apr 2010 22:32:37 -0000 1.698 --- doc/gdb.texinfo 9 Apr 2010 02:59:42 -0000 *************** The trace stopped for some other reason. *** 31508,31517 **** @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. @table @samp --- 31508,31518 ---- @end table ! 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 *************** The total size of the trace buffer, in b *** 31528,31533 **** --- 31529,31545 ---- @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} Index: cli/cli-cmds.c =================================================================== RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v retrieving revision 1.99 diff -p -r1.99 cli-cmds.c *** cli/cli-cmds.c 7 Apr 2010 03:42:55 -0000 1.99 --- cli/cli-cmds.c 9 Apr 2010 02:59:42 -0000 *************** *** 38,44 **** #include "objfiles.h" #include "source.h" #include "disasm.h" ! extern void disconnect_or_stop_tracing (int from_tty); #include "ui-out.h" --- 38,44 ---- #include "objfiles.h" #include "source.h" #include "disasm.h" ! #include "tracepoint.h" #include "ui-out.h" *************** quit_command (char *args, int from_tty) *** 337,343 **** if (!quit_confirm ()) error (_("Not confirmed.")); ! disconnect_or_stop_tracing (from_tty); quit_force (args, from_tty); } --- 337,343 ---- if (!quit_confirm ()) error (_("Not confirmed.")); ! disconnect_tracing (from_tty); quit_force (args, from_tty); }