From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21431 invoked by alias); 14 Feb 2013 15:49:46 -0000 Received: (qmail 21415 invoked by uid 22791); 14 Feb 2013 15:49:45 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Feb 2013 15:49:35 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1U6142-00027v-9c from Hafiz_Abid@mentor.com ; Thu, 14 Feb 2013 07:49:34 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 14 Feb 2013 07:49:34 -0800 Received: from abidh-ubunto1104 (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.1.289.1; Thu, 14 Feb 2013 15:49:32 +0000 Date: Thu, 14 Feb 2013 15:49:00 -0000 From: "Abid, Hafiz" Subject: Re: [Patch] Get trace file name when using 'target tfile' To: Pedro Alves , CC: Yao Qi , , In-Reply-To: <511CF5E7.1090600@redhat.com> (from palves@redhat.com on Thu Feb 14 14:34:15 2013) Message-ID: <1360856970.2842.4@abidh-ubunto1104> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-UVrUI+30jwHLSuS1h7Ts" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-02/txt/msg00348.txt.bz2 --=-UVrUI+30jwHLSuS1h7Ts Content-Type: text/plain; charset="us-ascii"; delsp=Yes; format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 2147 On 14/02/13 14:34:15, Pedro Alves wrote: > On 02/14/2013 03:16 AM, Yao Qi wrote: > > On 02/13/2013 10:38 PM, Abid, Hafiz wrote: > >> - /* This is true if the status is coming from a file rather > >> - than a live target. */ > >> - int from_file; > >> + /* If the status is coming from a file rather than a live=20=20 > target, > >> + this points at the file's filename. Otherwise, this is=20=20 > NULL. */ > >> + const char *from_file; > > > > How about rename this field to "trace_filename", or something=20=20 > similar? "from_file" is fine as a boolean, but is confusing as a the=20=20 > name of trace file. >=20 > Fine with me. I'd drop the "trace_" bit as being redundant > with "struct trace_status". >=20 > -- > Pedro Alves >=20 >=20 Hi, Thanks everybody for review. The updated patch is attached. The changes=20= =20 from the previous version are. 1. Renamed "from_file" field to "filename". Use explicit NULL(or=20=20 non-NULL) check against it. 2. Added a test case for -trace-struct command. 3. Added NEWS entry. How does it look? Regards, Abid 2013-02-14 Pedro Alves Hafiz Abid Qadeer gdb/ * NEWS: Mention new field "trace-file". * tracepoint.c (trace_status_mi): Output "trace-file" field. (tfile_open): Record the trace file's filename in the trace status. (tfile_files_info): Mention the name of the trace file. Check the "filename" field explicitely. (trace_status_command): Explicitely check "filename" field. (trace_find_command): Ditto. (trace_find_pc_command): Ditto. (trace_find_tracepoint_command): Ditto. (trace_find_line_command): Ditto. (trace_find_range_command): Ditto. (trace_find_outside_command): Ditto. * tracepoint.h (struct trace_status) : Rename it to "filename" and make it hold the trace file's filename instead of a boolean. * remote.c (remote_get_trace_status): Initialize "filename" field with NULL instead of 0. gdb/doc/ * gdb.texinfo (GDB/MI Tracepoint Commands) <-trace-status>: Document the "trace-file" field. gdb/testsuite/ * gdb.trace/tfile.exp: Add test for -trace-status command. --=-UVrUI+30jwHLSuS1h7Ts Content-Type: text/x-patch; charset="us-ascii"; name="trace_v2.patch" Content-Disposition: attachment; filename="trace_v2.patch" Content-Transfer-Encoding: quoted-printable Content-length: 7262 diff --git a/gdb/NEWS b/gdb/NEWS index 38b36c2..13c7b76 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -150,6 +150,9 @@ show filename-display ** The response to breakpoint commands and breakpoint async records includes an "installed" field containing a boolean state about each non-pending tracepoint location is whether installed on target or not. + ** Output of the "-trace-status" command includes a "trace-file" field=20 + containing the name of the trace file being examined. This field is + optional, and only present when examining a trace file. =20 * GDB now supports the "mini debuginfo" section, .gnu_debugdata. You must have the LZMA library available when configuring GDB for this diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e3f336e..e8ac8c5 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -32094,6 +32094,10 @@ 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. =20 +@item trace-file +The filename of the trace file being examined. This field is +optional, and only present when examining a trace file. + @end table =20 @subsubheading @value{GDBN} Command diff --git a/gdb/remote.c b/gdb/remote.c index 18fe61d..1e42847 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -10701,7 +10701,7 @@ remote_get_trace_status (struct trace_status *ts) return -1; =20 /* We're working with a live target. */ - ts->from_file =3D 0; + ts->filename =3D NULL; =20 if (*p++ !=3D 'T') error (_("Bogus trace status reply from target: %s"), target_buf); diff --git a/gdb/testsuite/gdb.trace/tfile.exp b/gdb/testsuite/gdb.trace/tf= ile.exp index b07be75..2bdde37 100644 --- a/gdb/testsuite/gdb.trace/tfile.exp +++ b/gdb/testsuite/gdb.trace/tfile.exp @@ -106,3 +106,7 @@ Not looking at any trace frame.*" \ gdb_test \ "interpreter-exec mi \"-target-select tfile basic.tf\"" \ "\\^connected.*" + +gdb_test "interpreter-exec mi \"-trace-status\"" \ + "\\^done,supported=3D\"file\",trace-file=3D\".*basic.tf\",running=3D\"= 0\",stop-reason=3D\"request\",frames=3D\"${decimal}\",frames-created=3D\"${= decimal}\",buffer-size=3D\"${decimal}\",buffer-free=3D\"${decimal}\",discon= nected=3D\".*\",circular=3D\".*\",user-name=3D\"\",notes=3D\"\",start-time= =3D\".*\",stop-time=3D\".*\"" \ + "-trace-status" diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index b45863e..ada0a21 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -1923,7 +1923,7 @@ trace_status_command (char *args, int from_tty) =20 if (status =3D=3D -1) { - if (ts->from_file) + if (ts->filename !=3D NULL) printf_filtered (_("Using a trace file.\n")); else { @@ -2083,17 +2083,20 @@ trace_status_mi (int on_stop) =20 status =3D target_get_trace_status (ts); =20 - if (status =3D=3D -1 && !ts->from_file) + if (status =3D=3D -1 && ts->filename =3D=3D NULL) { ui_out_field_string (uiout, "supported", "0"); return; } =20 - if (ts->from_file) + if (ts->filename !=3D NULL) ui_out_field_string (uiout, "supported", "file"); else if (!on_stop) ui_out_field_string (uiout, "supported", "1"); =20 + if (ts->filename !=3D NULL) + ui_out_field_string (uiout, "trace-file", ts->filename); + gdb_assert (ts->running_known); =20 if (ts->running) @@ -2382,7 +2385,8 @@ trace_find_command (char *args, int from_tty) { /* This should only be called with a numeric argument. */ int frameno =3D -1; =20 - if (current_trace_status ()->running && !current_trace_status ()->from_f= ile) + if (current_trace_status ()->running + && current_trace_status ()->filename =3D=3D NULL) error (_("May not look at trace frames while trace is running.")); =20=20=20 if (args =3D=3D 0 || *args =3D=3D 0) @@ -2433,7 +2437,8 @@ trace_find_pc_command (char *args, int from_tty) { CORE_ADDR pc; =20 - if (current_trace_status ()->running && !current_trace_status ()->from_f= ile) + if (current_trace_status ()->running + && current_trace_status ()->filename =3D=3D NULL) error (_("May not look at trace frames while trace is running.")); =20 if (args =3D=3D 0 || *args =3D=3D 0) @@ -2451,7 +2456,8 @@ trace_find_tracepoint_command (char *args, int from_t= ty) int tdp; struct tracepoint *tp; =20 - if (current_trace_status ()->running && !current_trace_status ()->from_f= ile) + if (current_trace_status ()->running + && current_trace_status ()->filename =3D=3D NULL) error (_("May not look at trace frames while trace is running.")); =20 if (args =3D=3D 0 || *args =3D=3D 0) @@ -2490,7 +2496,8 @@ trace_find_line_command (char *args, int from_tty) struct symtab_and_line sal; struct cleanup *old_chain; =20 - if (current_trace_status ()->running && !current_trace_status ()->from_f= ile) + if (current_trace_status ()->running + && current_trace_status ()->filename =3D=3D NULL) error (_("May not look at trace frames while trace is running.")); =20 if (args =3D=3D 0 || *args =3D=3D 0) @@ -2555,7 +2562,8 @@ trace_find_range_command (char *args, int from_tty) static CORE_ADDR start, stop; char *tmp; =20 - if (current_trace_status ()->running && !current_trace_status ()->from_f= ile) + if (current_trace_status ()->running + && current_trace_status ()->filename =3D=3D NULL) error (_("May not look at trace frames while trace is running.")); =20 if (args =3D=3D 0 || *args =3D=3D 0) @@ -2588,7 +2596,8 @@ trace_find_outside_command (char *args, int from_tty) CORE_ADDR start, stop; char *tmp; =20 - if (current_trace_status ()->running && !current_trace_status ()->from_f= ile) + if (current_trace_status ()->running + && current_trace_status ()->filename =3D=3D NULL) error (_("May not look at trace frames while trace is running.")); =20 if (args =3D=3D 0 || *args =3D=3D 0) @@ -3745,8 +3754,8 @@ tfile_open (char *filename, int from_tty) =20 trace_regblock_size =3D 0; ts =3D current_trace_status (); - /* We know we're working with a file. */ - ts->from_file =3D 1; + /* We know we're working with a file. Record its name. */ + ts->filename =3D trace_filename; /* Set defaults in case there is no status line. */ ts->running_known =3D 0; ts->stop_reason =3D trace_stop_reason_unknown; @@ -4196,8 +4205,7 @@ tfile_close (int quitting) static void tfile_files_info (struct target_ops *t) { - /* (it would be useful to mention the name of the file). */ - printf_filtered ("Looking at a trace file.\n"); + printf_filtered ("\t`%s'\n", trace_filename); } =20 /* The trace status for a file is that tracing can never be run. */ diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h index 2e1d83a..b6c698c 100644 --- a/gdb/tracepoint.h +++ b/gdb/tracepoint.h @@ -72,9 +72,9 @@ enum trace_stop_reason =20 struct trace_status { - /* This is true if the status is coming from a file rather - than a live target. */ - int from_file; + /* If the status is coming from a file rather than a live target, + this points at the file's filename. Otherwise, this is NULL. */ + const char *filename; =20 /* This is true if the value of the running field is known. */ int running_known; --=-UVrUI+30jwHLSuS1h7Ts--