| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <html> |
| <!-- Copyright (C) 1988-2015 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being "Free Software" and "Free Software Needs |
| Free Documentation", with the Front-Cover Texts being "A GNU Manual," |
| and with the Back-Cover Texts as in (a) below. |
| |
| (a) The FSF's Back-Cover Text is: "You are free to copy and modify |
| this GNU Manual. Buying copies from GNU Press supports the FSF in |
| developing GNU and promoting software freedom." --> |
| <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ --> |
| <head> |
| <title>Debugging with GDB: Tracepoint Actions</title> |
| |
| <meta name="description" content="Debugging with GDB: Tracepoint Actions"> |
| <meta name="keywords" content="Debugging with GDB: Tracepoint Actions"> |
| <meta name="resource-type" content="document"> |
| <meta name="distribution" content="global"> |
| <meta name="Generator" content="makeinfo"> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| <link href="index.html#Top" rel="start" title="Top"> |
| <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> |
| <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> |
| <link href="Set-Tracepoints.html#Set-Tracepoints" rel="up" title="Set Tracepoints"> |
| <link href="Listing-Tracepoints.html#Listing-Tracepoints" rel="next" title="Listing Tracepoints"> |
| <link href="Trace-State-Variables.html#Trace-State-Variables" rel="prev" title="Trace State Variables"> |
| <style type="text/css"> |
| <!-- |
| a.summary-letter {text-decoration: none} |
| blockquote.smallquotation {font-size: smaller} |
| div.display {margin-left: 3.2em} |
| div.example {margin-left: 3.2em} |
| div.indentedblock {margin-left: 3.2em} |
| div.lisp {margin-left: 3.2em} |
| div.smalldisplay {margin-left: 3.2em} |
| div.smallexample {margin-left: 3.2em} |
| div.smallindentedblock {margin-left: 3.2em; font-size: smaller} |
| div.smalllisp {margin-left: 3.2em} |
| kbd {font-style:oblique} |
| pre.display {font-family: inherit} |
| pre.format {font-family: inherit} |
| pre.menu-comment {font-family: serif} |
| pre.menu-preformatted {font-family: serif} |
| pre.smalldisplay {font-family: inherit; font-size: smaller} |
| pre.smallexample {font-size: smaller} |
| pre.smallformat {font-family: inherit; font-size: smaller} |
| pre.smalllisp {font-size: smaller} |
| span.nocodebreak {white-space:nowrap} |
| span.nolinebreak {white-space:nowrap} |
| span.roman {font-family:serif; font-weight:normal} |
| span.sansserif {font-family:sans-serif; font-weight:normal} |
| ul.no-bullet {list-style: none} |
| --> |
| </style> |
| |
| |
| </head> |
| |
| <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> |
| <a name="Tracepoint-Actions"></a> |
| <div class="header"> |
| <p> |
| Next: <a href="Listing-Tracepoints.html#Listing-Tracepoints" accesskey="n" rel="next">Listing Tracepoints</a>, Previous: <a href="Trace-State-Variables.html#Trace-State-Variables" accesskey="p" rel="prev">Trace State Variables</a>, Up: <a href="Set-Tracepoints.html#Set-Tracepoints" accesskey="u" rel="up">Set Tracepoints</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> |
| </div> |
| <hr> |
| <a name="Tracepoint-Action-Lists"></a> |
| <h4 class="subsection">13.1.6 Tracepoint Action Lists</h4> |
| |
| <dl compact="compact"> |
| <dd><a name="index-actions"></a> |
| <a name="index-tracepoint-actions"></a> |
| </dd> |
| <dt><code>actions <span class="roman">[</span><var>num</var><span class="roman">]</span></code></dt> |
| <dd><p>This command will prompt for a list of actions to be taken when the |
| tracepoint is hit. If the tracepoint number <var>num</var> is not |
| specified, this command sets the actions for the one that was most |
| recently defined (so that you can define a tracepoint and then say |
| <code>actions</code> without bothering about its number). You specify the |
| actions themselves on the following lines, one action at a time, and |
| terminate the actions list with a line containing just <code>end</code>. So |
| far, the only defined actions are <code>collect</code>, <code>teval</code>, and |
| <code>while-stepping</code>. |
| </p> |
| <p><code>actions</code> is actually equivalent to <code>commands</code> (see <a href="Break-Commands.html#Break-Commands">Breakpoint Command Lists</a>), except that only the defined |
| actions are allowed; any other <small>GDB</small> command is rejected. |
| </p> |
| <a name="index-remove-actions-from-a-tracepoint"></a> |
| <p>To remove all actions from a tracepoint, type ‘<samp>actions <var>num</var></samp>’ |
| and follow it immediately with ‘<samp>end</samp>’. |
| </p> |
| <div class="smallexample"> |
| <pre class="smallexample">(gdb) <b>collect <var>data</var></b> // collect some data |
| |
| (gdb) <b>while-stepping 5</b> // single-step 5 times, collect data |
| |
| (gdb) <b>end</b> // signals the end of actions. |
| </pre></div> |
| |
| <p>In the following example, the action list begins with <code>collect</code> |
| commands indicating the things to be collected when the tracepoint is |
| hit. Then, in order to single-step and collect additional data |
| following the tracepoint, a <code>while-stepping</code> command is used, |
| followed by the list of things to be collected after each step in a |
| sequence of single steps. The <code>while-stepping</code> command is |
| terminated by its own separate <code>end</code> command. Lastly, the action |
| list is terminated by an <code>end</code> command. |
| </p> |
| <div class="smallexample"> |
| <pre class="smallexample">(gdb) <b>trace foo</b> |
| (gdb) <b>actions</b> |
| Enter actions for tracepoint 1, one per line: |
| > collect bar,baz |
| > collect $regs |
| > while-stepping 12 |
| > collect $pc, arr[i] |
| > end |
| end |
| </pre></div> |
| |
| <a name="index-collect-_0028tracepoints_0029"></a> |
| </dd> |
| <dt><code>collect<span class="roman">[</span>/<var>mods</var><span class="roman">]</span> <var>expr1</var>, <var>expr2</var>, …</code></dt> |
| <dd><p>Collect values of the given expressions when the tracepoint is hit. |
| This command accepts a comma-separated list of any valid expressions. |
| In addition to global, static, or local variables, the following |
| special arguments are supported: |
| </p> |
| <dl compact="compact"> |
| <dt><code>$regs</code></dt> |
| <dd><p>Collect all registers. |
| </p> |
| </dd> |
| <dt><code>$args</code></dt> |
| <dd><p>Collect all function arguments. |
| </p> |
| </dd> |
| <dt><code>$locals</code></dt> |
| <dd><p>Collect all local variables. |
| </p> |
| </dd> |
| <dt><code>$_ret</code></dt> |
| <dd><p>Collect the return address. This is helpful if you want to see more |
| of a backtrace. |
| </p> |
| </dd> |
| <dt><code>$_probe_argc</code></dt> |
| <dd><p>Collects the number of arguments from the static probe at which the |
| tracepoint is located. |
| See <a href="Static-Probe-Points.html#Static-Probe-Points">Static Probe Points</a>. |
| </p> |
| </dd> |
| <dt><code>$_probe_arg<var>n</var></code></dt> |
| <dd><p><var>n</var> is an integer between 0 and 11. Collects the <var>n</var>th argument |
| from the static probe at which the tracepoint is located. |
| See <a href="Static-Probe-Points.html#Static-Probe-Points">Static Probe Points</a>. |
| </p> |
| </dd> |
| <dt><code>$_sdata</code></dt> |
| <dd><a name="index-_0024_005fsdata_002c-collect"></a> |
| <p>Collect static tracepoint marker specific data. Only available for |
| static tracepoints. See <a href="#Tracepoint-Actions">Tracepoint Action |
| Lists</a>. On the UST static tracepoints library backend, an |
| instrumentation point resembles a <code>printf</code> function call. The |
| tracing library is able to collect user specified data formatted to a |
| character string using the format provided by the programmer that |
| instrumented the program. Other backends have similar mechanisms. |
| Here’s an example of a UST marker call: |
| </p> |
| <div class="smallexample"> |
| <pre class="smallexample"> const char master_name[] = "$your_name"; |
| trace_mark(channel1, marker1, "hello %s", master_name) |
| </pre></div> |
| |
| <p>In this case, collecting <code>$_sdata</code> collects the string |
| ‘<samp>hello $yourname</samp>’. When analyzing the trace buffer, you can |
| inspect ‘<samp>$_sdata</samp>’ like any other variable available to |
| <small>GDB</small>. |
| </p></dd> |
| </dl> |
| |
| <p>You can give several consecutive <code>collect</code> commands, each one |
| with a single argument, or one <code>collect</code> command with several |
| arguments separated by commas; the effect is the same. |
| </p> |
| <p>The optional <var>mods</var> changes the usual handling of the arguments. |
| <code>s</code> requests that pointers to chars be handled as strings, in |
| particular collecting the contents of the memory being pointed at, up |
| to the first zero. The upper bound is by default the value of the |
| <code>print elements</code> variable; if <code>s</code> is followed by a decimal |
| number, that is the upper bound instead. So for instance |
| ‘<samp>collect/s25 mystr</samp>’ collects as many as 25 characters at |
| ‘<samp>mystr</samp>’. |
| </p> |
| <p>The command <code>info scope</code> (see <a href="Symbols.html#Symbols">info scope</a>) is |
| particularly useful for figuring out what data to collect. |
| </p> |
| <a name="index-teval-_0028tracepoints_0029"></a> |
| </dd> |
| <dt><code>teval <var>expr1</var>, <var>expr2</var>, …</code></dt> |
| <dd><p>Evaluate the given expressions when the tracepoint is hit. This |
| command accepts a comma-separated list of expressions. The results |
| are discarded, so this is mainly useful for assigning values to trace |
| state variables (see <a href="Trace-State-Variables.html#Trace-State-Variables">Trace State Variables</a>) without adding those |
| values to the trace buffer, as would be the case if the <code>collect</code> |
| action were used. |
| </p> |
| <a name="index-while_002dstepping-_0028tracepoints_0029"></a> |
| </dd> |
| <dt><code>while-stepping <var>n</var></code></dt> |
| <dd><p>Perform <var>n</var> single-step instruction traces after the tracepoint, |
| collecting new data after each step. The <code>while-stepping</code> |
| command is followed by the list of what to collect while stepping |
| (followed by its own <code>end</code> command): |
| </p> |
| <div class="smallexample"> |
| <pre class="smallexample">> while-stepping 12 |
| > collect $regs, myglobal |
| > end |
| > |
| </pre></div> |
| |
| <p>Note that <code>$pc</code> is not automatically collected by |
| <code>while-stepping</code>; you need to explicitly collect that register if |
| you need it. You may abbreviate <code>while-stepping</code> as <code>ws</code> or |
| <code>stepping</code>. |
| </p> |
| </dd> |
| <dt><code>set default-collect <var>expr1</var>, <var>expr2</var>, …</code></dt> |
| <dd><a name="index-set-default_002dcollect"></a> |
| <a name="index-default-collection-action"></a> |
| <p>This variable is a list of expressions to collect at each tracepoint |
| hit. It is effectively an additional <code>collect</code> action prepended |
| to every tracepoint action list. The expressions are parsed |
| individually for each tracepoint, so for instance a variable named |
| <code>xyz</code> may be interpreted as a global for one tracepoint, and a |
| local for another, as appropriate to the tracepoint’s location. |
| </p> |
| </dd> |
| <dt><code>show default-collect</code></dt> |
| <dd><a name="index-show-default_002dcollect"></a> |
| <p>Show the list of expressions that are collected by default at each |
| tracepoint hit. |
| </p> |
| </dd> |
| </dl> |
| |
| <hr> |
| <div class="header"> |
| <p> |
| Next: <a href="Listing-Tracepoints.html#Listing-Tracepoints" accesskey="n" rel="next">Listing Tracepoints</a>, Previous: <a href="Trace-State-Variables.html#Trace-State-Variables" accesskey="p" rel="prev">Trace State Variables</a>, Up: <a href="Set-Tracepoints.html#Set-Tracepoints" accesskey="u" rel="up">Set Tracepoints</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> |
| </div> |
| |
| |
| |
| </body> |
| </html> |