aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2010-01-15 22:37:20 +0000
committerStan Shebs <shebs@codesourcery.com>2010-01-15 22:37:20 +0000
commit00bf0b8586eece6ef4e508343e9896d309c2004e (patch)
tree53202654ea4c6e5c41252c0d74790e03becc6dc8 /gdb/doc
parent6ec12636a713f947bf37b8f355a0e53c94f4a8e9 (diff)
downloadgdb-00bf0b8586eece6ef4e508343e9896d309c2004e.zip
gdb-00bf0b8586eece6ef4e508343e9896d309c2004e.tar.gz
gdb-00bf0b8586eece6ef4e508343e9896d309c2004e.tar.bz2
Add trace file support.
* tracepoint.h (enum trace_stop_reason): New enum. (struct trace_status): New struct. (parse_trace_status): Declare. (struct uploaded_tp): Move here from remote.c, add fields for actions. (struct uploaded_tsv): New struct. * tracepoint.c (tfile_ops): New target vector. (trace_fd): New global. (tfile_open): New function. (tfile_close): New function. (tfile_files_info): New function. (tfile_get_trace_status): New function. (tfile_get_traceframe_address): New function. (tfile_trace_find): New function. (tfile_fetch_registers): New function. (tfile_xfer_partial): New function. (tfile_get_trace_state_variable_value): New function. (init_tfile_ops): New function. (_initialize_tracepoint): Call it, add tfile target. (trace_status): New global. (current_trace_status): New function. (trace_running_p): Remove, change all users to get from current_trace_status()->running. (get_trace_status): Remove. (trace_status_command): Call target_get_trace_status directly, report more detail including tracing stop reasons. (trace_find_command): Always allow tfind on a file. (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. (trace_frames_offset, cur_offset): Declare as off_t. (trace_regblock_size): Rename from reg_size, update users. (parse_trace_status): New function. (tfile_interp_line): New function. (disconnect_or_stop_tracing): Ensure current trace status before asking what to do. (stop_reason_names): New global. (trace_save_command): New command. (get_uploaded_tp): Move here from remote.c. (find_matching_tracepoint): Ditto. (merge_uploaded_tracepoints): New function. (parse_trace_status): Use stop_reason_names. (_initialize_tracepoint): Define tsave command. * target.h (target_ops): New fields to_save_trace_data, to_upload_tracepoints, to_upload_trace_state_variables, to_get_raw_trace_data, change to_get_trace_status to take a pointer to a status struct. (target_save_trace_data): New macro. (target_upload_tracepoints): New macro. (target_upload_trace_state_variables): New macro. (target_get_raw_trace_data): New macro. * target.c (update_current_target): Add new methods, change signature of to_get_trace_status. * remote.c (hex2bin): Make globally visible. (bin2hex): Ditto. (remote_download_trace_state_variable): Download name also. (remote_get_trace_status): Update parameter, use parse_trace_status. (remote_save_trace_data): New function. (remote_upload_tracepoints): New function. (remote_upload_trace_state_variables): New function. (remote_get_raw_trace_data): New function. (remote_start_remote): Use them. (_initialize_remote_ops): Add operations. * ax-gdb.c: Include breakpoint.h. * breakpoint.c (create_tracepoint_from_upload): Use break_command_really, return tracepoint, warn about unimplemented parts. * NEWS: Mention trace file addition. * gdb.texinfo (Trace Files): New section. (Tracepoint Packets): Document QTSave and qTBuffer. (Trace File Format): New appendix. * generic/gdbtk-bp.c (gdb_trace_status): Use current_trace_status. * gdb.trace/tfile.c: New file. * gdb.trace/tfile.exp: New file.
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/ChangeLog6
-rw-r--r--gdb/doc/gdb.texinfo125
2 files changed, 129 insertions, 2 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 8b5d162..b07d720 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-15 Stan Shebs <stan@codesourcery.com>
+
+ * gdb.texinfo (Trace Files): New section.
+ (Tracepoint Packets): Document QTSave and qTBuffer.
+ (Trace File Format): New appendix.
+
2010-01-13 Phil Muldoon <pmuldoon@redhat.com>
* gdb.texinfo (Values From Inferior): Document lazy_string value
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 253e251..7cf1bb4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -174,6 +174,7 @@ software in general. We will miss him.
@value{GDBN}
* Operating System Information:: Getting additional information from
the operating system
+* Trace File Format:: GDB trace file format
* Copying:: GNU General Public License says
how you can copy and share GDB
* GNU Free Documentation License:: The license for this documentation
@@ -9292,12 +9293,17 @@ support tracepoints as of this writing. The format of the remote
packets used to implement tracepoints are described in @ref{Tracepoint
Packets}.
+It is also possible to get trace data from a file, in a manner reminiscent
+of corefiles; you specify the filename, and use @code{tfind} to search
+through the file. @xref{Trace Files}, for more details.
+
This chapter describes the tracepoint commands and features.
@menu
* Set Tracepoints::
* Analyze Collected Data::
* Tracepoint Variables::
+* Trace Files::
@end menu
@node Set Tracepoints
@@ -10081,6 +10087,41 @@ which are managed by the target.
> end
@end smallexample
+@node Trace Files
+@section Using Trace Files
+@cindex trace files
+
+In some situations, the target running a trace experiment may no
+longer be available; perhaps it crashed, or the hardware was needed
+for a different activity. To handle these cases, you can arrange to
+dump the trace data into a file, and later use that file as a source
+of trace data, via the @code{target tfile} command.
+
+@table @code
+
+@kindex tsave
+@item tsave [ -r ] @var{filename}
+Save the trace data to @var{filename}. By default, this command
+assumes that @var{filename} refers to the host filesystem, so if
+necessary @value{GDBN} will copy raw trace data up from the target and
+then save it. If the target supports it, you can also supply the
+optional argument @code{-r} (``remote'') to direct the target to save
+the data directly into @var{filename} in its own filesystem, which may be
+more efficient if the trace buffer is very large. (Note, however, that
+@code{target tfile} can only read from files accessible to the host.)
+
+@kindex target tfile
+@kindex tfile
+@item target tfile @var{filename}
+Use the file named @var{filename} as a source of trace data. Commands
+that examine data work as they do with a live target, but it is not
+possible to run any new trace experiments. @code{tstatus} will report
+the state of the trace run at the moment the data was saved, as well
+as the current trace frame you are examining. @var{filename} must be
+on a filesystem accessible to the host.
+
+@end table
+
@node Overlays
@chapter Debugging Programs That Use Overlays
@cindex overlays
@@ -29964,10 +30005,12 @@ encoded). @value{GDBN} will continue to supply the values of symbols
(if available), until the target ceases to request them.
@end table
+@item qTBuffer
@item QTDisconnected
@itemx QTDP
@itemx QTDV
-@itemx QTfP
+@itemx qTfP
+@itemx qTfV
@itemx QTFrame
@xref{Tracepoint Packets}.
@@ -29996,7 +30039,9 @@ the command by a @samp{,}, not a @samp{:}, contrary to the naming
conventions above. Please don't use this packet as a model for new
packets.)
-@item QTsP
+@item QTSave
+@item qTsP
+@item qTsV
@itemx QTStart
@itemx QTStop
@itemx QTinit
@@ -30455,6 +30500,29 @@ of data, and multiple @code{qTsP} to get additional pieces. Replies
to these packets generally take the form of the @code{QTDP} packets
that define tracepoints. (FIXME add detailed syntax)
+@item qTfV
+@itemx qTsV
+These packets request data about trace state variables that are on the
+target. @value{GDBN} sends @code{qTfV} to get the first vari of data,
+and multiple @code{qTsV} to get additional variables. Replies to
+these packets follow the syntax of the @code{QTDV} packets that define
+trace state variables.
+
+@item QTSave:@var{filename}
+This packet directs the target to save trace data to the file name
+@var{filename} in the target's filesystem. @var{filename} is encoded
+as a hex string; the interpretation of the file name (relative vs
+absolute, wild cards, etc) is up to the target.
+
+@item qTBuffer:@var{offset},@var{len}
+Return up to @var{len} bytes of the current contents of trace buffer,
+starting at @var{offset}. The trace buffer is treated as if it were
+a contiguous collection of traceframes, as per the trace file format.
+The reply consists as many hex-encoded bytes as the target can deliver
+in a packet; it is not an error to return fewer than were asked for.
+A reply consisting of just @code{l} indicates that no bytes are
+available.
+
@end table
@node Host I/O Packets
@@ -32146,6 +32214,59 @@ element is interpreted as human-readable auxilliary information.
@include agentexpr.texi
+@node Trace File Format
+@appendix Trace File Format
+@cindex trace file format
+
+The trace file comes in three parts: a header, a textual description
+section, and a trace frame section with binary data.
+
+The header has the form @code{\x7fTRACE0\n}. The first byte is
+@code{0x7f} so as to indicate that the file contains binary data,
+while the @code{0} is a version number that may have different values
+in the future.
+
+The description section consists of multiple lines of @sc{ascii} text
+separated by newline characters (@code{0xa}). The lines may include a
+variety of optional descriptive or context-setting information, such
+as tracepoint definitions or register set size. @value{GDBN} will
+ignore any line that it does not recognize. An empty line marks the end
+of this section.
+
+@c FIXME add some specific types of data
+
+The trace frame section consists of a number of consecutive frames.
+Each frame begins with a two-byte tracepoint number, followed by a
+four-byte size giving the amount of data in the frame. The data in
+the frame consists of a number of blocks, each introduced by a
+character indicating its type (at least register, memory, and trace
+state variable). The data in this section is raw binary, not a
+hexadecimal or other encoding; its endianness matches the target's
+endianness.
+
+@c FIXME bi-arch may require endianness/arch info in description section
+
+@table @code
+@item R @var{bytes}
+Register block. The number and ordering of bytes matches that of a
+@code{g} packet in the remote protocol. Note that these are the
+actual bytes, in target order and @value{GDBN} register order, not a
+hexadecimal encoding.
+
+@item M @var{address} @var{length} @var{bytes}...
+Memory block. This is a contiguous block of memory, at the 8-byte
+address @var{address}, with a 2-byte length @var{length}, followed by
+@var{length} bytes.
+
+@item V @var{number} @var{value}
+Trace state variable block. This records the 8-byte signed value
+@var{value} of trace state variable numbered @var{number}.
+
+@end table
+
+Future enhancements of the trace file format may include additional types
+of blocks.
+
@node Target Descriptions
@appendix Target Descriptions
@cindex target descriptions