tfind.html 8.9 KB

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