This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Fix loading trace files when trace state variables were collected
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 11 Feb 2010 21:04:16 +0000
- Subject: Fix loading trace files when trace state variables were collected
I've applied the patch below.
If you collect a trace state variable in a tracepoint, and
dump a trace file, GDB can't load it back properly.
(gdb) target tfile tfile.txt
Tracepoint 1 at 0x80484d1: file loop.cc, line 7.
$trace_timestamp is not a trace state variable; GDB agent expressions cannot use convenience variables.
(gdb) tstatus
Using a trace file.
Trace stopped by a tstop command.
Buffer contains 5 trace frames (of 5 created total).
Trace buffer has 5242785 bytes of 5242880 bytes free.
Not looking at any trace frame.
(gdb) tfind 0
Unknown block type '0' (0x30) in trace frame
All is broken from here on.
(gdb) target tfile tfile.txt
Tracepoint 1 at 0x80484d1: file loop.cc, line 7.
$trace_timestamp is not a trace state variable; GDB agent expressions cannot use convenience variables.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is an error thrown from within tfile_open, and that escapes
out, before the trace_frames_offset global is set properly, leaving
the tfile target pushed, but broken.
(gdb) tstatus
Using a trace file.
Trace stopped by a tstop command.
Buffer contains 5 trace frames (of 5 created total).
Trace buffer has 5242785 bytes of 5242880 bytes free.
Not looking at any trace frame.
(gdb) tfind 0
Unknown block type '0' (0x30) in trace frame
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
hence this is reading from the wrong offset.
(gdb) tdump
No known tracepoint matches 'current' tracepoint #21631.
The fix is to merge TSVs before tracepoints, so to
avoid that error in the first place. remote.c does the
same thing for the same reason.
Of course, any thrown error will still trigger the
same problem again. We may want to make tfile_open a bit
smarter and more robust at some point.
--
Pedro Alves
2010-02-11 Pedro Alves <pedro@codesourcery.com>
* tracepoint.c (tfile_open): Remove spurious discard_cleanups.
Merge uploaded TSVs before merging uploaded tracepoints.
---
gdb/tracepoint.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Index: src/gdb/tracepoint.c
===================================================================
--- src.orig/gdb/tracepoint.c 2010-02-11 17:47:30.000000000 +0000
+++ src/gdb/tracepoint.c 2010-02-11 20:53:05.000000000 +0000
@@ -2824,7 +2824,6 @@ tfile_open (char *filename, int from_tty
unpush_target (&tfile_ops);
push_target (&tfile_ops);
- discard_cleanups (old_chain);
trace_filename = xstrdup (filename);
trace_fd = scratch_chan;
@@ -2881,10 +2880,12 @@ tfile_open (char *filename, int from_tty
/* Add the file's tracepoints and variables into the current mix. */
- merge_uploaded_tracepoints (&uploaded_tps);
-
+ /* Get trace state variables first, they may be checked when parsing
+ uploaded commands. */
merge_uploaded_trace_state_variables (&uploaded_tsvs);
+ merge_uploaded_tracepoints (&uploaded_tps);
+
/* Record the starting offset of the binary trace data. */
trace_frames_offset = bytes;