Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

225 rindas
9.4KB

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