• 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>Types 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="Values-From-Inferior.html#Values-From-Inferior" title="Values From Inferior">
10<link rel="next" href="Pretty-Printing-API.html#Pretty-Printing-API" title="Pretty Printing API">
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="Types-In-Python"></a>
43<p>
44Next:&nbsp;<a rel="next" accesskey="n" href="Pretty-Printing-API.html#Pretty-Printing-API">Pretty Printing API</a>,
45Previous:&nbsp;<a rel="previous" accesskey="p" href="Values-From-Inferior.html#Values-From-Inferior">Values From Inferior</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.4 Types In Python</h5>
51
52<p><a name="index-types-in-Python-1799"></a><a name="index-Python_002c-working-with-types-1800"></a>
53<a name="index-gdb_002eType-1801"></a><span class="sc">gdb</span> represents types from the inferior using the class
54<code>gdb.Type</code>.
55
56   <p>The following type-related functions are available in the <code>gdb</code>
57module:
58
59   <p><a name="index-gdb_002elookup_005ftype-1802"></a>
60
61<div class="defun">
62&mdash; Function: <b>gdb.lookup_type</b> (<var>name </var><span class="roman">[</span><var>, block</var><span class="roman">]</span>)<var><a name="index-gdb_002elookup_005ftype-1803"></a></var><br>
63<blockquote><p>This function looks up a type by name.  <var>name</var> is the name of the
64type to look up.  It must be a string.
65
66        <p>If <var>block</var> is given, then <var>name</var> is looked up in that scope. 
67Otherwise, it is searched for globally.
68
69        <p>Ordinarily, this function will return an instance of <code>gdb.Type</code>. 
70If the named type cannot be found, it will throw an exception. 
71</p></blockquote></div>
72
73   <p>If the type is a structure or class type, or an enum type, the fields
74of that type can be accessed using the Python <dfn>dictionary syntax</dfn>. 
75For example, if <code>some_type</code> is a <code>gdb.Type</code> instance holding
76a structure type, you can access its <code>foo</code> field with:
77
78<pre class="smallexample">     bar = some_type['foo']
79</pre>
80   <p><code>bar</code> will be a <code>gdb.Field</code> object; see below under the
81description of the <code>Type.fields</code> method for a description of the
82<code>gdb.Field</code> class.
83
84   <p>An instance of <code>Type</code> has the following attributes:
85
86<div class="defun">
87&mdash; Variable: <b>Type.code</b><var><a name="index-Type_002ecode-1804"></a></var><br>
88<blockquote><p>The type code for this type.  The type code will be one of the
89<code>TYPE_CODE_</code> constants defined below. 
90</p></blockquote></div>
91
92<div class="defun">
93&mdash; Variable: <b>Type.sizeof</b><var><a name="index-Type_002esizeof-1805"></a></var><br>
94<blockquote><p>The size of this type, in target <code>char</code> units.  Usually, a
95target's <code>char</code> type will be an 8-bit byte.  However, on some
96unusual platforms, this type may have a different size. 
97</p></blockquote></div>
98
99<div class="defun">
100&mdash; Variable: <b>Type.tag</b><var><a name="index-Type_002etag-1806"></a></var><br>
101<blockquote><p>The tag name for this type.  The tag name is the name after
102<code>struct</code>, <code>union</code>, or <code>enum</code> in C and C<tt>++</tt>; not all
103languages have this concept.  If this type has no tag name, then
104<code>None</code> is returned. 
105</p></blockquote></div>
106
107   <p>The following methods are provided:
108
109<div class="defun">
110&mdash; Function: <b>Type.fields</b> ()<var><a name="index-Type_002efields-1807"></a></var><br>
111<blockquote><p>For structure and union types, this method returns the fields.  Range
112types have two fields, the minimum and maximum values.  Enum types
113have one field per enum constant.  Function and method types have one
114field per parameter.  The base types of C<tt>++</tt> classes are also
115represented as fields.  If the type has no fields, or does not fit
116into one of these categories, an empty sequence will be returned.
117
118        <p>Each field is a <code>gdb.Field</code> object, with some pre-defined attributes:
119          <dl>
120<dt><code>bitpos</code><dd>This attribute is not available for <code>static</code> fields (as in
121C<tt>++</tt> or Java).  For non-<code>static</code> fields, the value is the bit
122position of the field.  For <code>enum</code> fields, the value is the
123enumeration member's integer representation.
124
125          <br><dt><code>name</code><dd>The name of the field, or <code>None</code> for anonymous fields.
126
127          <br><dt><code>artificial</code><dd>This is <code>True</code> if the field is artificial, usually meaning that
128it was provided by the compiler and not the user.  This attribute is
129always provided, and is <code>False</code> if the field is not artificial.
130
131          <br><dt><code>is_base_class</code><dd>This is <code>True</code> if the field represents a base class of a C<tt>++</tt>
132structure.  This attribute is always provided, and is <code>False</code>
133if the field is not a base class of the type that is the argument of
134<code>fields</code>, or if that type was not a C<tt>++</tt> class.
135
136          <br><dt><code>bitsize</code><dd>If the field is packed, or is a bitfield, then this will have a
137non-zero value, which is the size of the field in bits.  Otherwise,
138this will be zero; in this case the field's size is given by its type.
139
140          <br><dt><code>type</code><dd>The type of the field.  This is usually an instance of <code>Type</code>,
141but it can be <code>None</code> in some situations. 
142</dl>
143        </p></blockquote></div>
144
145<div class="defun">
146&mdash; Function: <b>Type.array</b> (<var>n1 </var><span class="roman">[</span><var>, n2</var><span class="roman">]</span>)<var><a name="index-Type_002earray-1808"></a></var><br>
147<blockquote><p>Return a new <code>gdb.Type</code> object which represents an array of this
148type.  If one argument is given, it is the inclusive upper bound of
149the array; in this case the lower bound is zero.  If two arguments are
150given, the first argument is the lower bound of the array, and the
151second argument is the upper bound of the array.  An array's length
152must not be negative, but the bounds can be. 
153</p></blockquote></div>
154
155<div class="defun">
156&mdash; Function: <b>Type.vector</b> (<var>n1 </var><span class="roman">[</span><var>, n2</var><span class="roman">]</span>)<var><a name="index-Type_002evector-1809"></a></var><br>
157<blockquote><p>Return a new <code>gdb.Type</code> object which represents a vector of this
158type.  If one argument is given, it is the inclusive upper bound of
159the vector; in this case the lower bound is zero.  If two arguments are
160given, the first argument is the lower bound of the vector, and the
161second argument is the upper bound of the vector.  A vector's length
162must not be negative, but the bounds can be.
163
164        <p>The difference between an <code>array</code> and a <code>vector</code> is that
165arrays behave like in C: when used in expressions they decay to a pointer
166to the first element whereas vectors are treated as first class values. 
167</p></blockquote></div>
168
169<div class="defun">
170&mdash; Function: <b>Type.const</b> ()<var><a name="index-Type_002econst-1810"></a></var><br>
171<blockquote><p>Return a new <code>gdb.Type</code> object which represents a
172<code>const</code>-qualified variant of this type. 
173</p></blockquote></div>
174
175<div class="defun">
176&mdash; Function: <b>Type.volatile</b> ()<var><a name="index-Type_002evolatile-1811"></a></var><br>
177<blockquote><p>Return a new <code>gdb.Type</code> object which represents a
178<code>volatile</code>-qualified variant of this type. 
179</p></blockquote></div>
180
181<div class="defun">
182&mdash; Function: <b>Type.unqualified</b> ()<var><a name="index-Type_002eunqualified-1812"></a></var><br>
183<blockquote><p>Return a new <code>gdb.Type</code> object which represents an unqualified
184variant of this type.  That is, the result is neither <code>const</code> nor
185<code>volatile</code>. 
186</p></blockquote></div>
187
188<div class="defun">
189&mdash; Function: <b>Type.range</b> ()<var><a name="index-Type_002erange-1813"></a></var><br>
190<blockquote><p>Return a Python <code>Tuple</code> object that contains two elements: the
191low bound of the argument type and the high bound of that type.  If
192the type does not have a range, <span class="sc">gdb</span> will raise a
193<code>gdb.error</code> exception (see <a href="Exception-Handling.html#Exception-Handling">Exception Handling</a>). 
194</p></blockquote></div>
195
196<div class="defun">
197&mdash; Function: <b>Type.reference</b> ()<var><a name="index-Type_002ereference-1814"></a></var><br>
198<blockquote><p>Return a new <code>gdb.Type</code> object which represents a reference to this
199type. 
200</p></blockquote></div>
201
202<div class="defun">
203&mdash; Function: <b>Type.pointer</b> ()<var><a name="index-Type_002epointer-1815"></a></var><br>
204<blockquote><p>Return a new <code>gdb.Type</code> object which represents a pointer to this
205type. 
206</p></blockquote></div>
207
208<div class="defun">
209&mdash; Function: <b>Type.strip_typedefs</b> ()<var><a name="index-Type_002estrip_005ftypedefs-1816"></a></var><br>
210<blockquote><p>Return a new <code>gdb.Type</code> that represents the real type,
211after removing all layers of typedefs. 
212</p></blockquote></div>
213
214<div class="defun">
215&mdash; Function: <b>Type.target</b> ()<var><a name="index-Type_002etarget-1817"></a></var><br>
216<blockquote><p>Return a new <code>gdb.Type</code> object which represents the target type
217of this type.
218
219        <p>For a pointer type, the target type is the type of the pointed-to
220object.  For an array type (meaning C-like arrays), the target type is
221the type of the elements of the array.  For a function or method type,
222the target type is the type of the return value.  For a complex type,
223the target type is the type of the elements.  For a typedef, the
224target type is the aliased type.
225
226        <p>If the type does not have a target, this method will throw an
227exception. 
228</p></blockquote></div>
229
230<div class="defun">
231&mdash; Function: <b>Type.template_argument</b> (<var>n </var><span class="roman">[</span><var>, block</var><span class="roman">]</span>)<var><a name="index-Type_002etemplate_005fargument-1818"></a></var><br>
232<blockquote><p>If this <code>gdb.Type</code> is an instantiation of a template, this will
233return a new <code>gdb.Type</code> which represents the type of the
234<var>n</var>th template argument.
235
236        <p>If this <code>gdb.Type</code> is not a template type, this will throw an
237exception.  Ordinarily, only C<tt>++</tt> code will have template types.
238
239        <p>If <var>block</var> is given, then <var>name</var> is looked up in that scope. 
240Otherwise, it is searched for globally. 
241</p></blockquote></div>
242
243   <p>Each type has a code, which indicates what category this type falls
244into.  The available type categories are represented by constants
245defined in the <code>gdb</code> module:
246
247     
248<a name="index-TYPE_005fCODE_005fPTR-1819"></a>
249<a name="index-gdb_002eTYPE_005fCODE_005fPTR-1820"></a>
250<dl><dt><code>gdb.TYPE_CODE_PTR</code><dd>The type is a pointer.
251
252     <p><a name="index-TYPE_005fCODE_005fARRAY-1821"></a><a name="index-gdb_002eTYPE_005fCODE_005fARRAY-1822"></a><br><dt><code>gdb.TYPE_CODE_ARRAY</code><dd>The type is an array.
253
254     <p><a name="index-TYPE_005fCODE_005fSTRUCT-1823"></a><a name="index-gdb_002eTYPE_005fCODE_005fSTRUCT-1824"></a><br><dt><code>gdb.TYPE_CODE_STRUCT</code><dd>The type is a structure.
255
256     <p><a name="index-TYPE_005fCODE_005fUNION-1825"></a><a name="index-gdb_002eTYPE_005fCODE_005fUNION-1826"></a><br><dt><code>gdb.TYPE_CODE_UNION</code><dd>The type is a union.
257
258     <p><a name="index-TYPE_005fCODE_005fENUM-1827"></a><a name="index-gdb_002eTYPE_005fCODE_005fENUM-1828"></a><br><dt><code>gdb.TYPE_CODE_ENUM</code><dd>The type is an enum.
259
260     <p><a name="index-TYPE_005fCODE_005fFLAGS-1829"></a><a name="index-gdb_002eTYPE_005fCODE_005fFLAGS-1830"></a><br><dt><code>gdb.TYPE_CODE_FLAGS</code><dd>A bit flags type, used for things such as status registers.
261
262     <p><a name="index-TYPE_005fCODE_005fFUNC-1831"></a><a name="index-gdb_002eTYPE_005fCODE_005fFUNC-1832"></a><br><dt><code>gdb.TYPE_CODE_FUNC</code><dd>The type is a function.
263
264     <p><a name="index-TYPE_005fCODE_005fINT-1833"></a><a name="index-gdb_002eTYPE_005fCODE_005fINT-1834"></a><br><dt><code>gdb.TYPE_CODE_INT</code><dd>The type is an integer type.
265
266     <p><a name="index-TYPE_005fCODE_005fFLT-1835"></a><a name="index-gdb_002eTYPE_005fCODE_005fFLT-1836"></a><br><dt><code>gdb.TYPE_CODE_FLT</code><dd>A floating point type.
267
268     <p><a name="index-TYPE_005fCODE_005fVOID-1837"></a><a name="index-gdb_002eTYPE_005fCODE_005fVOID-1838"></a><br><dt><code>gdb.TYPE_CODE_VOID</code><dd>The special type <code>void</code>.
269
270     <p><a name="index-TYPE_005fCODE_005fSET-1839"></a><a name="index-gdb_002eTYPE_005fCODE_005fSET-1840"></a><br><dt><code>gdb.TYPE_CODE_SET</code><dd>A Pascal set type.
271
272     <p><a name="index-TYPE_005fCODE_005fRANGE-1841"></a><a name="index-gdb_002eTYPE_005fCODE_005fRANGE-1842"></a><br><dt><code>gdb.TYPE_CODE_RANGE</code><dd>A range type, that is, an integer type with bounds.
273
274     <p><a name="index-TYPE_005fCODE_005fSTRING-1843"></a><a name="index-gdb_002eTYPE_005fCODE_005fSTRING-1844"></a><br><dt><code>gdb.TYPE_CODE_STRING</code><dd>A string type.  Note that this is only used for certain languages with
275language-defined string types; C strings are not represented this way.
276
277     <p><a name="index-TYPE_005fCODE_005fBITSTRING-1845"></a><a name="index-gdb_002eTYPE_005fCODE_005fBITSTRING-1846"></a><br><dt><code>gdb.TYPE_CODE_BITSTRING</code><dd>A string of bits.  It is deprecated.
278
279     <p><a name="index-TYPE_005fCODE_005fERROR-1847"></a><a name="index-gdb_002eTYPE_005fCODE_005fERROR-1848"></a><br><dt><code>gdb.TYPE_CODE_ERROR</code><dd>An unknown or erroneous type.
280
281     <p><a name="index-TYPE_005fCODE_005fMETHOD-1849"></a><a name="index-gdb_002eTYPE_005fCODE_005fMETHOD-1850"></a><br><dt><code>gdb.TYPE_CODE_METHOD</code><dd>A method type, as found in C<tt>++</tt> or Java.
282
283     <p><a name="index-TYPE_005fCODE_005fMETHODPTR-1851"></a><a name="index-gdb_002eTYPE_005fCODE_005fMETHODPTR-1852"></a><br><dt><code>gdb.TYPE_CODE_METHODPTR</code><dd>A pointer-to-member-function.
284
285     <p><a name="index-TYPE_005fCODE_005fMEMBERPTR-1853"></a><a name="index-gdb_002eTYPE_005fCODE_005fMEMBERPTR-1854"></a><br><dt><code>gdb.TYPE_CODE_MEMBERPTR</code><dd>A pointer-to-member.
286
287     <p><a name="index-TYPE_005fCODE_005fREF-1855"></a><a name="index-gdb_002eTYPE_005fCODE_005fREF-1856"></a><br><dt><code>gdb.TYPE_CODE_REF</code><dd>A reference type.
288
289     <p><a name="index-TYPE_005fCODE_005fCHAR-1857"></a><a name="index-gdb_002eTYPE_005fCODE_005fCHAR-1858"></a><br><dt><code>gdb.TYPE_CODE_CHAR</code><dd>A character type.
290
291     <p><a name="index-TYPE_005fCODE_005fBOOL-1859"></a><a name="index-gdb_002eTYPE_005fCODE_005fBOOL-1860"></a><br><dt><code>gdb.TYPE_CODE_BOOL</code><dd>A boolean type.
292
293     <p><a name="index-TYPE_005fCODE_005fCOMPLEX-1861"></a><a name="index-gdb_002eTYPE_005fCODE_005fCOMPLEX-1862"></a><br><dt><code>gdb.TYPE_CODE_COMPLEX</code><dd>A complex float type.
294
295     <p><a name="index-TYPE_005fCODE_005fTYPEDEF-1863"></a><a name="index-gdb_002eTYPE_005fCODE_005fTYPEDEF-1864"></a><br><dt><code>gdb.TYPE_CODE_TYPEDEF</code><dd>A typedef to some other type.
296
297     <p><a name="index-TYPE_005fCODE_005fNAMESPACE-1865"></a><a name="index-gdb_002eTYPE_005fCODE_005fNAMESPACE-1866"></a><br><dt><code>gdb.TYPE_CODE_NAMESPACE</code><dd>A C<tt>++</tt> namespace.
298
299     <p><a name="index-TYPE_005fCODE_005fDECFLOAT-1867"></a><a name="index-gdb_002eTYPE_005fCODE_005fDECFLOAT-1868"></a><br><dt><code>gdb.TYPE_CODE_DECFLOAT</code><dd>A decimal floating point type.
300
301     <p><a name="index-TYPE_005fCODE_005fINTERNAL_005fFUNCTION-1869"></a><a name="index-gdb_002eTYPE_005fCODE_005fINTERNAL_005fFUNCTION-1870"></a><br><dt><code>gdb.TYPE_CODE_INTERNAL_FUNCTION</code><dd>A function internal to <span class="sc">gdb</span>.  This is the type used to represent
302convenience functions. 
303</dl>
304
305   <p>Further support for types is provided in the <code>gdb.types</code>
306Python module (see <a href="gdb_002etypes.html#gdb_002etypes">gdb.types</a>).
307
308   </body></html>
309
310