Frame-Apply.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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: Frame Apply</title>
  16. <meta name="description" content="Debugging with GDB: Frame Apply">
  17. <meta name="keywords" content="Debugging with GDB: Frame Apply">
  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="Stack.html#Stack" rel="up" title="Stack">
  26. <link href="Frame-Filter-Management.html#Frame-Filter-Management" rel="next" title="Frame Filter Management">
  27. <link href="Frame-Info.html#Frame-Info" rel="previous" title="Frame Info">
  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="Frame-Apply"></a>
  59. <div class="header">
  60. <p>
  61. Next: <a href="Frame-Filter-Management.html#Frame-Filter-Management" accesskey="n" rel="next">Frame Filter Management</a>, Previous: <a href="Frame-Info.html#Frame-Info" accesskey="p" rel="previous">Frame Info</a>, Up: <a href="Stack.html#Stack" accesskey="u" rel="up">Stack</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="Applying-a-Command-to-Several-Frames_002e"></a>
  65. <h3 class="section">8.5 Applying a Command to Several Frames.</h3>
  66. <a name="index-frame-apply"></a>
  67. <a name="index-apply-command-to-several-frames"></a>
  68. <dl compact="compact">
  69. <dt><code>frame apply [all | <var>count</var> | <var>-count</var> | level <var>level</var>&hellip;] [<var>option</var>]&hellip; <var>command</var></code></dt>
  70. <dd><p>The <code>frame apply</code> command allows you to apply the named
  71. <var>command</var> to one or more frames.
  72. </p>
  73. <dl compact="compact">
  74. <dt><code><code>all</code></code></dt>
  75. <dd><p>Specify <code>all</code> to apply <var>command</var> to all frames.
  76. </p>
  77. </dd>
  78. <dt><code><var>count</var></code></dt>
  79. <dd><p>Use <var>count</var> to apply <var>command</var> to the innermost <var>count</var>
  80. frames, where <var>count</var> is a positive number.
  81. </p>
  82. </dd>
  83. <dt><code><var>-count</var></code></dt>
  84. <dd><p>Use <var>-count</var> to apply <var>command</var> to the outermost <var>count</var>
  85. frames, where <var>count</var> is a positive number.
  86. </p>
  87. </dd>
  88. <dt><code><code>level</code></code></dt>
  89. <dd><p>Use <code>level</code> to apply <var>command</var> to the set of frames identified
  90. by the <var>level</var> list. <var>level</var> is a frame level or a range of frame
  91. levels as <var>level1</var>-<var>level2</var>. The frame level is the number shown
  92. in the first field of the &lsquo;<samp>backtrace</samp>&rsquo; command output.
  93. E.g., &lsquo;<samp>2-4 6-8 3</samp>&rsquo; indicates to apply <var>command</var> for the frames
  94. at levels 2, 3, 4, 6, 7, 8, and then again on frame at level 3.
  95. </p>
  96. </dd>
  97. </dl>
  98. <p>Note that the frames on which <code>frame apply</code> applies a command are
  99. also influenced by the <code>set backtrace</code> settings such as <code>set
  100. backtrace past-main</code> and <code>set backtrace limit N</code>.
  101. See <a href="Backtrace.html#Backtrace">Backtraces</a>.
  102. </p>
  103. <p>The <code>frame apply</code> command also supports a number of options that
  104. allow overriding relevant <code>set backtrace</code> settings:
  105. </p>
  106. <dl compact="compact">
  107. <dt><code>-past-main [<code>on</code>|<code>off</code>]</code></dt>
  108. <dd><p>Whether backtraces should continue past <code>main</code>.
  109. Related setting: <a href="Backtrace.html#set-backtrace-past_002dmain">set backtrace past-main</a>.
  110. </p>
  111. </dd>
  112. <dt><code>-past-entry [<code>on</code>|<code>off</code>]</code></dt>
  113. <dd><p>Whether backtraces should continue past the entry point of a program.
  114. Related setting: <a href="Backtrace.html#set-backtrace-past_002dentry">set backtrace past-entry</a>.
  115. </p></dd>
  116. </dl>
  117. <p>By default, <small>GDB</small> displays some frame information before the
  118. output produced by <var>command</var>, and an error raised during the
  119. execution of a <var>command</var> will abort <code>frame apply</code>. The
  120. following options can be used to fine-tune these behaviors:
  121. </p>
  122. <dl compact="compact">
  123. <dt><code>-c</code></dt>
  124. <dd><p>The flag <code>-c</code>, which stands for &lsquo;<samp>continue</samp>&rsquo;, causes any
  125. errors in <var>command</var> to be displayed, and the execution of
  126. <code>frame apply</code> then continues.
  127. </p></dd>
  128. <dt><code>-s</code></dt>
  129. <dd><p>The flag <code>-s</code>, which stands for &lsquo;<samp>silent</samp>&rsquo;, causes any errors
  130. or empty output produced by a <var>command</var> to be silently ignored.
  131. That is, the execution continues, but the frame information and errors
  132. are not printed.
  133. </p></dd>
  134. <dt><code>-q</code></dt>
  135. <dd><p>The flag <code>-q</code> (&lsquo;<samp>quiet</samp>&rsquo;) disables printing the frame
  136. information.
  137. </p></dd>
  138. </dl>
  139. <p>The following example shows how the flags <code>-c</code> and <code>-s</code> are
  140. working when applying the command <code>p j</code> to all frames, where
  141. variable <code>j</code> can only be successfully printed in the outermost
  142. <code>#1 main</code> frame.
  143. </p>
  144. <div class="smallexample">
  145. <pre class="smallexample">(gdb) frame apply all p j
  146. #0 some_function (i=5) at fun.c:4
  147. No symbol &quot;j&quot; in current context.
  148. (gdb) frame apply all -c p j
  149. #0 some_function (i=5) at fun.c:4
  150. No symbol &quot;j&quot; in current context.
  151. #1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
  152. $1 = 5
  153. (gdb) frame apply all -s p j
  154. #1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
  155. $2 = 5
  156. (gdb)
  157. </pre></div>
  158. <p>By default, &lsquo;<samp>frame apply</samp>&rsquo;, prints the frame location
  159. information before the command output:
  160. </p>
  161. <div class="smallexample">
  162. <pre class="smallexample">(gdb) frame apply all p $sp
  163. #0 some_function (i=5) at fun.c:4
  164. $4 = (void *) 0xffffd1e0
  165. #1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
  166. $5 = (void *) 0xffffd1f0
  167. (gdb)
  168. </pre></div>
  169. <p>If the flag <code>-q</code> is given, no frame information is printed:
  170. </p><div class="smallexample">
  171. <pre class="smallexample">(gdb) frame apply all -q p $sp
  172. $12 = (void *) 0xffffd1e0
  173. $13 = (void *) 0xffffd1f0
  174. (gdb)
  175. </pre></div>
  176. </dd>
  177. </dl>
  178. <dl compact="compact">
  179. <dd>
  180. <a name="index-faas"></a>
  181. <a name="index-apply-a-command-to-all-frames-_0028ignoring-errors-and-empty-output_0029"></a>
  182. </dd>
  183. <dt><code>faas <var>command</var></code></dt>
  184. <dd><p>Shortcut for <code>frame apply all -s <var>command</var></code>.
  185. Applies <var>command</var> on all frames, ignoring errors and empty output.
  186. </p>
  187. <p>It can for example be used to print a local variable or a function
  188. argument without knowing the frame where this variable or argument
  189. is, using:
  190. </p><div class="smallexample">
  191. <pre class="smallexample">(gdb) faas p some_local_var_i_do_not_remember_where_it_is
  192. </pre></div>
  193. <p>The <code>faas</code> command accepts the same options as the <code>frame
  194. apply</code> command. See <a href="#Frame-Apply">frame apply</a>.
  195. </p>
  196. <p>Note that the command <code>tfaas <var>command</var></code> applies <var>command</var>
  197. on all frames of all threads. See See <a href="Threads.html#Threads">Threads</a>.
  198. </p></dd>
  199. </dl>
  200. <hr>
  201. <div class="header">
  202. <p>
  203. Next: <a href="Frame-Filter-Management.html#Frame-Filter-Management" accesskey="n" rel="next">Frame Filter Management</a>, Previous: <a href="Frame-Info.html#Frame-Info" accesskey="p" rel="previous">Frame Info</a>, Up: <a href="Stack.html#Stack" accesskey="u" rel="up">Stack</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>
  204. </div>
  205. </body>
  206. </html>