1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<!-- Copyright (C) 1988-2021 Free Software Foundation, Inc. 4 5Permission is granted to copy, distribute and/or modify this document 6under the terms of the GNU Free Documentation License, Version 1.3 or 7any later version published by the Free Software Foundation; with the 8Invariant Sections being "Free Software" and "Free Software Needs 9Free Documentation", with the Front-Cover Texts being "A GNU Manual," 10and with the Back-Cover Texts as in (a) below. 11 12(a) The FSF's Back-Cover Text is: "You are free to copy and modify 13this GNU Manual. Buying copies from GNU Press supports the FSF in 14developing GNU and promoting software freedom." --> 15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ --> 16<head> 17<title>Debugging with GDB: tfind</title> 18 19<meta name="description" content="Debugging with GDB: tfind"> 20<meta name="keywords" content="Debugging with GDB: tfind"> 21<meta name="resource-type" content="document"> 22<meta name="distribution" content="global"> 23<meta name="Generator" content="makeinfo"> 24<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 25<link href="index.html#Top" rel="start" title="Top"> 26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> 27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> 28<link href="Analyze-Collected-Data.html#Analyze-Collected-Data" rel="up" title="Analyze Collected Data"> 29<link href="tdump.html#tdump" rel="next" title="tdump"> 30<link href="Analyze-Collected-Data.html#Analyze-Collected-Data" rel="previous" title="Analyze Collected Data"> 31<style type="text/css"> 32<!-- 33a.summary-letter {text-decoration: none} 34blockquote.smallquotation {font-size: smaller} 35div.display {margin-left: 3.2em} 36div.example {margin-left: 3.2em} 37div.indentedblock {margin-left: 3.2em} 38div.lisp {margin-left: 3.2em} 39div.smalldisplay {margin-left: 3.2em} 40div.smallexample {margin-left: 3.2em} 41div.smallindentedblock {margin-left: 3.2em; font-size: smaller} 42div.smalllisp {margin-left: 3.2em} 43kbd {font-style:oblique} 44pre.display {font-family: inherit} 45pre.format {font-family: inherit} 46pre.menu-comment {font-family: serif} 47pre.menu-preformatted {font-family: serif} 48pre.smalldisplay {font-family: inherit; font-size: smaller} 49pre.smallexample {font-size: smaller} 50pre.smallformat {font-family: inherit; font-size: smaller} 51pre.smalllisp {font-size: smaller} 52span.nocodebreak {white-space:nowrap} 53span.nolinebreak {white-space:nowrap} 54span.roman {font-family:serif; font-weight:normal} 55span.sansserif {font-family:sans-serif; font-weight:normal} 56ul.no-bullet {list-style: none} 57--> 58</style> 59 60 61</head> 62 63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> 64<a name="tfind"></a> 65<div class="header"> 66<p> 67Next: <a href="tdump.html#tdump" accesskey="n" rel="next">tdump</a>, Up: <a href="Analyze-Collected-Data.html#Analyze-Collected-Data" accesskey="u" rel="up">Analyze Collected Data</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> 68</div> 69<hr> 70<a name="tfind-n"></a> 71<h4 class="subsection">13.2.1 <code>tfind <var>n</var></code></h4> 72 73<a name="index-tfind"></a> 74<a name="index-select-trace-snapshot"></a> 75<a name="index-find-trace-snapshot"></a> 76<p>The basic command for selecting a trace snapshot from the buffer is 77<code>tfind <var>n</var></code>, which finds trace snapshot number <var>n</var>, 78counting from zero. If no argument <var>n</var> is given, the next 79snapshot is selected. 80</p> 81<p>Here are the various forms of using the <code>tfind</code> command. 82</p> 83<dl compact="compact"> 84<dt><code>tfind start</code></dt> 85<dd><p>Find the first snapshot in the buffer. This is a synonym for 86<code>tfind 0</code> (since 0 is the number of the first snapshot). 87</p> 88</dd> 89<dt><code>tfind none</code></dt> 90<dd><p>Stop debugging trace snapshots, resume <em>live</em> debugging. 91</p> 92</dd> 93<dt><code>tfind end</code></dt> 94<dd><p>Same as ‘<samp>tfind none</samp>’. 95</p> 96</dd> 97<dt><code>tfind</code></dt> 98<dd><p>No argument means find the next trace snapshot or find the first 99one if no trace snapshot is selected. 100</p> 101</dd> 102<dt><code>tfind -</code></dt> 103<dd><p>Find the previous trace snapshot before the current one. This permits 104retracing earlier steps. 105</p> 106</dd> 107<dt><code>tfind tracepoint <var>num</var></code></dt> 108<dd><p>Find the next snapshot associated with tracepoint <var>num</var>. Search 109proceeds forward from the last examined trace snapshot. If no 110argument <var>num</var> is given, it means find the next snapshot collected 111for the same tracepoint as the current snapshot. 112</p> 113</dd> 114<dt><code>tfind pc <var>addr</var></code></dt> 115<dd><p>Find the next snapshot associated with the value <var>addr</var> of the 116program counter. Search proceeds forward from the last examined trace 117snapshot. If no argument <var>addr</var> is given, it means find the next 118snapshot with the same value of PC as the current snapshot. 119</p> 120</dd> 121<dt><code>tfind outside <var>addr1</var>, <var>addr2</var></code></dt> 122<dd><p>Find the next snapshot whose PC is outside the given range of 123addresses (exclusive). 124</p> 125</dd> 126<dt><code>tfind range <var>addr1</var>, <var>addr2</var></code></dt> 127<dd><p>Find the next snapshot whose PC is between <var>addr1</var> and 128<var>addr2</var> (inclusive). 129</p> 130</dd> 131<dt><code>tfind line <span class="roman">[</span><var>file</var>:<span class="roman">]</span><var>n</var></code></dt> 132<dd><p>Find the next snapshot associated with the source line <var>n</var>. If 133the optional argument <var>file</var> is given, refer to line <var>n</var> in 134that source file. Search proceeds forward from the last examined 135trace snapshot. If no argument <var>n</var> is given, it means find the 136next line other than the one currently being examined; thus saying 137<code>tfind line</code> repeatedly can appear to have the same effect as 138stepping from line to line in a <em>live</em> debugging session. 139</p></dd> 140</dl> 141 142<p>The default arguments for the <code>tfind</code> commands are specifically 143designed to make it easy to scan through the trace buffer. For 144instance, <code>tfind</code> with no argument selects the next trace 145snapshot, and <code>tfind -</code> with no argument selects the previous 146trace snapshot. So, by giving one <code>tfind</code> command, and then 147simply hitting <tt class="key">RET</tt> repeatedly you can examine all the trace 148snapshots in order. Or, by saying <code>tfind -</code> and then hitting 149<tt class="key">RET</tt> repeatedly you can examine the snapshots in reverse order. 150The <code>tfind line</code> command with no argument selects the snapshot 151for the next source line executed. The <code>tfind pc</code> command with 152no argument selects the next snapshot with the same program counter 153(PC) as the current frame. The <code>tfind tracepoint</code> command with 154no argument selects the next trace snapshot collected by the same 155tracepoint as the current one. 156</p> 157<p>In addition to letting you scan through the trace buffer manually, 158these commands make it easy to construct <small>GDB</small> scripts that 159scan through the trace buffer and print out whatever collected data 160you are interested in. Thus, if we want to examine the PC, FP, and SP 161registers from each trace frame in the buffer, we can say this: 162</p> 163<div class="smallexample"> 164<pre class="smallexample">(gdb) <b>tfind start</b> 165(gdb) <b>while ($trace_frame != -1)</b> 166> printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \ 167 $trace_frame, $pc, $sp, $fp 168> tfind 169> end 170 171Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44 172Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44 173Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44 174Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44 175Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44 176Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44 177Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44 178Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44 179Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44 180Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44 181Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14 182</pre></div> 183 184<p>Or, if we want to examine the variable <code>X</code> at each source line in 185the buffer: 186</p> 187<div class="smallexample"> 188<pre class="smallexample">(gdb) <b>tfind start</b> 189(gdb) <b>while ($trace_frame != -1)</b> 190> printf "Frame %d, X == %d\n", $trace_frame, X 191> tfind line 192> end 193 194Frame 0, X = 1 195Frame 7, X = 2 196Frame 13, X = 255 197</pre></div> 198 199<hr> 200<div class="header"> 201<p> 202Next: <a href="tdump.html#tdump" accesskey="n" rel="next">tdump</a>, Up: <a href="Analyze-Collected-Data.html#Analyze-Collected-Data" accesskey="u" rel="up">Analyze Collected Data</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> 203</div> 204 205 206 207</body> 208</html> 209