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