No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

Tracepoint-Actions.html 12KB

hace 3 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Tracepoint Actions (Debugging with GDB)</title>
  17. <meta name="description" content="Tracepoint Actions (Debugging with GDB)">
  18. <meta name="keywords" content="Tracepoint Actions (Debugging with GDB)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  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="Listing-Tracepoints.html#Listing-Tracepoints" rel="next" title="Listing Tracepoints">
  27. <link href="Trace-State-Variables.html#Trace-State-Variables" rel="prev" title="Trace State Variables">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Tracepoint-Actions"></a>
  58. <div class="header">
  59. <p>
  60. 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> &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>
  61. </div>
  62. <hr>
  63. <a name="Tracepoint-Action-Lists"></a>
  64. <h4 class="subsection">13.1.6 Tracepoint Action Lists</h4>
  65. <dl compact="compact">
  66. <dd><a name="index-actions"></a>
  67. <a name="index-tracepoint-actions"></a>
  68. </dd>
  69. <dt><code>actions <span class="roman">[</span><var>num</var><span class="roman">]</span></code></dt>
  70. <dd><p>This command will prompt for a list of actions to be taken when the
  71. tracepoint is hit. If the tracepoint number <var>num</var> is not
  72. specified, this command sets the actions for the one that was most
  73. recently defined (so that you can define a tracepoint and then say
  74. <code>actions</code> without bothering about its number). You specify the
  75. actions themselves on the following lines, one action at a time, and
  76. terminate the actions list with a line containing just <code>end</code>. So
  77. far, the only defined actions are <code>collect</code>, <code>teval</code>, and
  78. <code>while-stepping</code>.
  79. </p>
  80. <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
  81. actions are allowed; any other <small>GDB</small> command is rejected.
  82. </p>
  83. <a name="index-remove-actions-from-a-tracepoint"></a>
  84. <p>To remove all actions from a tracepoint, type &lsquo;<samp>actions <var>num</var></samp>&rsquo;
  85. and follow it immediately with &lsquo;<samp>end</samp>&rsquo;.
  86. </p>
  87. <div class="smallexample">
  88. <pre class="smallexample">(gdb) <b>collect <var>data</var></b> // collect some data
  89. (gdb) <b>while-stepping 5</b> // single-step 5 times, collect data
  90. (gdb) <b>end</b> // signals the end of actions.
  91. </pre></div>
  92. <p>In the following example, the action list begins with <code>collect</code>
  93. commands indicating the things to be collected when the tracepoint is
  94. hit. Then, in order to single-step and collect additional data
  95. following the tracepoint, a <code>while-stepping</code> command is used,
  96. followed by the list of things to be collected after each step in a
  97. sequence of single steps. The <code>while-stepping</code> command is
  98. terminated by its own separate <code>end</code> command. Lastly, the action
  99. list is terminated by an <code>end</code> command.
  100. </p>
  101. <div class="smallexample">
  102. <pre class="smallexample">(gdb) <b>trace foo</b>
  103. (gdb) <b>actions</b>
  104. Enter actions for tracepoint 1, one per line:
  105. &gt; collect bar,baz
  106. &gt; collect $regs
  107. &gt; while-stepping 12
  108. &gt; collect $pc, arr[i]
  109. &gt; end
  110. end
  111. </pre></div>
  112. <a name="index-collect-_0028tracepoints_0029"></a>
  113. </dd>
  114. <dt><code>collect<span class="roman">[</span>/<var>mods</var><span class="roman">]</span> <var>expr1</var>, <var>expr2</var>, &hellip;</code></dt>
  115. <dd><p>Collect values of the given expressions when the tracepoint is hit.
  116. This command accepts a comma-separated list of any valid expressions.
  117. In addition to global, static, or local variables, the following
  118. special arguments are supported:
  119. </p>
  120. <dl compact="compact">
  121. <dt><code>$regs</code></dt>
  122. <dd><p>Collect all registers.
  123. </p>
  124. </dd>
  125. <dt><code>$args</code></dt>
  126. <dd><p>Collect all function arguments.
  127. </p>
  128. </dd>
  129. <dt><code>$locals</code></dt>
  130. <dd><p>Collect all local variables.
  131. </p>
  132. </dd>
  133. <dt><code>$_ret</code></dt>
  134. <dd><p>Collect the return address. This is helpful if you want to see more
  135. of a backtrace.
  136. </p>
  137. <p><em>Note:</em> The return address location can not always be reliably
  138. determined up front, and the wrong address / registers may end up
  139. collected instead. On some architectures the reliability is higher
  140. for tracepoints at function entry, while on others it&rsquo;s the opposite.
  141. When this happens, backtracing will stop because the return address is
  142. found unavailable (unless another collect rule happened to match it).
  143. </p>
  144. </dd>
  145. <dt><code>$_probe_argc</code></dt>
  146. <dd><p>Collects the number of arguments from the static probe at which the
  147. tracepoint is located.
  148. See <a href="Static-Probe-Points.html#Static-Probe-Points">Static Probe Points</a>.
  149. </p>
  150. </dd>
  151. <dt><code>$_probe_arg<var>n</var></code></dt>
  152. <dd><p><var>n</var> is an integer between 0 and 11. Collects the <var>n</var>th argument
  153. from the static probe at which the tracepoint is located.
  154. See <a href="Static-Probe-Points.html#Static-Probe-Points">Static Probe Points</a>.
  155. </p>
  156. </dd>
  157. <dt><code>$_sdata</code></dt>
  158. <dd><a name="index-_0024_005fsdata_002c-collect"></a>
  159. <p>Collect static tracepoint marker specific data. Only available for
  160. static tracepoints. See <a href="#Tracepoint-Actions">Tracepoint Action
  161. Lists</a>. On the UST static tracepoints library backend, an
  162. instrumentation point resembles a <code>printf</code> function call. The
  163. tracing library is able to collect user specified data formatted to a
  164. character string using the format provided by the programmer that
  165. instrumented the program. Other backends have similar mechanisms.
  166. Here&rsquo;s an example of a UST marker call:
  167. </p>
  168. <div class="smallexample">
  169. <pre class="smallexample"> const char master_name[] = &quot;$your_name&quot;;
  170. trace_mark(channel1, marker1, &quot;hello %s&quot;, master_name)
  171. </pre></div>
  172. <p>In this case, collecting <code>$_sdata</code> collects the string
  173. &lsquo;<samp>hello $yourname</samp>&rsquo;. When analyzing the trace buffer, you can
  174. inspect &lsquo;<samp>$_sdata</samp>&rsquo; like any other variable available to
  175. <small>GDB</small>.
  176. </p></dd>
  177. </dl>
  178. <p>You can give several consecutive <code>collect</code> commands, each one
  179. with a single argument, or one <code>collect</code> command with several
  180. arguments separated by commas; the effect is the same.
  181. </p>
  182. <p>The optional <var>mods</var> changes the usual handling of the arguments.
  183. <code>s</code> requests that pointers to chars be handled as strings, in
  184. particular collecting the contents of the memory being pointed at, up
  185. to the first zero. The upper bound is by default the value of the
  186. <code>print elements</code> variable; if <code>s</code> is followed by a decimal
  187. number, that is the upper bound instead. So for instance
  188. &lsquo;<samp>collect/s25 mystr</samp>&rsquo; collects as many as 25 characters at
  189. &lsquo;<samp>mystr</samp>&rsquo;.
  190. </p>
  191. <p>The command <code>info scope</code> (see <a href="Symbols.html#Symbols">info scope</a>) is
  192. particularly useful for figuring out what data to collect.
  193. </p>
  194. <a name="index-teval-_0028tracepoints_0029"></a>
  195. </dd>
  196. <dt><code>teval <var>expr1</var>, <var>expr2</var>, &hellip;</code></dt>
  197. <dd><p>Evaluate the given expressions when the tracepoint is hit. This
  198. command accepts a comma-separated list of expressions. The results
  199. are discarded, so this is mainly useful for assigning values to trace
  200. state variables (see <a href="Trace-State-Variables.html#Trace-State-Variables">Trace State Variables</a>) without adding those
  201. values to the trace buffer, as would be the case if the <code>collect</code>
  202. action were used.
  203. </p>
  204. <a name="index-while_002dstepping-_0028tracepoints_0029"></a>
  205. </dd>
  206. <dt><code>while-stepping <var>n</var></code></dt>
  207. <dd><p>Perform <var>n</var> single-step instruction traces after the tracepoint,
  208. collecting new data after each step. The <code>while-stepping</code>
  209. command is followed by the list of what to collect while stepping
  210. (followed by its own <code>end</code> command):
  211. </p>
  212. <div class="smallexample">
  213. <pre class="smallexample">&gt; while-stepping 12
  214. &gt; collect $regs, myglobal
  215. &gt; end
  216. &gt;
  217. </pre></div>
  218. <p>Note that <code>$pc</code> is not automatically collected by
  219. <code>while-stepping</code>; you need to explicitly collect that register if
  220. you need it. You may abbreviate <code>while-stepping</code> as <code>ws</code> or
  221. <code>stepping</code>.
  222. </p>
  223. </dd>
  224. <dt><code>set default-collect <var>expr1</var>, <var>expr2</var>, &hellip;</code></dt>
  225. <dd><a name="index-set-default_002dcollect"></a>
  226. <a name="index-default-collection-action"></a>
  227. <p>This variable is a list of expressions to collect at each tracepoint
  228. hit. It is effectively an additional <code>collect</code> action prepended
  229. to every tracepoint action list. The expressions are parsed
  230. individually for each tracepoint, so for instance a variable named
  231. <code>xyz</code> may be interpreted as a global for one tracepoint, and a
  232. local for another, as appropriate to the tracepoint&rsquo;s location.
  233. </p>
  234. </dd>
  235. <dt><code>show default-collect</code></dt>
  236. <dd><a name="index-show-default_002dcollect"></a>
  237. <p>Show the list of expressions that are collected by default at each
  238. tracepoint hit.
  239. </p>
  240. </dd>
  241. </dl>
  242. <hr>
  243. <div class="header">
  244. <p>
  245. 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> &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>
  246. </div>
  247. </body>
  248. </html>