Static-Probe-Points.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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: Static Probe Points</title>
  16. <meta name="description" content="Debugging with GDB: Static Probe Points">
  17. <meta name="keywords" content="Debugging with GDB: Static Probe Points">
  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="Breakpoints.html#Breakpoints" rel="up" title="Breakpoints">
  26. <link href="Error-in-Breakpoints.html#Error-in-Breakpoints" rel="next" title="Error in Breakpoints">
  27. <link href="Save-Breakpoints.html#Save-Breakpoints" rel="previous" title="Save Breakpoints">
  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="Static-Probe-Points"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Error-in-Breakpoints.html#Error-in-Breakpoints" accesskey="n" rel="next">Error in Breakpoints</a>, Previous: <a href="Save-Breakpoints.html#Save-Breakpoints" accesskey="p" rel="previous">Save Breakpoints</a>, Up: <a href="Breakpoints.html#Breakpoints" accesskey="u" rel="up">Breakpoints</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="Static-Probe-Points-1"></a>
  65. <h4 class="subsection">5.1.10 Static Probe Points</h4>
  66. <a name="index-static-probe-point_002c-SystemTap"></a>
  67. <a name="index-static-probe-point_002c-DTrace"></a>
  68. <p><small>GDB</small> supports <em>SDT</em> probes in the code. <acronym>SDT</acronym> stands
  69. for Statically Defined Tracing, and the probes are designed to have a tiny
  70. runtime code and data footprint, and no dynamic relocations.
  71. </p>
  72. <p>Currently, the following types of probes are supported on
  73. ELF-compatible systems:
  74. </p>
  75. <ul>
  76. <li> <code>SystemTap</code> (<a href="http://sourceware.org/systemtap/">http://sourceware.org/systemtap/</a>)
  77. <acronym>SDT</acronym> probes<a name="DOCF5" href="#FOOT5"><sup>5</sup></a>. <code>SystemTap</code> probes are usable
  78. from assembly, C and C<tt>++</tt> languages<a name="DOCF6" href="#FOOT6"><sup>6</sup></a>.
  79. </li><li> <code>DTrace</code> (<a href="http://oss.oracle.com/projects/DTrace">http://oss.oracle.com/projects/DTrace</a>)
  80. <acronym>USDT</acronym> probes. <code>DTrace</code> probes are usable from C and
  81. C<tt>++</tt> languages.
  82. </li></ul>
  83. <a name="index-semaphores-on-static-probe-points"></a>
  84. <p>Some <code>SystemTap</code> probes have an associated semaphore variable;
  85. for instance, this happens automatically if you defined your probe
  86. using a DTrace-style <samp>.d</samp> file. If your probe has a semaphore,
  87. <small>GDB</small> will automatically enable it when you specify a
  88. breakpoint using the &lsquo;<samp>-probe-stap</samp>&rsquo; notation. But, if you put a
  89. breakpoint at a probe&rsquo;s location by some other method (e.g.,
  90. <code>break file:line</code>), then <small>GDB</small> will not automatically set
  91. the semaphore. <code>DTrace</code> probes do not support semaphores.
  92. </p>
  93. <p>You can examine the available static static probes using <code>info
  94. probes</code>, with optional arguments:
  95. </p>
  96. <dl compact="compact">
  97. <dd><a name="index-info-probes"></a>
  98. </dd>
  99. <dt><code>info probes <span class="roman">[</span><var>type</var><span class="roman">]</span> <span class="roman">[</span><var>provider</var> <span class="roman">[</span><var>name</var> <span class="roman">[</span><var>objfile</var><span class="roman">]</span><span class="roman">]</span><span class="roman">]</span></code></dt>
  100. <dd><p>If given, <var>type</var> is either <code>stap</code> for listing
  101. <code>SystemTap</code> probes or <code>dtrace</code> for listing <code>DTrace</code>
  102. probes. If omitted all probes are listed regardless of their types.
  103. </p>
  104. <p>If given, <var>provider</var> is a regular expression used to match against provider
  105. names when selecting which probes to list. If omitted, probes by all
  106. probes from all providers are listed.
  107. </p>
  108. <p>If given, <var>name</var> is a regular expression to match against probe names
  109. when selecting which probes to list. If omitted, probe names are not
  110. considered when deciding whether to display them.
  111. </p>
  112. <p>If given, <var>objfile</var> is a regular expression used to select which
  113. object files (executable or shared libraries) to examine. If not
  114. given, all object files are considered.
  115. </p>
  116. </dd>
  117. <dt><code>info probes all</code></dt>
  118. <dd><p>List the available static probes, from all types.
  119. </p></dd>
  120. </dl>
  121. <a name="index-enabling-and-disabling-probes"></a>
  122. <p>Some probe points can be enabled and/or disabled. The effect of
  123. enabling or disabling a probe depends on the type of probe being
  124. handled. Some <code>DTrace</code> probes can be enabled or
  125. disabled, but <code>SystemTap</code> probes cannot be disabled.
  126. </p>
  127. <p>You can enable (or disable) one or more probes using the following
  128. commands, with optional arguments:
  129. </p>
  130. <dl compact="compact">
  131. <dd><a name="index-enable-probes"></a>
  132. </dd>
  133. <dt><code>enable probes <span class="roman">[</span><var>provider</var> <span class="roman">[</span><var>name</var> <span class="roman">[</span><var>objfile</var><span class="roman">]</span><span class="roman">]</span><span class="roman">]</span></code></dt>
  134. <dd><p>If given, <var>provider</var> is a regular expression used to match against
  135. provider names when selecting which probes to enable. If omitted,
  136. all probes from all providers are enabled.
  137. </p>
  138. <p>If given, <var>name</var> is a regular expression to match against probe
  139. names when selecting which probes to enable. If omitted, probe names
  140. are not considered when deciding whether to enable them.
  141. </p>
  142. <p>If given, <var>objfile</var> is a regular expression used to select which
  143. object files (executable or shared libraries) to examine. If not
  144. given, all object files are considered.
  145. </p>
  146. <a name="index-disable-probes"></a>
  147. </dd>
  148. <dt><code>disable probes <span class="roman">[</span><var>provider</var> <span class="roman">[</span><var>name</var> <span class="roman">[</span><var>objfile</var><span class="roman">]</span><span class="roman">]</span><span class="roman">]</span></code></dt>
  149. <dd><p>See the <code>enable probes</code> command above for a description of the
  150. optional arguments accepted by this command.
  151. </p></dd>
  152. </dl>
  153. <a name="index-_0024_005fprobe_005farg_002c-convenience-variable"></a>
  154. <p>A probe may specify up to twelve arguments. These are available at the
  155. point at which the probe is defined&mdash;that is, when the current PC is
  156. at the probe&rsquo;s location. The arguments are available using the
  157. convenience variables (see <a href="Convenience-Vars.html#Convenience-Vars">Convenience Vars</a>)
  158. <code>$_probe_arg0</code>&hellip;<code>$_probe_arg11</code>. In <code>SystemTap</code>
  159. probes each probe argument is an integer of the appropriate size;
  160. types are not preserved. In <code>DTrace</code> probes types are preserved
  161. provided that they are recognized as such by <small>GDB</small>; otherwise
  162. the value of the probe argument will be a long integer. The
  163. convenience variable <code>$_probe_argc</code> holds the number of arguments
  164. at the current probe point.
  165. </p>
  166. <p>These variables are always available, but attempts to access them at
  167. any location other than a probe point will cause <small>GDB</small> to give
  168. an error message.
  169. </p>
  170. <div class="footnote">
  171. <hr>
  172. <h4 class="footnotes-heading">Footnotes</h4>
  173. <h3><a name="FOOT5" href="#DOCF5">(5)</a></h3>
  174. <p>See
  175. <a href="http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps">http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps</a>
  176. for more information on how to add <code>SystemTap</code> <acronym>SDT</acronym>
  177. probes in your applications.</p>
  178. <h3><a name="FOOT6" href="#DOCF6">(6)</a></h3>
  179. <p>See
  180. <a href="http://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation">http://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation</a>
  181. for a good reference on how the <acronym>SDT</acronym> probes are implemented.</p>
  182. </div>
  183. <hr>
  184. <div class="header">
  185. <p>
  186. Next: <a href="Error-in-Breakpoints.html#Error-in-Breakpoints" accesskey="n" rel="next">Error in Breakpoints</a>, Previous: <a href="Save-Breakpoints.html#Save-Breakpoints" accesskey="p" rel="previous">Save Breakpoints</a>, Up: <a href="Breakpoints.html#Breakpoints" accesskey="u" rel="up">Breakpoints</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>
  187. </div>
  188. </body>
  189. </html>