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

234 lines
10KB

  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>Blocks In Guile (Debugging with GDB)</title>
  17. <meta name="description" content="Blocks In Guile (Debugging with GDB)">
  18. <meta name="keywords" content="Blocks 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="Symbols-In-Guile.html#Symbols-In-Guile" rel="next" title="Symbols In Guile">
  27. <link href="Frames-In-Guile.html#Frames-In-Guile" rel="prev" title="Frames 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="Blocks-In-Guile"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Symbols-In-Guile.html#Symbols-In-Guile" accesskey="n" rel="next">Symbols In Guile</a>, Previous: <a href="Frames-In-Guile.html#Frames-In-Guile" accesskey="p" rel="prev">Frames 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-blocks-from-Guile_002e"></a>
  64. <h4 class="subsubsection">23.3.3.16 Accessing blocks from Guile.</h4>
  65. <a name="index-blocks-in-guile"></a>
  66. <a name="index-_003cgdb_003ablock_003e"></a>
  67. <p>In <small>GDB</small>, symbols are stored in blocks. A block corresponds
  68. roughly to a scope in the source code. Blocks are organized
  69. hierarchically, and are represented individually in Guile as an object
  70. of type <code>&lt;gdb:block&gt;</code>. Blocks rely on debugging information being
  71. available.
  72. </p>
  73. <p>A frame has a block. Please see <a href="Frames-In-Guile.html#Frames-In-Guile">Frames In Guile</a>, for a more
  74. in-depth discussion of frames.
  75. </p>
  76. <p>The outermost block is known as the <em>global block</em>. The global
  77. block typically holds public global variables and functions.
  78. </p>
  79. <p>The block nested just inside the global block is the <em>static
  80. block</em>. The static block typically holds file-scoped variables and
  81. functions.
  82. </p>
  83. <p><small>GDB</small> provides a method to get a block&rsquo;s superblock, but there
  84. is currently no way to examine the sub-blocks of a block, or to
  85. iterate over all the blocks in a symbol table (see <a href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile">Symbol Tables In Guile</a>).
  86. </p>
  87. <p>Here is a short example that should help explain blocks:
  88. </p>
  89. <div class="smallexample">
  90. <pre class="smallexample">/* This is in the global block. */
  91. int global;
  92. /* This is in the static block. */
  93. static int file_scope;
  94. /* 'function' is in the global block, and 'argument' is
  95. in a block nested inside of 'function'. */
  96. int function (int argument)
  97. {
  98. /* 'local' is in a block inside 'function'. It may or may
  99. not be in the same block as 'argument'. */
  100. int local;
  101. {
  102. /* 'inner' is in a block whose superblock is the one holding
  103. 'local'. */
  104. int inner;
  105. /* If this call is expanded by the compiler, you may see
  106. a nested block here whose function is 'inline_function'
  107. and whose superblock is the one holding 'inner'. */
  108. inline_function ();
  109. }
  110. }
  111. </pre></div>
  112. <p>The following block-related procedures are provided by the
  113. <code>(gdb)</code> module:
  114. </p>
  115. <dl>
  116. <dt><a name="index-block_003f"></a>Scheme Procedure: <strong>block?</strong> <em>object</em></dt>
  117. <dd><p>Return <code>#t</code> if <var>object</var> is a <code>&lt;gdb:block&gt;</code> object.
  118. Otherwise return <code>#f</code>.
  119. </p></dd></dl>
  120. <dl>
  121. <dt><a name="index-block_002dvalid_003f"></a>Scheme Procedure: <strong>block-valid?</strong> <em>block</em></dt>
  122. <dd><p>Returns <code>#t</code> if <code>&lt;gdb:block&gt;</code> <var>block</var> is valid,
  123. <code>#f</code> if not. A block object can become invalid if the block it
  124. refers to doesn&rsquo;t exist anymore in the inferior. All other
  125. <code>&lt;gdb:block&gt;</code> methods will throw an exception if it is invalid at
  126. the time the procedure is called. The block&rsquo;s validity is also checked
  127. during iteration over symbols of the block.
  128. </p></dd></dl>
  129. <dl>
  130. <dt><a name="index-block_002dstart"></a>Scheme Procedure: <strong>block-start</strong> <em>block</em></dt>
  131. <dd><p>Return the start address of <code>&lt;gdb:block&gt;</code> <var>block</var>.
  132. </p></dd></dl>
  133. <dl>
  134. <dt><a name="index-block_002dend"></a>Scheme Procedure: <strong>block-end</strong> <em>block</em></dt>
  135. <dd><p>Return the end address of <code>&lt;gdb:block&gt;</code> <var>block</var>.
  136. </p></dd></dl>
  137. <dl>
  138. <dt><a name="index-block_002dfunction"></a>Scheme Procedure: <strong>block-function</strong> <em>block</em></dt>
  139. <dd><p>Return the name of <code>&lt;gdb:block&gt;</code> <var>block</var> represented as a
  140. <code>&lt;gdb:symbol&gt;</code> object.
  141. If the block is not named, then <code>#f</code> is returned.
  142. </p>
  143. <p>For ordinary function blocks, the superblock is the static block.
  144. However, you should note that it is possible for a function block to
  145. have a superblock that is not the static block &ndash; for instance this
  146. happens for an inlined function.
  147. </p></dd></dl>
  148. <dl>
  149. <dt><a name="index-block_002dsuperblock"></a>Scheme Procedure: <strong>block-superblock</strong> <em>block</em></dt>
  150. <dd><p>Return the block containing <code>&lt;gdb:block&gt;</code> <var>block</var>.
  151. If the parent block does not exist, then <code>#f</code> is returned.
  152. </p></dd></dl>
  153. <dl>
  154. <dt><a name="index-block_002dglobal_002dblock"></a>Scheme Procedure: <strong>block-global-block</strong> <em>block</em></dt>
  155. <dd><p>Return the global block associated with <code>&lt;gdb:block&gt;</code> <var>block</var>.
  156. </p></dd></dl>
  157. <dl>
  158. <dt><a name="index-block_002dstatic_002dblock"></a>Scheme Procedure: <strong>block-static-block</strong> <em>block</em></dt>
  159. <dd><p>Return the static block associated with <code>&lt;gdb:block&gt;</code> <var>block</var>.
  160. </p></dd></dl>
  161. <dl>
  162. <dt><a name="index-block_002dglobal_003f"></a>Scheme Procedure: <strong>block-global?</strong> <em>block</em></dt>
  163. <dd><p>Return <code>#t</code> if <code>&lt;gdb:block&gt;</code> <var>block</var> is a global block.
  164. Otherwise return <code>#f</code>.
  165. </p></dd></dl>
  166. <dl>
  167. <dt><a name="index-block_002dstatic_003f"></a>Scheme Procedure: <strong>block-static?</strong> <em>block</em></dt>
  168. <dd><p>Return <code>#t</code> if <code>&lt;gdb:block&gt;</code> <var>block</var> is a static block.
  169. Otherwise return <code>#f</code>.
  170. </p></dd></dl>
  171. <dl>
  172. <dt><a name="index-block_002dsymbols"></a>Scheme Procedure: <strong>block-symbols</strong></dt>
  173. <dd><p>Return a list of all symbols (as &lt;gdb:symbol&gt; objects) in
  174. <code>&lt;gdb:block&gt;</code> <var>block</var>.
  175. </p></dd></dl>
  176. <dl>
  177. <dt><a name="index-make_002dblock_002dsymbols_002diterator"></a>Scheme Procedure: <strong>make-block-symbols-iterator</strong> <em>block</em></dt>
  178. <dd><p>Return an object of type <code>&lt;gdb:iterator&gt;</code> that will iterate
  179. over all symbols of the block.
  180. Guile programs should not assume that a specific block object will
  181. always contain a given symbol, since changes in <small>GDB</small> features and
  182. infrastructure may cause symbols move across blocks in a symbol table.
  183. See <a href="Iterators-In-Guile.html#Iterators-In-Guile">Iterators In Guile</a>.
  184. </p></dd></dl>
  185. <dl>
  186. <dt><a name="index-block_002dsymbols_002dprogress_003f"></a>Scheme Procedure: <strong>block-symbols-progress?</strong></dt>
  187. <dd><p>Return #t if the object is a &lt;gdb:block-symbols-progress&gt; object.
  188. This object would be obtained from the <code>progress</code> element of the
  189. <code>&lt;gdb:iterator&gt;</code> object returned by <code>make-block-symbols-iterator</code>.
  190. </p></dd></dl>
  191. <dl>
  192. <dt><a name="index-lookup_002dblock"></a>Scheme Procedure: <strong>lookup-block</strong> <em>pc</em></dt>
  193. <dd><p>Return the innermost <code>&lt;gdb:block&gt;</code> containing the given <var>pc</var>
  194. value. If the block cannot be found for the <var>pc</var> value specified,
  195. the function will return <code>#f</code>.
  196. </p></dd></dl>
  197. <hr>
  198. <div class="header">
  199. <p>
  200. Next: <a href="Symbols-In-Guile.html#Symbols-In-Guile" accesskey="n" rel="next">Symbols In Guile</a>, Previous: <a href="Frames-In-Guile.html#Frames-In-Guile" accesskey="p" rel="prev">Frames 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>
  201. </div>
  202. </body>
  203. </html>