3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Tracepoint%20Actions">Tracepoint Actions
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Listing-Tracepoints.html#Listing%20Tracepoints">Listing Tracepoints
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Tracepoint-Passcounts.html#Tracepoint%20Passcounts">Tracepoint Passcounts
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"Set-Tracepoints.html#Set%20Tracepoints">Set Tracepoints
</a>
19 <h4 class=
"subsection">Tracepoint Action Lists
</h4>
22 <dt><code>actions
</code>[
<code></code><var>num
</var><code></code>]
<code></code>
23 <dd>This command will prompt for a list of actions to be taken when the
24 tracepoint is hit. If the tracepoint number
<var>num
</var> is not
25 specified, this command sets the actions for the one that was most
26 recently defined (so that you can define a tracepoint and then say
27 <code>actions
</code> without bothering about its number). You specify the
28 actions themselves on the following lines, one action at a time, and
29 terminate the actions list with a line containing just
<code>end
</code>. So
30 far, the only defined actions are
<code>collect
</code> and
31 <code>while-stepping
</code>.
33 <p>To remove all actions from a tracepoint, type
<code>actions
</code><var>num
</var><code></code>
34 and follow it immediately with
<code>end
</code>.
36 <pre class=
"smallexample"> (gdb)
<b>collect
</b><var>data
</var><b></b> // collect some data
38 (gdb)
<b>while-stepping
5</b> // single-step
5 times, collect data
40 (gdb)
<b>end
</b> // signals the end of actions.
43 <p>In the following example, the action list begins with
<code>collect
</code>
44 commands indicating the things to be collected when the tracepoint is
45 hit. Then, in order to single-step and collect additional data
46 following the tracepoint, a
<code>while-stepping
</code> command is used,
47 followed by the list of things to be collected while stepping. The
48 <code>while-stepping
</code> command is terminated by its own separate
49 <code>end
</code> command. Lastly, the action list is terminated by an
50 <code>end
</code> command.
52 <pre class=
"smallexample"> (gdb)
<b>trace foo
</b>
54 Enter actions for tracepoint
1, one per line:
57 > while-stepping
12
63 <br><dt><code>collect
</code><var>expr1
</var><code>,
</code><var>expr2
</var><code>, ...
</code>
64 <dd>Collect values of the given expressions when the tracepoint is hit.
65 This command accepts a comma-separated list of any valid expressions.
66 In addition to global, static, or local variables, the following
67 special arguments are supported:
70 <dt><code>$regs
</code>
71 <dd>collect all registers
73 <br><dt><code>$args
</code>
74 <dd>collect all function arguments
76 <br><dt><code>$locals
</code>
77 <dd>collect all local variables.
80 <p>You can give several consecutive
<code>collect
</code> commands, each one
81 with a single argument, or one
<code>collect
</code> command with several
82 arguments separated by commas: the effect is the same.
84 <p>The command
<code>info scope
</code> (see
<a href=
"Symbols.html#Symbols">info scope
</a>) is
85 particularly useful for figuring out what data to collect.
87 <br><dt><code>while-stepping
</code><var>n
</var><code></code>
88 <dd>Perform
<var>n
</var> single-step traces after the tracepoint, collecting
89 new data at each step. The
<code>while-stepping
</code> command is
90 followed by the list of what to collect while stepping (followed by
91 its own
<code>end
</code> command):
93 <pre class=
"smallexample"> > while-stepping
12
94 > collect $regs, myglobal
99 <p>You may abbreviate
<code>while-stepping
</code> as
<code>ws
</code> or
100 <code>stepping
</code>.