Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

281 lines
12KB

  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>Skipping Over Functions and Files (Debugging with GDB)</title>
  17. <meta name="description" content="Skipping Over Functions and Files (Debugging with GDB)">
  18. <meta name="keywords" content="Skipping Over Functions and Files (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="Stopping.html#Stopping" rel="up" title="Stopping">
  26. <link href="Signals.html#Signals" rel="next" title="Signals">
  27. <link href="Continuing-and-Stepping.html#Continuing-and-Stepping" rel="prev" title="Continuing and Stepping">
  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="Skipping-Over-Functions-and-Files"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Signals.html#Signals" accesskey="n" rel="next">Signals</a>, Previous: <a href="Continuing-and-Stepping.html#Continuing-and-Stepping" accesskey="p" rel="prev">Continuing and Stepping</a>, Up: <a href="Stopping.html#Stopping" accesskey="u" rel="up">Stopping</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="Skipping-Over-Functions-and-Files-1"></a>
  64. <h3 class="section">5.3 Skipping Over Functions and Files</h3>
  65. <a name="index-skipping-over-functions-and-files"></a>
  66. <p>The program you are debugging may contain some functions which are
  67. uninteresting to debug. The <code>skip</code> command lets you tell <small>GDB</small> to
  68. skip a function, all functions in a file or a particular function in
  69. a particular file when stepping.
  70. </p>
  71. <p>For example, consider the following C function:
  72. </p>
  73. <div class="smallexample">
  74. <pre class="smallexample">101 int func()
  75. 102 {
  76. 103 foo(boring());
  77. 104 bar(boring());
  78. 105 }
  79. </pre></div>
  80. <p>Suppose you wish to step into the functions <code>foo</code> and <code>bar</code>, but you
  81. are not interested in stepping through <code>boring</code>. If you run <code>step</code>
  82. at line 103, you&rsquo;ll enter <code>boring()</code>, but if you run <code>next</code>, you&rsquo;ll
  83. step over both <code>foo</code> and <code>boring</code>!
  84. </p>
  85. <p>One solution is to <code>step</code> into <code>boring</code> and use the <code>finish</code>
  86. command to immediately exit it. But this can become tedious if <code>boring</code>
  87. is called from many places.
  88. </p>
  89. <p>A more flexible solution is to execute <kbd>skip boring</kbd>. This instructs
  90. <small>GDB</small> never to step into <code>boring</code>. Now when you execute
  91. <code>step</code> at line 103, you&rsquo;ll step over <code>boring</code> and directly into
  92. <code>foo</code>.
  93. </p>
  94. <p>Functions may be skipped by providing either a function name, linespec
  95. (see <a href="Specify-Location.html#Specify-Location">Specify Location</a>), regular expression that matches the function&rsquo;s
  96. name, file name or a <code>glob</code>-style pattern that matches the file name.
  97. </p>
  98. <p>On Posix systems the form of the regular expression is
  99. &ldquo;Extended Regular Expressions&rdquo;. See for example &lsquo;<samp>man 7 regex</samp>&rsquo;
  100. on <small>GNU</small>/Linux systems. On non-Posix systems the form of the regular
  101. expression is whatever is provided by the <code>regcomp</code> function of
  102. the underlying system.
  103. See for example &lsquo;<samp>man 7 glob</samp>&rsquo; on <small>GNU</small>/Linux systems for a
  104. description of <code>glob</code>-style patterns.
  105. </p>
  106. <dl compact="compact">
  107. <dd><a name="index-skip"></a>
  108. </dd>
  109. <dt><code>skip <span class="roman">[</span><var>options</var><span class="roman">]</span></code></dt>
  110. <dd><p>The basic form of the <code>skip</code> command takes zero or more options
  111. that specify what to skip.
  112. The <var>options</var> argument is any useful combination of the following:
  113. </p>
  114. <dl compact="compact">
  115. <dt><code>-file <var>file</var></code></dt>
  116. <dt><code>-fi <var>file</var></code></dt>
  117. <dd><p>Functions in <var>file</var> will be skipped over when stepping.
  118. </p>
  119. </dd>
  120. <dt><code>-gfile <var>file-glob-pattern</var></code></dt>
  121. <dt><code>-gfi <var>file-glob-pattern</var></code></dt>
  122. <dd><a name="index-skipping-over-files-via-glob_002dstyle-patterns"></a>
  123. <p>Functions in files matching <var>file-glob-pattern</var> will be skipped
  124. over when stepping.
  125. </p>
  126. <div class="smallexample">
  127. <pre class="smallexample">(gdb) skip -gfi utils/*.c
  128. </pre></div>
  129. </dd>
  130. <dt><code>-function <var>linespec</var></code></dt>
  131. <dt><code>-fu <var>linespec</var></code></dt>
  132. <dd><p>Functions named by <var>linespec</var> or the function containing the line
  133. named by <var>linespec</var> will be skipped over when stepping.
  134. See <a href="Specify-Location.html#Specify-Location">Specify Location</a>.
  135. </p>
  136. </dd>
  137. <dt><code>-rfunction <var>regexp</var></code></dt>
  138. <dt><code>-rfu <var>regexp</var></code></dt>
  139. <dd><a name="index-skipping-over-functions-via-regular-expressions"></a>
  140. <p>Functions whose name matches <var>regexp</var> will be skipped over when stepping.
  141. </p>
  142. <p>This form is useful for complex function names.
  143. For example, there is generally no need to step into C<tt>++</tt> <code>std::string</code>
  144. constructors or destructors. Plus with C<tt>++</tt> templates it can be hard to
  145. write out the full name of the function, and often it doesn&rsquo;t matter what
  146. the template arguments are. Specifying the function to be skipped as a
  147. regular expression makes this easier.
  148. </p>
  149. <div class="smallexample">
  150. <pre class="smallexample">(gdb) skip -rfu ^std::(allocator|basic_string)&lt;.*&gt;::~?\1 *\(
  151. </pre></div>
  152. <p>If you want to skip every templated C<tt>++</tt> constructor and destructor
  153. in the <code>std</code> namespace you can do:
  154. </p>
  155. <div class="smallexample">
  156. <pre class="smallexample">(gdb) skip -rfu ^std::([a-zA-z0-9_]+)&lt;.*&gt;::~?\1 *\(
  157. </pre></div>
  158. </dd>
  159. </dl>
  160. <p>If no options are specified, the function you&rsquo;re currently debugging
  161. will be skipped.
  162. </p>
  163. <a name="index-skip-function"></a>
  164. </dd>
  165. <dt><code>skip function <span class="roman">[</span><var>linespec</var><span class="roman">]</span></code></dt>
  166. <dd><p>After running this command, the function named by <var>linespec</var> or the
  167. function containing the line named by <var>linespec</var> will be skipped over when
  168. stepping. See <a href="Specify-Location.html#Specify-Location">Specify Location</a>.
  169. </p>
  170. <p>If you do not specify <var>linespec</var>, the function you&rsquo;re currently debugging
  171. will be skipped.
  172. </p>
  173. <p>(If you have a function called <code>file</code> that you want to skip, use
  174. <kbd>skip function file</kbd>.)
  175. </p>
  176. <a name="index-skip-file"></a>
  177. </dd>
  178. <dt><code>skip file <span class="roman">[</span><var>filename</var><span class="roman">]</span></code></dt>
  179. <dd><p>After running this command, any function whose source lives in <var>filename</var>
  180. will be skipped over when stepping.
  181. </p>
  182. <div class="smallexample">
  183. <pre class="smallexample">(gdb) skip file boring.c
  184. File boring.c will be skipped when stepping.
  185. </pre></div>
  186. <p>If you do not specify <var>filename</var>, functions whose source lives in the file
  187. you&rsquo;re currently debugging will be skipped.
  188. </p></dd>
  189. </dl>
  190. <p>Skips can be listed, deleted, disabled, and enabled, much like breakpoints.
  191. These are the commands for managing your list of skips:
  192. </p>
  193. <dl compact="compact">
  194. <dd><a name="index-info-skip"></a>
  195. </dd>
  196. <dt><code>info skip <span class="roman">[</span><var>range</var><span class="roman">]</span></code></dt>
  197. <dd><p>Print details about the specified skip(s). If <var>range</var> is not specified,
  198. print a table with details about all functions and files marked for skipping.
  199. <code>info skip</code> prints the following information about each skip:
  200. </p>
  201. <dl compact="compact">
  202. <dt><em>Identifier</em></dt>
  203. <dd><p>A number identifying this skip.
  204. </p></dd>
  205. <dt><em>Enabled or Disabled</em></dt>
  206. <dd><p>Enabled skips are marked with &lsquo;<samp>y</samp>&rsquo;.
  207. Disabled skips are marked with &lsquo;<samp>n</samp>&rsquo;.
  208. </p></dd>
  209. <dt><em>Glob</em></dt>
  210. <dd><p>If the file name is a &lsquo;<samp>glob</samp>&rsquo; pattern this is &lsquo;<samp>y</samp>&rsquo;.
  211. Otherwise it is &lsquo;<samp>n</samp>&rsquo;.
  212. </p></dd>
  213. <dt><em>File</em></dt>
  214. <dd><p>The name or &lsquo;<samp>glob</samp>&rsquo; pattern of the file to be skipped.
  215. If no file is specified this is &lsquo;<samp>&lt;none&gt;</samp>&rsquo;.
  216. </p></dd>
  217. <dt><em>RE</em></dt>
  218. <dd><p>If the function name is a &lsquo;<samp>regular expression</samp>&rsquo; this is &lsquo;<samp>y</samp>&rsquo;.
  219. Otherwise it is &lsquo;<samp>n</samp>&rsquo;.
  220. </p></dd>
  221. <dt><em>Function</em></dt>
  222. <dd><p>The name or regular expression of the function to skip.
  223. If no function is specified this is &lsquo;<samp>&lt;none&gt;</samp>&rsquo;.
  224. </p></dd>
  225. </dl>
  226. <a name="index-skip-delete"></a>
  227. </dd>
  228. <dt><code>skip delete <span class="roman">[</span><var>range</var><span class="roman">]</span></code></dt>
  229. <dd><p>Delete the specified skip(s). If <var>range</var> is not specified, delete all
  230. skips.
  231. </p>
  232. <a name="index-skip-enable"></a>
  233. </dd>
  234. <dt><code>skip enable <span class="roman">[</span><var>range</var><span class="roman">]</span></code></dt>
  235. <dd><p>Enable the specified skip(s). If <var>range</var> is not specified, enable all
  236. skips.
  237. </p>
  238. <a name="index-skip-disable"></a>
  239. </dd>
  240. <dt><code>skip disable <span class="roman">[</span><var>range</var><span class="roman">]</span></code></dt>
  241. <dd><p>Disable the specified skip(s). If <var>range</var> is not specified, disable all
  242. skips.
  243. </p>
  244. <a name="index-set-debug-skip"></a>
  245. </dd>
  246. <dt><code>set debug skip <span class="roman">[</span>on|off<span class="roman">]</span></code></dt>
  247. <dd><p>Set whether to print the debug output about skipping files and functions.
  248. </p>
  249. <a name="index-show-debug-skip"></a>
  250. </dd>
  251. <dt><code>show debug skip</code></dt>
  252. <dd><p>Show whether the debug output about skipping files and functions is printed.
  253. </p>
  254. </dd>
  255. </dl>
  256. <hr>
  257. <div class="header">
  258. <p>
  259. Next: <a href="Signals.html#Signals" accesskey="n" rel="next">Signals</a>, Previous: <a href="Continuing-and-Stepping.html#Continuing-and-Stepping" accesskey="p" rel="prev">Continuing and Stepping</a>, Up: <a href="Stopping.html#Stopping" accesskey="u" rel="up">Stopping</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>
  260. </div>
  261. </body>
  262. </html>