Starting-and-Stopping-Trace-Experiments.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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-2020 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.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Starting and Stopping Trace Experiments</title>
  16. <meta name="description" content="Debugging with GDB: Starting and Stopping Trace Experiments">
  17. <meta name="keywords" content="Debugging with GDB: Starting and Stopping Trace Experiments">
  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="Set-Tracepoints.html#Set-Tracepoints" rel="up" title="Set Tracepoints">
  26. <link href="Tracepoint-Restrictions.html#Tracepoint-Restrictions" rel="next" title="Tracepoint Restrictions">
  27. <link href="Listing-Static-Tracepoint-Markers.html#Listing-Static-Tracepoint-Markers" rel="previous" title="Listing Static Tracepoint Markers">
  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="Starting-and-Stopping-Trace-Experiments"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Tracepoint-Restrictions.html#Tracepoint-Restrictions" accesskey="n" rel="next">Tracepoint Restrictions</a>, Previous: <a href="Listing-Static-Tracepoint-Markers.html#Listing-Static-Tracepoint-Markers" accesskey="p" rel="previous">Listing Static Tracepoint Markers</a>, Up: <a href="Set-Tracepoints.html#Set-Tracepoints" accesskey="u" rel="up">Set Tracepoints</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="Starting-and-Stopping-Trace-Experiments-1"></a>
  65. <h4 class="subsection">13.1.9 Starting and Stopping Trace Experiments</h4>
  66. <dl compact="compact">
  67. <dd><a name="index-tstart-_005b-notes-_005d"></a>
  68. <a name="index-start-a-new-trace-experiment"></a>
  69. <a name="index-collected-data-discarded"></a>
  70. </dd>
  71. <dt><code>tstart</code></dt>
  72. <dd><p>This command starts the trace experiment, and begins collecting data.
  73. It has the side effect of discarding all the data collected in the
  74. trace buffer during the previous trace experiment. If any arguments
  75. are supplied, they are taken as a note and stored with the trace
  76. experiment&rsquo;s state. The notes may be arbitrary text, and are
  77. especially useful with disconnected tracing in a multi-user context;
  78. the notes can explain what the trace is doing, supply user contact
  79. information, and so forth.
  80. </p>
  81. <a name="index-tstop-_005b-notes-_005d"></a>
  82. <a name="index-stop-a-running-trace-experiment"></a>
  83. </dd>
  84. <dt><code>tstop</code></dt>
  85. <dd><p>This command stops the trace experiment. If any arguments are
  86. supplied, they are recorded with the experiment as a note. This is
  87. useful if you are stopping a trace started by someone else, for
  88. instance if the trace is interfering with the system&rsquo;s behavior and
  89. needs to be stopped quickly.
  90. </p>
  91. <p><strong>Note</strong>: a trace experiment and data collection may stop
  92. automatically if any tracepoint&rsquo;s passcount is reached
  93. (see <a href="Tracepoint-Passcounts.html#Tracepoint-Passcounts">Tracepoint Passcounts</a>), or if the trace buffer becomes full.
  94. </p>
  95. <a name="index-tstatus"></a>
  96. <a name="index-status-of-trace-data-collection"></a>
  97. <a name="index-trace-experiment_002c-status-of"></a>
  98. </dd>
  99. <dt><code>tstatus</code></dt>
  100. <dd><p>This command displays the status of the current trace data
  101. collection.
  102. </p></dd>
  103. </dl>
  104. <p>Here is an example of the commands we described so far:
  105. </p>
  106. <div class="smallexample">
  107. <pre class="smallexample">(gdb) <b>trace gdb_c_test</b>
  108. (gdb) <b>actions</b>
  109. Enter actions for tracepoint #1, one per line.
  110. &gt; collect $regs,$locals,$args
  111. &gt; while-stepping 11
  112. &gt; collect $regs
  113. &gt; end
  114. &gt; end
  115. (gdb) <b>tstart</b>
  116. [time passes &hellip;]
  117. (gdb) <b>tstop</b>
  118. </pre></div>
  119. <a name="disconnected-tracing"></a><a name="index-disconnected-tracing"></a>
  120. <p>You can choose to continue running the trace experiment even if
  121. <small>GDB</small> disconnects from the target, voluntarily or
  122. involuntarily. For commands such as <code>detach</code>, the debugger will
  123. ask what you want to do with the trace. But for unexpected
  124. terminations (<small>GDB</small> crash, network outage), it would be
  125. unfortunate to lose hard-won trace data, so the variable
  126. <code>disconnected-tracing</code> lets you decide whether the trace should
  127. continue running without <small>GDB</small>.
  128. </p>
  129. <dl compact="compact">
  130. <dt><code>set disconnected-tracing on</code></dt>
  131. <dt><code>set disconnected-tracing off</code></dt>
  132. <dd><a name="index-set-disconnected_002dtracing"></a>
  133. <p>Choose whether a tracing run should continue to run if <small>GDB</small>
  134. has disconnected from the target. Note that <code>detach</code> or
  135. <code>quit</code> will ask you directly what to do about a running trace no
  136. matter what this variable&rsquo;s setting, so the variable is mainly useful
  137. for handling unexpected situations, such as loss of the network.
  138. </p>
  139. </dd>
  140. <dt><code>show disconnected-tracing</code></dt>
  141. <dd><a name="index-show-disconnected_002dtracing"></a>
  142. <p>Show the current choice for disconnected tracing.
  143. </p>
  144. </dd>
  145. </dl>
  146. <p>When you reconnect to the target, the trace experiment may or may not
  147. still be running; it might have filled the trace buffer in the
  148. meantime, or stopped for one of the other reasons. If it is running,
  149. it will continue after reconnection.
  150. </p>
  151. <p>Upon reconnection, the target will upload information about the
  152. tracepoints in effect. <small>GDB</small> will then compare that
  153. information to the set of tracepoints currently defined, and attempt
  154. to match them up, allowing for the possibility that the numbers may
  155. have changed due to creation and deletion in the meantime. If one of
  156. the target&rsquo;s tracepoints does not match any in <small>GDB</small>, the
  157. debugger will create a new tracepoint, so that you have a number with
  158. which to specify that tracepoint. This matching-up process is
  159. necessarily heuristic, and it may result in useless tracepoints being
  160. created; you may simply delete them if they are of no use.
  161. </p>
  162. <a name="index-circular-trace-buffer"></a>
  163. <p>If your target agent supports a <em>circular trace buffer</em>, then you
  164. can run a trace experiment indefinitely without filling the trace
  165. buffer; when space runs out, the agent deletes already-collected trace
  166. frames, oldest first, until there is enough room to continue
  167. collecting. This is especially useful if your tracepoints are being
  168. hit too often, and your trace gets terminated prematurely because the
  169. buffer is full. To ask for a circular trace buffer, simply set
  170. &lsquo;<samp>circular-trace-buffer</samp>&rsquo; to on. You can set this at any time,
  171. including during tracing; if the agent can do it, it will change
  172. buffer handling on the fly, otherwise it will not take effect until
  173. the next run.
  174. </p>
  175. <dl compact="compact">
  176. <dt><code>set circular-trace-buffer on</code></dt>
  177. <dt><code>set circular-trace-buffer off</code></dt>
  178. <dd><a name="index-set-circular_002dtrace_002dbuffer"></a>
  179. <p>Choose whether a tracing run should use a linear or circular buffer
  180. for trace data. A linear buffer will not lose any trace data, but may
  181. fill up prematurely, while a circular buffer will discard old trace
  182. data, but it will have always room for the latest tracepoint hits.
  183. </p>
  184. </dd>
  185. <dt><code>show circular-trace-buffer</code></dt>
  186. <dd><a name="index-show-circular_002dtrace_002dbuffer"></a>
  187. <p>Show the current choice for the trace buffer. Note that this may not
  188. match the agent&rsquo;s current buffer handling, nor is it guaranteed to
  189. match the setting that might have been in effect during a past run,
  190. for instance if you are looking at frames from a trace file.
  191. </p>
  192. </dd>
  193. </dl>
  194. <dl compact="compact">
  195. <dt><code>set trace-buffer-size <var>n</var></code></dt>
  196. <dt><code>set trace-buffer-size unlimited</code></dt>
  197. <dd><a name="index-set-trace_002dbuffer_002dsize"></a>
  198. <p>Request that the target use a trace buffer of <var>n</var> bytes. Not all
  199. targets will honor the request; they may have a compiled-in size for
  200. the trace buffer, or some other limitation. Set to a value of
  201. <code>unlimited</code> or <code>-1</code> to let the target use whatever size it
  202. likes. This is also the default.
  203. </p>
  204. </dd>
  205. <dt><code>show trace-buffer-size</code></dt>
  206. <dd><a name="index-show-trace_002dbuffer_002dsize"></a>
  207. <p>Show the current requested size for the trace buffer. Note that this
  208. will only match the actual size if the target supports size-setting,
  209. and was able to handle the requested size. For instance, if the
  210. target can only change buffer size between runs, this variable will
  211. not reflect the change until the next run starts. Use <code>tstatus</code>
  212. to get a report of the actual buffer size.
  213. </p></dd>
  214. </dl>
  215. <dl compact="compact">
  216. <dt><code>set trace-user <var>text</var></code></dt>
  217. <dd><a name="index-set-trace_002duser"></a>
  218. </dd>
  219. <dt><code>show trace-user</code></dt>
  220. <dd><a name="index-show-trace_002duser"></a>
  221. </dd>
  222. <dt><code>set trace-notes <var>text</var></code></dt>
  223. <dd><a name="index-set-trace_002dnotes"></a>
  224. <p>Set the trace run&rsquo;s notes.
  225. </p>
  226. </dd>
  227. <dt><code>show trace-notes</code></dt>
  228. <dd><a name="index-show-trace_002dnotes"></a>
  229. <p>Show the trace run&rsquo;s notes.
  230. </p>
  231. </dd>
  232. <dt><code>set trace-stop-notes <var>text</var></code></dt>
  233. <dd><a name="index-set-trace_002dstop_002dnotes"></a>
  234. <p>Set the trace run&rsquo;s stop notes. The handling of the note is as for
  235. <code>tstop</code> arguments; the set command is convenient way to fix a
  236. stop note that is mistaken or incomplete.
  237. </p>
  238. </dd>
  239. <dt><code>show trace-stop-notes</code></dt>
  240. <dd><a name="index-show-trace_002dstop_002dnotes"></a>
  241. <p>Show the trace run&rsquo;s stop notes.
  242. </p>
  243. </dd>
  244. </dl>
  245. <hr>
  246. <div class="header">
  247. <p>
  248. Next: <a href="Tracepoint-Restrictions.html#Tracepoint-Restrictions" accesskey="n" rel="next">Tracepoint Restrictions</a>, Previous: <a href="Listing-Static-Tracepoint-Markers.html#Listing-Static-Tracepoint-Markers" accesskey="p" rel="previous">Listing Static Tracepoint Markers</a>, Up: <a href="Set-Tracepoints.html#Set-Tracepoints" accesskey="u" rel="up">Set Tracepoints</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>
  249. </div>
  250. </body>
  251. </html>