Frames-In-Guile.html 13 KB

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