|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
-
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3 or
- any later version published by the Free Software Foundation; with the
- Invariant Sections being "Free Software" and "Free Software Needs
- Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
- and with the Back-Cover Texts as in (a) below.
-
- (a) The FSF's Back-Cover Text is: "You are free to copy and modify
- this GNU Manual. Buying copies from GNU Press supports the FSF in
- developing GNU and promoting software freedom." -->
- <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Blocks In Guile (Debugging with GDB)</title>
-
- <meta name="description" content="Blocks In Guile (Debugging with GDB)">
- <meta name="keywords" content="Blocks In Guile (Debugging with GDB)">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <link href="index.html#Top" rel="start" title="Top">
- <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
- <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
- <link href="Guile-API.html#Guile-API" rel="up" title="Guile API">
- <link href="Symbols-In-Guile.html#Symbols-In-Guile" rel="next" title="Symbols In Guile">
- <link href="Frames-In-Guile.html#Frames-In-Guile" rel="prev" title="Frames In Guile">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.indentedblock {margin-right: 0em}
- blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
- blockquote.smallquotation {font-size: smaller}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- div.smalldisplay {margin-left: 3.2em}
- div.smallexample {margin-left: 3.2em}
- div.smalllisp {margin-left: 3.2em}
- kbd {font-style: oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: inherit; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: inherit; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.nolinebreak {white-space: nowrap}
- span.roman {font-family: initial; font-weight: normal}
- span.sansserif {font-family: sans-serif; font-weight: normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
-
-
- </head>
-
- <body lang="en">
- <a name="Blocks-In-Guile"></a>
- <div class="header">
- <p>
- 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> [<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>
- </div>
- <hr>
- <a name="Accessing-blocks-from-Guile_002e"></a>
- <h4 class="subsubsection">23.3.3.16 Accessing blocks from Guile.</h4>
-
- <a name="index-blocks-in-guile"></a>
- <a name="index-_003cgdb_003ablock_003e"></a>
-
- <p>In <small>GDB</small>, symbols are stored in blocks. A block corresponds
- roughly to a scope in the source code. Blocks are organized
- hierarchically, and are represented individually in Guile as an object
- of type <code><gdb:block></code>. Blocks rely on debugging information being
- available.
- </p>
- <p>A frame has a block. Please see <a href="Frames-In-Guile.html#Frames-In-Guile">Frames In Guile</a>, for a more
- in-depth discussion of frames.
- </p>
- <p>The outermost block is known as the <em>global block</em>. The global
- block typically holds public global variables and functions.
- </p>
- <p>The block nested just inside the global block is the <em>static
- block</em>. The static block typically holds file-scoped variables and
- functions.
- </p>
- <p><small>GDB</small> provides a method to get a block’s superblock, but there
- is currently no way to examine the sub-blocks of a block, or to
- 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>).
- </p>
- <p>Here is a short example that should help explain blocks:
- </p>
- <div class="smallexample">
- <pre class="smallexample">/* This is in the global block. */
- int global;
-
- /* This is in the static block. */
- static int file_scope;
-
- /* 'function' is in the global block, and 'argument' is
- in a block nested inside of 'function'. */
- int function (int argument)
- {
- /* 'local' is in a block inside 'function'. It may or may
- not be in the same block as 'argument'. */
- int local;
-
- {
- /* 'inner' is in a block whose superblock is the one holding
- 'local'. */
- int inner;
-
- /* If this call is expanded by the compiler, you may see
- a nested block here whose function is 'inline_function'
- and whose superblock is the one holding 'inner'. */
- inline_function ();
- }
- }
- </pre></div>
-
- <p>The following block-related procedures are provided by the
- <code>(gdb)</code> module:
- </p>
- <dl>
- <dt><a name="index-block_003f"></a>Scheme Procedure: <strong>block?</strong> <em>object</em></dt>
- <dd><p>Return <code>#t</code> if <var>object</var> is a <code><gdb:block></code> object.
- Otherwise return <code>#f</code>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dvalid_003f"></a>Scheme Procedure: <strong>block-valid?</strong> <em>block</em></dt>
- <dd><p>Returns <code>#t</code> if <code><gdb:block></code> <var>block</var> is valid,
- <code>#f</code> if not. A block object can become invalid if the block it
- refers to doesn’t exist anymore in the inferior. All other
- <code><gdb:block></code> methods will throw an exception if it is invalid at
- the time the procedure is called. The block’s validity is also checked
- during iteration over symbols of the block.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dstart"></a>Scheme Procedure: <strong>block-start</strong> <em>block</em></dt>
- <dd><p>Return the start address of <code><gdb:block></code> <var>block</var>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dend"></a>Scheme Procedure: <strong>block-end</strong> <em>block</em></dt>
- <dd><p>Return the end address of <code><gdb:block></code> <var>block</var>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dfunction"></a>Scheme Procedure: <strong>block-function</strong> <em>block</em></dt>
- <dd><p>Return the name of <code><gdb:block></code> <var>block</var> represented as a
- <code><gdb:symbol></code> object.
- If the block is not named, then <code>#f</code> is returned.
- </p>
- <p>For ordinary function blocks, the superblock is the static block.
- However, you should note that it is possible for a function block to
- have a superblock that is not the static block – for instance this
- happens for an inlined function.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dsuperblock"></a>Scheme Procedure: <strong>block-superblock</strong> <em>block</em></dt>
- <dd><p>Return the block containing <code><gdb:block></code> <var>block</var>.
- If the parent block does not exist, then <code>#f</code> is returned.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dglobal_002dblock"></a>Scheme Procedure: <strong>block-global-block</strong> <em>block</em></dt>
- <dd><p>Return the global block associated with <code><gdb:block></code> <var>block</var>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dstatic_002dblock"></a>Scheme Procedure: <strong>block-static-block</strong> <em>block</em></dt>
- <dd><p>Return the static block associated with <code><gdb:block></code> <var>block</var>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dglobal_003f"></a>Scheme Procedure: <strong>block-global?</strong> <em>block</em></dt>
- <dd><p>Return <code>#t</code> if <code><gdb:block></code> <var>block</var> is a global block.
- Otherwise return <code>#f</code>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dstatic_003f"></a>Scheme Procedure: <strong>block-static?</strong> <em>block</em></dt>
- <dd><p>Return <code>#t</code> if <code><gdb:block></code> <var>block</var> is a static block.
- Otherwise return <code>#f</code>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dsymbols"></a>Scheme Procedure: <strong>block-symbols</strong></dt>
- <dd><p>Return a list of all symbols (as <gdb:symbol> objects) in
- <code><gdb:block></code> <var>block</var>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-make_002dblock_002dsymbols_002diterator"></a>Scheme Procedure: <strong>make-block-symbols-iterator</strong> <em>block</em></dt>
- <dd><p>Return an object of type <code><gdb:iterator></code> that will iterate
- over all symbols of the block.
- Guile programs should not assume that a specific block object will
- always contain a given symbol, since changes in <small>GDB</small> features and
- infrastructure may cause symbols move across blocks in a symbol table.
- See <a href="Iterators-In-Guile.html#Iterators-In-Guile">Iterators In Guile</a>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-block_002dsymbols_002dprogress_003f"></a>Scheme Procedure: <strong>block-symbols-progress?</strong></dt>
- <dd><p>Return #t if the object is a <gdb:block-symbols-progress> object.
- This object would be obtained from the <code>progress</code> element of the
- <code><gdb:iterator></code> object returned by <code>make-block-symbols-iterator</code>.
- </p></dd></dl>
-
- <dl>
- <dt><a name="index-lookup_002dblock"></a>Scheme Procedure: <strong>lookup-block</strong> <em>pc</em></dt>
- <dd><p>Return the innermost <code><gdb:block></code> containing the given <var>pc</var>
- value. If the block cannot be found for the <var>pc</var> value specified,
- the function will return <code>#f</code>.
- </p></dd></dl>
-
- <hr>
- <div class="header">
- <p>
- 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> [<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>
- </div>
-
-
-
- </body>
- </html>
|