After the tracepoint experiment ends, you use gdb commands
for examining the trace data. The basic idea is that each tracepoint
collects a trace snapshot every time it is hit and another
snapshot every time it single-steps. All these snapshots are
consecutively numbered from zero and go into a buffer, and you can
examine them later. The way you examine them is to focus on a
specific trace snapshot. When the remote stub is focused on a trace
snapshot, it will respond to all gdb requests for memory and
registers by reading from the buffer which belongs to that snapshot,
rather than from real memory or registers of the program being
debugged. This means that all gdb commands
(print, info registers, backtrace, etc.) will
behave as if we were currently debugging the program state as it was
when the tracepoint occurred. Any requests for data that are not in
the buffer will fail.
12.2.1. tfind n
The basic command for selecting a trace snapshot from the buffer is
tfind n, which finds trace snapshot number n,
counting from zero. If no argument n is given, the next
snapshot is selected.
Here are the various forms of using the tfind command.
Find the first snapshot in the buffer. This is a synonym for
tfind 0 (since 0 is the number of the first snapshot).
Stop debugging trace snapshots, resume live debugging.
Same as tfind none.
No argument means find the next trace snapshot.
Find the previous trace snapshot before the current one. This permits
retracing earlier steps.
tfind tracepoint num
Find the next snapshot associated with tracepoint num. Search
proceeds forward from the last examined trace snapshot. If no
argument num is given, it means find the next snapshot collected
for the same tracepoint as the current snapshot.
tfind pc addr
Find the next snapshot associated with the value addr of the
program counter. Search proceeds forward from the last examined trace
snapshot. If no argument addr is given, it means find the next
snapshot with the same value of PC as the current snapshot.
tfind outside addr1, addr2
Find the next snapshot whose PC is outside the given range of
tfind range addr1, addr2
Find the next snapshot whose PC is between addr1 and
tfind line [file:]n
Find the next snapshot associated with the source line n. If
the optional argument file is given, refer to line n in
that source file. Search proceeds forward from the last examined
trace snapshot. If no argument n is given, it means find the
next line other than the one currently being examined; thus saying
tfind line repeatedly can appear to have the same effect as
stepping from line to line in a live debugging session.
The default arguments for the tfind commands are specifically
designed to make it easy to scan through the trace buffer. For
instance, tfind with no argument selects the next trace
snapshot, and tfind - with no argument selects the previous
trace snapshot. So, by giving one tfind command, and then
simply hitting [RET] repeatedly you can examine all the trace
snapshots in order. Or, by saying tfind - and then hitting
[RET] repeatedly you can examine the snapshots in reverse order.
The tfind line command with no argument selects the snapshot
for the next source line executed. The tfind pc command with
no argument selects the next snapshot with the same program counter
(PC) as the current frame. The tfind tracepoint command with
no argument selects the next trace snapshot collected by the same
tracepoint as the current one.
In addition to letting you scan through the trace buffer manually,
these commands make it easy to construct gdb scripts that
scan through the trace buffer and print out whatever collected data
you are interested in. Thus, if we want to examine the PC, FP, and SP
registers from each trace frame in the buffer, we can say this:
This command saves all current tracepoint definitions together with
their actions and passcounts, into a file filename
suitable for use in a later debugging session. To read the saved
tracepoint definitions, use the source command (refer to Section 22.3 Command files).