Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

304 lines
13KB

  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>Frames In Guile (Debugging with GDB)</title>
  17. <meta name="description" content="Frames In Guile (Debugging with GDB)">
  18. <meta name="keywords" content="Frames In Guile (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="Guile-API.html#Guile-API" rel="up" title="Guile API">
  26. <link href="Blocks-In-Guile.html#Blocks-In-Guile" rel="next" title="Blocks In Guile">
  27. <link href="Objfiles-In-Guile.html#Objfiles-In-Guile" rel="prev" title="Objfiles In Guile">
  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="Frames-In-Guile"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Blocks-In-Guile.html#Blocks-In-Guile" accesskey="n" rel="next">Blocks In Guile</a>, Previous: <a href="Objfiles-In-Guile.html#Objfiles-In-Guile" accesskey="p" rel="prev">Objfiles In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile API</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="Accessing-inferior-stack-frames-from-Guile_002e"></a>
  64. <h4 class="subsubsection">23.3.3.15 Accessing inferior stack frames from Guile.</h4>
  65. <a name="index-frames-in-guile"></a>
  66. <p>When the debugged program stops, <small>GDB</small> is able to analyze its call
  67. stack (see <a href="Frames.html#Frames">Stack frames</a>). The <code>&lt;gdb:frame&gt;</code> class
  68. represents a frame in the stack. A <code>&lt;gdb:frame&gt;</code> object is only valid
  69. while its corresponding frame exists in the inferior&rsquo;s stack. If you try
  70. to use an invalid frame object, <small>GDB</small> will throw a
  71. <code>gdb:invalid-object</code> exception (see <a href="Guile-Exception-Handling.html#Guile-Exception-Handling">Guile Exception Handling</a>).
  72. </p>
  73. <p>Two <code>&lt;gdb:frame&gt;</code> objects can be compared for equality with the
  74. <code>equal?</code> function, like:
  75. </p>
  76. <div class="smallexample">
  77. <pre class="smallexample">(gdb) guile (equal? (newest-frame) (selected-frame))
  78. #t
  79. </pre></div>
  80. <p>The following frame-related procedures are provided by the
  81. <code>(gdb)</code> module:
  82. </p>
  83. <dl>
  84. <dt><a name="index-frame_003f"></a>Scheme Procedure: <strong>frame?</strong> <em>object</em></dt>
  85. <dd><p>Return <code>#t</code> if <var>object</var> is a <code>&lt;gdb:frame&gt;</code> object.
  86. Otherwise return <code>#f</code>.
  87. </p></dd></dl>
  88. <dl>
  89. <dt><a name="index-frame_002dvalid_003f"></a>Scheme Procedure: <strong>frame-valid?</strong> <em>frame</em></dt>
  90. <dd><p>Returns <code>#t</code> if <var>frame</var> is valid, <code>#f</code> if not.
  91. A frame object can become invalid if the frame it refers to doesn&rsquo;t
  92. exist anymore in the inferior. All <code>&lt;gdb:frame&gt;</code> procedures will throw
  93. an exception if the frame is invalid at the time the procedure is called.
  94. </p></dd></dl>
  95. <dl>
  96. <dt><a name="index-frame_002dname"></a>Scheme Procedure: <strong>frame-name</strong> <em>frame</em></dt>
  97. <dd><p>Return the function name of <var>frame</var>, or <code>#f</code> if it can&rsquo;t be
  98. obtained.
  99. </p></dd></dl>
  100. <dl>
  101. <dt><a name="index-frame_002darch"></a>Scheme Procedure: <strong>frame-arch</strong> <em>frame</em></dt>
  102. <dd><p>Return the <code>&lt;gdb:architecture&gt;</code> object corresponding to <var>frame</var>&rsquo;s
  103. architecture. See <a href="Architectures-In-Guile.html#Architectures-In-Guile">Architectures In Guile</a>.
  104. </p></dd></dl>
  105. <dl>
  106. <dt><a name="index-frame_002dtype"></a>Scheme Procedure: <strong>frame-type</strong> <em>frame</em></dt>
  107. <dd><p>Return the type of <var>frame</var>. The value can be one of:
  108. </p>
  109. <dl compact="compact">
  110. <dt><code>NORMAL_FRAME</code></dt>
  111. <dd><p>An ordinary stack frame.
  112. </p>
  113. </dd>
  114. <dt><code>DUMMY_FRAME</code></dt>
  115. <dd><p>A fake stack frame that was created by <small>GDB</small> when performing an
  116. inferior function call.
  117. </p>
  118. </dd>
  119. <dt><code>INLINE_FRAME</code></dt>
  120. <dd><p>A frame representing an inlined function. The function was inlined
  121. into a <code>NORMAL_FRAME</code> that is older than this one.
  122. </p>
  123. </dd>
  124. <dt><code>TAILCALL_FRAME</code></dt>
  125. <dd><p>A frame representing a tail call. See <a href="Tail-Call-Frames.html#Tail-Call-Frames">Tail Call Frames</a>.
  126. </p>
  127. </dd>
  128. <dt><code>SIGTRAMP_FRAME</code></dt>
  129. <dd><p>A signal trampoline frame. This is the frame created by the OS when
  130. it calls into a signal handler.
  131. </p>
  132. </dd>
  133. <dt><code>ARCH_FRAME</code></dt>
  134. <dd><p>A fake stack frame representing a cross-architecture call.
  135. </p>
  136. </dd>
  137. <dt><code>SENTINEL_FRAME</code></dt>
  138. <dd><p>This is like <code>NORMAL_FRAME</code>, but it is only used for the
  139. newest frame.
  140. </p></dd>
  141. </dl>
  142. </dd></dl>
  143. <dl>
  144. <dt><a name="index-frame_002dunwind_002dstop_002dreason"></a>Scheme Procedure: <strong>frame-unwind-stop-reason</strong> <em>frame</em></dt>
  145. <dd><p>Return an integer representing the reason why it&rsquo;s not possible to find
  146. more frames toward the outermost frame. Use
  147. <code>unwind-stop-reason-string</code> to convert the value returned by this
  148. function to a string. The value can be one of:
  149. </p>
  150. <dl compact="compact">
  151. <dt><code>FRAME_UNWIND_NO_REASON</code></dt>
  152. <dd><p>No particular reason (older frames should be available).
  153. </p>
  154. </dd>
  155. <dt><code>FRAME_UNWIND_NULL_ID</code></dt>
  156. <dd><p>The previous frame&rsquo;s analyzer returns an invalid result.
  157. </p>
  158. </dd>
  159. <dt><code>FRAME_UNWIND_OUTERMOST</code></dt>
  160. <dd><p>This frame is the outermost.
  161. </p>
  162. </dd>
  163. <dt><code>FRAME_UNWIND_UNAVAILABLE</code></dt>
  164. <dd><p>Cannot unwind further, because that would require knowing the
  165. values of registers or memory that have not been collected.
  166. </p>
  167. </dd>
  168. <dt><code>FRAME_UNWIND_INNER_ID</code></dt>
  169. <dd><p>This frame ID looks like it ought to belong to a NEXT frame,
  170. but we got it for a PREV frame. Normally, this is a sign of
  171. unwinder failure. It could also indicate stack corruption.
  172. </p>
  173. </dd>
  174. <dt><code>FRAME_UNWIND_SAME_ID</code></dt>
  175. <dd><p>This frame has the same ID as the previous one. That means
  176. that unwinding further would almost certainly give us another
  177. frame with exactly the same ID, so break the chain. Normally,
  178. this is a sign of unwinder failure. It could also indicate
  179. stack corruption.
  180. </p>
  181. </dd>
  182. <dt><code>FRAME_UNWIND_NO_SAVED_PC</code></dt>
  183. <dd><p>The frame unwinder did not find any saved PC, but we needed
  184. one to unwind further.
  185. </p>
  186. </dd>
  187. <dt><code>FRAME_UNWIND_MEMORY_ERROR</code></dt>
  188. <dd><p>The frame unwinder caused an error while trying to access memory.
  189. </p>
  190. </dd>
  191. <dt><code>FRAME_UNWIND_FIRST_ERROR</code></dt>
  192. <dd><p>Any stop reason greater or equal to this value indicates some kind
  193. of error. This special value facilitates writing code that tests
  194. for errors in unwinding in a way that will work correctly even if
  195. the list of the other values is modified in future <small>GDB</small>
  196. versions. Using it, you could write:
  197. </p>
  198. <div class="smallexample">
  199. <pre class="smallexample">(define reason (frame-unwind-stop-readon (selected-frame)))
  200. (define reason-str (unwind-stop-reason-string reason))
  201. (if (&gt;= reason FRAME_UNWIND_FIRST_ERROR)
  202. (format #t &quot;An error occured: ~s\n&quot; reason-str))
  203. </pre></div>
  204. </dd>
  205. </dl>
  206. </dd></dl>
  207. <dl>
  208. <dt><a name="index-frame_002dpc"></a>Scheme Procedure: <strong>frame-pc</strong> <em>frame</em></dt>
  209. <dd><p>Return the frame&rsquo;s resume address.
  210. </p></dd></dl>
  211. <dl>
  212. <dt><a name="index-frame_002dblock"></a>Scheme Procedure: <strong>frame-block</strong> <em>frame</em></dt>
  213. <dd><p>Return the frame&rsquo;s code block as a <code>&lt;gdb:block&gt;</code> object.
  214. See <a href="Blocks-In-Guile.html#Blocks-In-Guile">Blocks In Guile</a>.
  215. </p></dd></dl>
  216. <dl>
  217. <dt><a name="index-frame_002dfunction"></a>Scheme Procedure: <strong>frame-function</strong> <em>frame</em></dt>
  218. <dd><p>Return the symbol for the function corresponding to this frame
  219. as a <code>&lt;gdb:symbol&gt;</code> object, or <code>#f</code> if there isn&rsquo;t one.
  220. See <a href="Symbols-In-Guile.html#Symbols-In-Guile">Symbols In Guile</a>.
  221. </p></dd></dl>
  222. <dl>
  223. <dt><a name="index-frame_002dolder"></a>Scheme Procedure: <strong>frame-older</strong> <em>frame</em></dt>
  224. <dd><p>Return the frame that called <var>frame</var>.
  225. </p></dd></dl>
  226. <dl>
  227. <dt><a name="index-frame_002dnewer"></a>Scheme Procedure: <strong>frame-newer</strong> <em>frame</em></dt>
  228. <dd><p>Return the frame called by <var>frame</var>.
  229. </p></dd></dl>
  230. <dl>
  231. <dt><a name="index-frame_002dsal"></a>Scheme Procedure: <strong>frame-sal</strong> <em>frame</em></dt>
  232. <dd><p>Return the frame&rsquo;s <code>&lt;gdb:sal&gt;</code> (symtab and line) object.
  233. See <a href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile">Symbol Tables In Guile</a>.
  234. </p></dd></dl>
  235. <dl>
  236. <dt><a name="index-frame_002dread_002dregister"></a>Scheme Procedure: <strong>frame-read-register</strong> <em>frame register</em></dt>
  237. <dd><p>Return the value of <var>register</var> in <var>frame</var>. <var>register</var>
  238. should be a string, like &lsquo;<samp>pc</samp>&rsquo;.
  239. </p></dd></dl>
  240. <dl>
  241. <dt><a name="index-frame_002dread_002dvar"></a>Scheme Procedure: <strong>frame-read-var</strong> <em>frame variable <span class="roman">[</span>#:block block<span class="roman">]</span></em></dt>
  242. <dd><p>Return the value of <var>variable</var> in <var>frame</var>. If the optional
  243. argument <var>block</var> is provided, search for the variable from that
  244. block; otherwise start at the frame&rsquo;s current block (which is
  245. determined by the frame&rsquo;s current program counter). The
  246. <var>variable</var> must be given as a string or a <code>&lt;gdb:symbol&gt;</code>
  247. object, and <var>block</var> must be a <code>&lt;gdb:block&gt;</code> object.
  248. </p></dd></dl>
  249. <dl>
  250. <dt><a name="index-frame_002dselect"></a>Scheme Procedure: <strong>frame-select</strong> <em>frame</em></dt>
  251. <dd><p>Set <var>frame</var> to be the selected frame. See <a href="Stack.html#Stack">Examining the
  252. Stack</a>.
  253. </p></dd></dl>
  254. <dl>
  255. <dt><a name="index-selected_002dframe"></a>Scheme Procedure: <strong>selected-frame</strong></dt>
  256. <dd><p>Return the selected frame object. See <a href="Selection.html#Selection">Selecting a Frame</a>.
  257. </p></dd></dl>
  258. <dl>
  259. <dt><a name="index-newest_002dframe"></a>Scheme Procedure: <strong>newest-frame</strong></dt>
  260. <dd><p>Return the newest frame object for the selected thread.
  261. </p></dd></dl>
  262. <dl>
  263. <dt><a name="index-unwind_002dstop_002dreason_002dstring"></a>Scheme Procedure: <strong>unwind-stop-reason-string</strong> <em>reason</em></dt>
  264. <dd><p>Return a string explaining the reason why <small>GDB</small> stopped unwinding
  265. frames, as expressed by the given <var>reason</var> code (an integer, see the
  266. <code>frame-unwind-stop-reason</code> procedure above in this section).
  267. </p></dd></dl>
  268. <hr>
  269. <div class="header">
  270. <p>
  271. Next: <a href="Blocks-In-Guile.html#Blocks-In-Guile" accesskey="n" rel="next">Blocks In Guile</a>, Previous: <a href="Objfiles-In-Guile.html#Objfiles-In-Guile" accesskey="p" rel="prev">Objfiles In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile API</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>
  272. </div>
  273. </body>
  274. </html>