blob: 3d5c239baa6c6a596b238a434187ee2429b2ce65 [file] [log] [blame]
<html lang="en">
<head>
<title>tfind - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Analyze-Collected-Data.html#Analyze-Collected-Data" title="Analyze Collected Data">
<link rel="next" href="tdump.html#tdump" title="tdump">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software'' and ``Free Software Needs
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom.''
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="tfind"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="tdump.html#tdump">tdump</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Analyze-Collected-Data.html#Analyze-Collected-Data">Analyze Collected Data</a>
<hr>
</div>
<h4 class="subsection">13.2.1 <code>tfind </code><var>n</var></h4>
<p><a name="index-tfind-927"></a><a name="index-select-trace-snapshot-928"></a><a name="index-find-trace-snapshot-929"></a>The basic command for selecting a trace snapshot from the buffer is
<code>tfind </code><var>n</var>, which finds trace snapshot number <var>n</var>,
counting from zero. If no argument <var>n</var> is given, the next
snapshot is selected.
<p>Here are the various forms of using the <code>tfind</code> command.
<dl>
<dt><code>tfind start</code><dd>Find the first snapshot in the buffer. This is a synonym for
<code>tfind 0</code> (since 0 is the number of the first snapshot).
<br><dt><code>tfind none</code><dd>Stop debugging trace snapshots, resume <em>live</em> debugging.
<br><dt><code>tfind end</code><dd>Same as &lsquo;<samp><span class="samp">tfind none</span></samp>&rsquo;.
<br><dt><code>tfind</code><dd>No argument means find the next trace snapshot or find the first
one if no trace snapshot is selected.
<br><dt><code>tfind -</code><dd>Find the previous trace snapshot before the current one. This permits
retracing earlier steps.
<br><dt><code>tfind tracepoint </code><var>num</var><dd>Find the next snapshot associated with tracepoint <var>num</var>. Search
proceeds forward from the last examined trace snapshot. If no
argument <var>num</var> is given, it means find the next snapshot collected
for the same tracepoint as the current snapshot.
<br><dt><code>tfind pc </code><var>addr</var><dd>Find the next snapshot associated with the value <var>addr</var> of the
program counter. Search proceeds forward from the last examined trace
snapshot. If no argument <var>addr</var> is given, it means find the next
snapshot with the same value of PC as the current snapshot.
<br><dt><code>tfind outside </code><var>addr1</var><code>, </code><var>addr2</var><dd>Find the next snapshot whose PC is outside the given range of
addresses (exclusive).
<br><dt><code>tfind range </code><var>addr1</var><code>, </code><var>addr2</var><dd>Find the next snapshot whose PC is between <var>addr1</var> and
<var>addr2</var> (inclusive).
<br><dt><code>tfind line </code><span class="roman">[</span><var>file</var><code>:</code><span class="roman">]</span><var>n</var><dd>Find the next snapshot associated with the source line <var>n</var>. If
the optional argument <var>file</var> is given, refer to line <var>n</var> in
that source file. Search proceeds forward from the last examined
trace snapshot. If no argument <var>n</var> is given, it means find the
next line other than the one currently being examined; thus saying
<code>tfind line</code> repeatedly can appear to have the same effect as
stepping from line to line in a <em>live</em> debugging session.
</dl>
<p>The default arguments for the <code>tfind</code> commands are specifically
designed to make it easy to scan through the trace buffer. For
instance, <code>tfind</code> with no argument selects the next trace
snapshot, and <code>tfind -</code> with no argument selects the previous
trace snapshot. So, by giving one <code>tfind</code> command, and then
simply hitting &lt;RET&gt; repeatedly you can examine all the trace
snapshots in order. Or, by saying <code>tfind -</code> and then hitting
&lt;RET&gt; repeatedly you can examine the snapshots in reverse order.
The <code>tfind line</code> command with no argument selects the snapshot
for the next source line executed. The <code>tfind pc</code> command with
no argument selects the next snapshot with the same program counter
(PC) as the current frame. The <code>tfind tracepoint</code> command with
no argument selects the next trace snapshot collected by the same
tracepoint as the current one.
<p>In addition to letting you scan through the trace buffer manually,
these commands make it easy to construct <span class="sc">gdb</span> 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:
<pre class="smallexample"> (gdb) <b>tfind start</b>
(gdb) <b>while ($trace_frame != -1)</b>
&gt; printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \
$trace_frame, $pc, $sp, $fp
&gt; tfind
&gt; end
Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44
Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44
Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44
Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44
Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44
Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44
Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44
Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44
Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44
Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44
Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14
</pre>
<p>Or, if we want to examine the variable <code>X</code> at each source line in
the buffer:
<pre class="smallexample"> (gdb) <b>tfind start</b>
(gdb) <b>while ($trace_frame != -1)</b>
&gt; printf "Frame %d, X == %d\n", $trace_frame, X
&gt; tfind line
&gt; end
Frame 0, X = 1
Frame 7, X = 2
Frame 13, X = 255
</pre>
</body></html>