* [Patch] Get trace file name when using 'target tfile'
@ 2013-02-13 14:38 Abid, Hafiz
2013-02-13 16:34 ` Pedro Alves
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Abid, Hafiz @ 2013-02-13 14:38 UTC (permalink / raw)
To: gdb-patches; +Cc: palves, marc.khouzam
[-- Attachment #1: Type: text/plain, Size: 1651 bytes --]
Hi All,
When using 'target tfile', commands like 'info target' and 'info files'
don't show the name of the trace file. This patch adds this
information. It also add a new field in the output of the -trace-status
command so that frontends can get this inforamtion.
This patch was originally written by Pedro. I have updated and
regtested it.
Regards,
Abid
Before:
(gdb) info target
Local trace dump file:
Looking at a trace file.
(gdb) interpreter-exec mi -trace-status
^done,supported="file",running="0",stop-reason="request",frames="7215",frames-created="7215",buffer-size="5242880",buffer-free="2833070",disconnected="0",circular="0",user-name="",notes="",start-time="0.000000",stop-time="0.000000"
After:
(gdb) info target
Local trace dump file:
`/home/abidh/trace.txt'
(gdb) interpreter-exec mi -trace-status
^done,supported="file",trace-file="/home/abidh/trace.txt",running="0",stop-reason="request",frames="7215",frames-created="7215",buffer-size="5242880",buffer-free="2833070",disconnected="0",circular="0",user-name="",notes="",start-time="0.000000",stop-time="0.000000"
2013-02-13 Pedro Alves <pedro@codesourcery.com>
Hafiz Abid Qadeer <abidh@codesourcery.com>
gdb/
* 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.
* tracepoint.h (struct trace_status) <from_file>: Make it hold
the
trace file's filename instead of a boolean.
gdb/doc/
* gdb.texinfo (GDB/MI Tracepoint Commands) <-trace-status>:
Document the "trace-file" field.
[-- Attachment #2: trace.patch --]
[-- Type: text/x-patch, Size: 2311 bytes --]
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.
+@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
@subsubheading @value{GDBN} Command
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index b45863e..848a1b1 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2094,6 +2094,9 @@ trace_status_mi (int on_stop)
else if (!on_stop)
ui_out_field_string (uiout, "supported", "1");
+ if (ts->from_file)
+ ui_out_field_string (uiout, "trace-file", ts->from_file);
+
gdb_assert (ts->running_known);
if (ts->running)
@@ -3745,8 +3748,8 @@ tfile_open (char *filename, int from_tty)
trace_regblock_size = 0;
ts = current_trace_status ();
- /* We know we're working with a file. */
- ts->from_file = 1;
+ /* We know we're working with a file. Record its name. */
+ ts->from_file = trace_filename;
/* Set defaults in case there is no status line. */
ts->running_known = 0;
ts->stop_reason = trace_stop_reason_unknown;
@@ -4196,8 +4199,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);
}
/* 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..f407046 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -72,9 +72,9 @@ enum trace_stop_reason
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 *from_file;
/* This is true if the value of the running field is known. */
int running_known;
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [Patch] Get trace file name when using 'target tfile' 2013-02-13 14:38 [Patch] Get trace file name when using 'target tfile' Abid, Hafiz @ 2013-02-13 16:34 ` Pedro Alves 2013-02-13 17:59 ` Eli Zaretskii 2013-02-14 3:17 ` Yao Qi 2 siblings, 0 replies; 9+ messages in thread From: Pedro Alves @ 2013-02-13 16:34 UTC (permalink / raw) To: Abid, Hafiz; +Cc: gdb-patches, marc.khouzam On 02/13/2013 02:38 PM, Abid, Hafiz wrote: > 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. > > +@item trace-file > +The filename of the trace file being examined. This field is > +optional, and only present when examining a trace file. The docs bits need Eli's approval. Obviously it looks good to me. :-) Though, since this adds an MI attribute, it should have a corresponding NEWS entry too. I'd be good to tweak the MI tfile tests to check this new field. Can you do that please? > + if (ts->from_file) if (ts->from_file != NULL) > + ui_out_field_string (uiout, "trace-file", ts->from_file); > + /* We know we're working with a file. Record its name. */ Double space. ----------------------------^ Otherwise this is OK. -- Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch] Get trace file name when using 'target tfile' 2013-02-13 14:38 [Patch] Get trace file name when using 'target tfile' Abid, Hafiz 2013-02-13 16:34 ` Pedro Alves @ 2013-02-13 17:59 ` Eli Zaretskii 2013-02-14 3:17 ` Yao Qi 2 siblings, 0 replies; 9+ messages in thread From: Eli Zaretskii @ 2013-02-13 17:59 UTC (permalink / raw) To: Abid, Hafiz; +Cc: gdb-patches, palves, marc.khouzam > Date: Wed, 13 Feb 2013 14:38:18 +0000 > From: "Abid, Hafiz" <hafiz_abid@mentor.com> > CC: <palves@redhat.com>, <marc.khouzam@ericsson.com> > > --- 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. > > +@item trace-file > +The filename of the trace file being examined. This field is > +optional, and only present when examining a trace file. > + This part is OK. Thanks. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch] Get trace file name when using 'target tfile' 2013-02-13 14:38 [Patch] Get trace file name when using 'target tfile' Abid, Hafiz 2013-02-13 16:34 ` Pedro Alves 2013-02-13 17:59 ` Eli Zaretskii @ 2013-02-14 3:17 ` Yao Qi 2013-02-14 14:34 ` Pedro Alves 2 siblings, 1 reply; 9+ messages in thread From: Yao Qi @ 2013-02-14 3:17 UTC (permalink / raw) To: Abid, Hafiz; +Cc: gdb-patches, palves, marc.khouzam 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 target, > + this points at the file's filename. Otherwise, this is NULL. */ > + const char *from_file; How about rename this field to "trace_filename", or something similar? "from_file" is fine as a boolean, but is confusing as a the name of trace file. -- Yao (é½å°§) ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch] Get trace file name when using 'target tfile' 2013-02-14 3:17 ` Yao Qi @ 2013-02-14 14:34 ` Pedro Alves 2013-02-14 15:49 ` Abid, Hafiz 0 siblings, 1 reply; 9+ messages in thread From: Pedro Alves @ 2013-02-14 14:34 UTC (permalink / raw) To: Yao Qi; +Cc: Abid, Hafiz, gdb-patches, marc.khouzam 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 target, >> + this points at the file's filename. Otherwise, this is NULL. */ >> + const char *from_file; > > How about rename this field to "trace_filename", or something similar? "from_file" is fine as a boolean, but is confusing as a the name of trace file. Fine with me. I'd drop the "trace_" bit as being redundant with "struct trace_status". -- Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch] Get trace file name when using 'target tfile' 2013-02-14 14:34 ` Pedro Alves @ 2013-02-14 15:49 ` Abid, Hafiz 2013-02-14 15:57 ` Pedro Alves 2013-02-14 22:02 ` Eli Zaretskii 0 siblings, 2 replies; 9+ messages in thread From: Abid, Hafiz @ 2013-02-14 15:49 UTC (permalink / raw) To: Pedro Alves, eliz; +Cc: Yao Qi, gdb-patches, marc.khouzam [-- Attachment #1: Type: text/plain, Size: 2182 bytes --] 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 > target, > >> + this points at the file's filename. Otherwise, this is > NULL. */ > >> + const char *from_file; > > > > How about rename this field to "trace_filename", or something > similar? "from_file" is fine as a boolean, but is confusing as a the > name of trace file. > > Fine with me. I'd drop the "trace_" bit as being redundant > with "struct trace_status". > > -- > Pedro Alves > > Hi, Thanks everybody for review. The updated patch is attached. The changes from the previous version are. 1. Renamed "from_file" field to "filename". Use explicit NULL(or 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 <pedro@codesourcery.com> Hafiz Abid Qadeer <abidh@codesourcery.com> 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) <from_file>: 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. [-- Attachment #2: trace_v2.patch --] [-- Type: text/x-patch, Size: 7220 bytes --] 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 + containing the name of the trace file being examined. This field is + optional, and only present when examining a trace file. * 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. +@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 @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; /* We're working with a live target. */ - ts->from_file = 0; + ts->filename = NULL; if (*p++ != '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/tfile.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=\"file\",trace-file=\".*basic.tf\",running=\"0\",stop-reason=\"request\",frames=\"${decimal}\",frames-created=\"${decimal}\",buffer-size=\"${decimal}\",buffer-free=\"${decimal}\",disconnected=\".*\",circular=\".*\",user-name=\"\",notes=\"\",start-time=\".*\",stop-time=\".*\"" \ + "-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) if (status == -1) { - if (ts->from_file) + if (ts->filename != NULL) printf_filtered (_("Using a trace file.\n")); else { @@ -2083,17 +2083,20 @@ trace_status_mi (int on_stop) status = target_get_trace_status (ts); - if (status == -1 && !ts->from_file) + if (status == -1 && ts->filename == NULL) { ui_out_field_string (uiout, "supported", "0"); return; } - if (ts->from_file) + if (ts->filename != NULL) ui_out_field_string (uiout, "supported", "file"); else if (!on_stop) ui_out_field_string (uiout, "supported", "1"); + if (ts->filename != NULL) + ui_out_field_string (uiout, "trace-file", ts->filename); + gdb_assert (ts->running_known); 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 = -1; - if (current_trace_status ()->running && !current_trace_status ()->from_file) + if (current_trace_status ()->running + && current_trace_status ()->filename == NULL) error (_("May not look at trace frames while trace is running.")); if (args == 0 || *args == 0) @@ -2433,7 +2437,8 @@ trace_find_pc_command (char *args, int from_tty) { CORE_ADDR pc; - if (current_trace_status ()->running && !current_trace_status ()->from_file) + if (current_trace_status ()->running + && current_trace_status ()->filename == NULL) error (_("May not look at trace frames while trace is running.")); if (args == 0 || *args == 0) @@ -2451,7 +2456,8 @@ trace_find_tracepoint_command (char *args, int from_tty) int tdp; struct tracepoint *tp; - if (current_trace_status ()->running && !current_trace_status ()->from_file) + if (current_trace_status ()->running + && current_trace_status ()->filename == NULL) error (_("May not look at trace frames while trace is running.")); if (args == 0 || *args == 0) @@ -2490,7 +2496,8 @@ trace_find_line_command (char *args, int from_tty) struct symtab_and_line sal; struct cleanup *old_chain; - if (current_trace_status ()->running && !current_trace_status ()->from_file) + if (current_trace_status ()->running + && current_trace_status ()->filename == NULL) error (_("May not look at trace frames while trace is running.")); if (args == 0 || *args == 0) @@ -2555,7 +2562,8 @@ trace_find_range_command (char *args, int from_tty) static CORE_ADDR start, stop; char *tmp; - if (current_trace_status ()->running && !current_trace_status ()->from_file) + if (current_trace_status ()->running + && current_trace_status ()->filename == NULL) error (_("May not look at trace frames while trace is running.")); if (args == 0 || *args == 0) @@ -2588,7 +2596,8 @@ trace_find_outside_command (char *args, int from_tty) CORE_ADDR start, stop; char *tmp; - if (current_trace_status ()->running && !current_trace_status ()->from_file) + if (current_trace_status ()->running + && current_trace_status ()->filename == NULL) error (_("May not look at trace frames while trace is running.")); if (args == 0 || *args == 0) @@ -3745,8 +3754,8 @@ tfile_open (char *filename, int from_tty) trace_regblock_size = 0; ts = current_trace_status (); - /* We know we're working with a file. */ - ts->from_file = 1; + /* We know we're working with a file. Record its name. */ + ts->filename = trace_filename; /* Set defaults in case there is no status line. */ ts->running_known = 0; ts->stop_reason = 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); } /* 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 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; /* This is true if the value of the running field is known. */ int running_known; ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch] Get trace file name when using 'target tfile' 2013-02-14 15:49 ` Abid, Hafiz @ 2013-02-14 15:57 ` Pedro Alves 2013-02-14 22:02 ` Eli Zaretskii 1 sibling, 0 replies; 9+ messages in thread From: Pedro Alves @ 2013-02-14 15:57 UTC (permalink / raw) To: Abid, Hafiz; +Cc: eliz, Yao Qi, gdb-patches, marc.khouzam On 02/14/2013 03:49 PM, Abid, Hafiz wrote: > Thanks everybody for review. The updated patch is attached. The changes from the previous version are. > > 1. Renamed "from_file" field to "filename". Use explicit NULL(or non-NULL) check against it. > 2. Added a test case for -trace-struct command. > 3. Added NEWS entry. > > How does it look? Thanks. The code bits looks good to me. Eli should review the new NEWS bit. > * remote.c (remote_get_trace_status): Initialize "filename" > field with NULL instead of 0. ^^^^ Something weird with spaces here. -- Pedro Alves ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch] Get trace file name when using 'target tfile' 2013-02-14 15:49 ` Abid, Hafiz 2013-02-14 15:57 ` Pedro Alves @ 2013-02-14 22:02 ` Eli Zaretskii 2013-02-15 10:15 ` Abid, Hafiz 1 sibling, 1 reply; 9+ messages in thread From: Eli Zaretskii @ 2013-02-14 22:02 UTC (permalink / raw) To: Abid, Hafiz; +Cc: palves, yao, gdb-patches, marc.khouzam > Date: Thu, 14 Feb 2013 15:49:30 +0000 > From: "Abid, Hafiz" <hafiz_abid@mentor.com> > CC: Yao Qi <yao@codesourcery.com>, <gdb-patches@sourceware.org>, > <marc.khouzam@ericsson.com> > > 1. Renamed "from_file" field to "filename". Use explicit NULL(or > non-NULL) check against it. > 2. Added a test case for -trace-struct command. > 3. Added NEWS entry. > > How does it look? OK, but: > --- 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 > + containing the name of the trace file being examined. This field is ^^ Two spaces between sentences, please. The documentation parts are OK with that change. Thanks. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Patch] Get trace file name when using 'target tfile' 2013-02-14 22:02 ` Eli Zaretskii @ 2013-02-15 10:15 ` Abid, Hafiz 0 siblings, 0 replies; 9+ messages in thread From: Abid, Hafiz @ 2013-02-15 10:15 UTC (permalink / raw) To: Eli Zaretskii; +Cc: palves, yao, gdb-patches, marc.khouzam On 14/02/13 22:02:13, Eli Zaretskii wrote: > > Date: Thu, 14 Feb 2013 15:49:30 +0000 > > From: "Abid, Hafiz" <hafiz_abid@mentor.com> > > CC: Yao Qi <yao@codesourcery.com>, <gdb-patches@sourceware.org>, > > <marc.khouzam@ericsson.com> > > > > 1. Renamed "from_file" field to "filename". Use explicit NULL(or > > non-NULL) check against it. > > 2. Added a test case for -trace-struct command. > > 3. Added NEWS entry. > > > > How does it look? > > OK, but: > > > --- 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 > > + containing the name of the trace file being examined. This > field is > ^^ > Two spaces between sentences, please. > > The documentation parts are OK with that change. Thanks. > Thanks Eli and Pedro for review. I committed after making the change suggested by Eli. Regards, Abid ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-02-15 10:15 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-02-13 14:38 [Patch] Get trace file name when using 'target tfile' Abid, Hafiz 2013-02-13 16:34 ` Pedro Alves 2013-02-13 17:59 ` Eli Zaretskii 2013-02-14 3:17 ` Yao Qi 2013-02-14 14:34 ` Pedro Alves 2013-02-14 15:49 ` Abid, Hafiz 2013-02-14 15:57 ` Pedro Alves 2013-02-14 22:02 ` Eli Zaretskii 2013-02-15 10:15 ` Abid, Hafiz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox