• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/gdb/
1<html lang="en">
2<head>
3<title>Blocks In Python - Debugging with GDB</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Debugging with GDB">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Python-API.html#Python-API" title="Python API">
9<link rel="prev" href="Frames-In-Python.html#Frames-In-Python" title="Frames In Python">
10<link rel="next" href="Symbols-In-Python.html#Symbols-In-Python" title="Symbols In Python">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988-2013 Free Software Foundation, Inc.
14
15Permission is granted to copy, distribute and/or modify this document
16under the terms of the GNU Free Documentation License, Version 1.3 or
17any later version published by the Free Software Foundation; with the
18Invariant Sections being ``Free Software'' and ``Free Software Needs
19Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
20and with the Back-Cover Texts as in (a) below.
21
22(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
23this GNU Manual.  Buying copies from GNU Press supports the FSF in
24developing GNU and promoting software freedom.''
25-->
26<meta http-equiv="Content-Style-Type" content="text/css">
27<style type="text/css"><!--
28  pre.display { font-family:inherit }
29  pre.format  { font-family:inherit }
30  pre.smalldisplay { font-family:inherit; font-size:smaller }
31  pre.smallformat  { font-family:inherit; font-size:smaller }
32  pre.smallexample { font-size:smaller }
33  pre.smalllisp    { font-size:smaller }
34  span.sc    { font-variant:small-caps }
35  span.roman { font-family:serif; font-weight:normal; } 
36  span.sansserif { font-family:sans-serif; font-weight:normal; } 
37--></style>
38<link rel="stylesheet" type="text/css" href="../cs.css">
39</head>
40<body>
41<div class="node">
42<a name="Blocks-In-Python"></a>
43<p>
44Next:&nbsp;<a rel="next" accesskey="n" href="Symbols-In-Python.html#Symbols-In-Python">Symbols In Python</a>,
45Previous:&nbsp;<a rel="previous" accesskey="p" href="Frames-In-Python.html#Frames-In-Python">Frames In Python</a>,
46Up:&nbsp;<a rel="up" accesskey="u" href="Python-API.html#Python-API">Python API</a>
47<hr>
48</div>
49
50<h5 class="subsubsection">23.2.2.21 Accessing blocks from Python.</h5>
51
52<p><a name="index-blocks-in-python-2057"></a><a name="index-gdb_002eBlock-2058"></a>
53In <span class="sc">gdb</span>, symbols are stored in blocks.  A block corresponds
54roughly to a scope in the source code.  Blocks are organized
55hierarchically, and are represented individually in Python as a
56<code>gdb.Block</code>.  Blocks rely on debugging information being
57available.
58
59   <p>A frame has a block.  Please see <a href="Frames-In-Python.html#Frames-In-Python">Frames In Python</a>, for a more
60in-depth discussion of frames.
61
62   <p>The outermost block is known as the <dfn>global block</dfn>.  The global
63block typically holds public global variables and functions.
64
65   <p>The block nested just inside the global block is the <dfn>static
66block</dfn>.  The static block typically holds file-scoped variables and
67functions.
68
69   <p><span class="sc">gdb</span> provides a method to get a block's superblock, but there
70is currently no way to examine the sub-blocks of a block, or to
71iterate over all the blocks in a symbol table (see <a href="Symbol-Tables-In-Python.html#Symbol-Tables-In-Python">Symbol Tables In Python</a>).
72
73   <p>Here is a short example that should help explain blocks:
74
75<pre class="smallexample">     /* This is in the global block.  */
76     int global;
77     
78     /* This is in the static block.  */
79     static int file_scope;
80     
81     /* 'function' is in the global block, and 'argument' is
82        in a block nested inside of 'function'.  */
83     int function (int argument)
84     {
85       /* 'local' is in a block inside 'function'.  It may or may
86          not be in the same block as 'argument'.  */
87       int local;
88     
89       {
90          /* 'inner' is in a block whose superblock is the one holding
91             'local'.  */
92          int inner;
93     
94          /* If this call is expanded by the compiler, you may see
95             a nested block here whose function is 'inline_function'
96             and whose superblock is the one holding 'inner'.  */
97          inline_function ();
98       }
99     }
100</pre>
101   <p>A <code>gdb.Block</code> is iterable.  The iterator returns the symbols
102(see <a href="Symbols-In-Python.html#Symbols-In-Python">Symbols In Python</a>) local to the block.  Python programs
103should not assume that a specific block object will always contain a
104given symbol, since changes in <span class="sc">gdb</span> features and
105infrastructure may cause symbols move across blocks in a symbol
106table.
107
108   <p>The following block-related functions are available in the <code>gdb</code>
109module:
110
111   <p><a name="index-gdb_002eblock_005ffor_005fpc-2059"></a>
112
113<div class="defun">
114&mdash; Function: <b>gdb.block_for_pc</b> (<var>pc</var>)<var><a name="index-gdb_002eblock_005ffor_005fpc-2060"></a></var><br>
115<blockquote><p>Return the innermost <code>gdb.Block</code> containing the given <var>pc</var>
116value.  If the block cannot be found for the <var>pc</var> value specified,
117the function will return <code>None</code>. 
118</p></blockquote></div>
119
120   <p>A <code>gdb.Block</code> object has the following methods:
121
122<div class="defun">
123&mdash; Function: <b>Block.is_valid</b> ()<var><a name="index-Block_002eis_005fvalid-2061"></a></var><br>
124<blockquote><p>Returns <code>True</code> if the <code>gdb.Block</code> object is valid,
125<code>False</code> if not.  A block object can become invalid if the block it
126refers to doesn't exist anymore in the inferior.  All other
127<code>gdb.Block</code> methods will throw an exception if it is invalid at
128the time the method is called.  The block's validity is also checked
129during iteration over symbols of the block. 
130</p></blockquote></div>
131
132   <p>A <code>gdb.Block</code> object has the following attributes:
133
134<div class="defun">
135&mdash; Variable: <b>Block.start</b><var><a name="index-Block_002estart-2062"></a></var><br>
136<blockquote><p>The start address of the block.  This attribute is not writable. 
137</p></blockquote></div>
138
139<div class="defun">
140&mdash; Variable: <b>Block.end</b><var><a name="index-Block_002eend-2063"></a></var><br>
141<blockquote><p>The end address of the block.  This attribute is not writable. 
142</p></blockquote></div>
143
144<div class="defun">
145&mdash; Variable: <b>Block.function</b><var><a name="index-Block_002efunction-2064"></a></var><br>
146<blockquote><p>The name of the block represented as a <code>gdb.Symbol</code>.  If the
147block is not named, then this attribute holds <code>None</code>.  This
148attribute is not writable.
149
150        <p>For ordinary function blocks, the superblock is the static block. 
151However, you should note that it is possible for a function block to
152have a superblock that is not the static block &ndash; for instance this
153happens for an inlined function. 
154</p></blockquote></div>
155
156<div class="defun">
157&mdash; Variable: <b>Block.superblock</b><var><a name="index-Block_002esuperblock-2065"></a></var><br>
158<blockquote><p>The block containing this block.  If this parent block does not exist,
159this attribute holds <code>None</code>.  This attribute is not writable. 
160</p></blockquote></div>
161
162<div class="defun">
163&mdash; Variable: <b>Block.global_block</b><var><a name="index-Block_002eglobal_005fblock-2066"></a></var><br>
164<blockquote><p>The global block associated with this block.  This attribute is not
165writable. 
166</p></blockquote></div>
167
168<div class="defun">
169&mdash; Variable: <b>Block.static_block</b><var><a name="index-Block_002estatic_005fblock-2067"></a></var><br>
170<blockquote><p>The static block associated with this block.  This attribute is not
171writable. 
172</p></blockquote></div>
173
174<div class="defun">
175&mdash; Variable: <b>Block.is_global</b><var><a name="index-Block_002eis_005fglobal-2068"></a></var><br>
176<blockquote><p><code>True</code> if the <code>gdb.Block</code> object is a global block,
177<code>False</code> if not.  This attribute is not
178writable. 
179</p></blockquote></div>
180
181<div class="defun">
182&mdash; Variable: <b>Block.is_static</b><var><a name="index-Block_002eis_005fstatic-2069"></a></var><br>
183<blockquote><p><code>True</code> if the <code>gdb.Block</code> object is a static block,
184<code>False</code> if not.  This attribute is not writable. 
185</p></blockquote></div>
186
187   </body></html>
188
189