1<html lang="en"> 2<head> 3<title>Symbols 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="Blocks-In-Python.html#Blocks-In-Python" title="Blocks In Python"> 10<link rel="next" href="Symbol-Tables-In-Python.html#Symbol-Tables-In-Python" title="Symbol Tables In Python"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 15Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation; with the 20Invariant Sections being ``Free Software'' and ``Free Software Needs 21Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' 22and with the Back-Cover Texts as in (a) below. 23 24(a) The FSF's Back-Cover Text is: ``You are free to copy and modify 25this GNU Manual. Buying copies from GNU Press supports the FSF in 26developing GNU and promoting software freedom.''--> 27<meta http-equiv="Content-Style-Type" content="text/css"> 28<style type="text/css"><!-- 29 pre.display { font-family:inherit } 30 pre.format { font-family:inherit } 31 pre.smalldisplay { font-family:inherit; font-size:smaller } 32 pre.smallformat { font-family:inherit; font-size:smaller } 33 pre.smallexample { font-size:smaller } 34 pre.smalllisp { font-size:smaller } 35 span.sc { font-variant:small-caps } 36 span.roman { font-family:serif; font-weight:normal; } 37 span.sansserif { font-family:sans-serif; font-weight:normal; } 38--></style> 39<link rel="stylesheet" type="text/css" href="../cs.css"> 40</head> 41<body> 42<div class="node"> 43<a name="Symbols-In-Python"></a> 44<p> 45Next: <a rel="next" accesskey="n" href="Symbol-Tables-In-Python.html#Symbol-Tables-In-Python">Symbol Tables In Python</a>, 46Previous: <a rel="previous" accesskey="p" href="Blocks-In-Python.html#Blocks-In-Python">Blocks In Python</a>, 47Up: <a rel="up" accesskey="u" href="Python-API.html#Python-API">Python API</a> 48<hr> 49</div> 50 51<h5 class="subsubsection">23.2.2.17 Python representation of Symbols.</h5> 52 53<p><a name="index-symbols-in-python-1841"></a><a name="index-gdb_002eSymbol-1842"></a> 54<span class="sc">gdb</span> represents every variable, function and type as an 55entry in a symbol table. See <a href="Symbols.html#Symbols">Examining the Symbol Table</a>. 56Similarly, Python represents these symbols in <span class="sc">gdb</span> with the 57<code>gdb.Symbol</code> object. 58 59 <p>The following symbol-related functions are available in the <code>gdb</code> 60module: 61 62 <p><a name="index-gdb_002elookup_005fsymbol-1843"></a> 63 64<div class="defun"> 65— Function: <b>lookup_symbol</b><var> name </var>[<var>block</var>] [<var>domain</var>]<var><a name="index-lookup_005fsymbol-1844"></a></var><br> 66<blockquote><p>This function searches for a symbol by name. The search scope can be 67restricted to the parameters defined in the optional domain and block 68arguments. 69 70 <p><var>name</var> is the name of the symbol. It must be a string. The 71optional <var>block</var> argument restricts the search to symbols visible 72in that <var>block</var>. The <var>block</var> argument must be a 73<code>gdb.Block</code> object. The optional <var>domain</var> argument restricts 74the search to the domain type. The <var>domain</var> argument must be a 75domain constant defined in the <code>gdb</code> module and described later 76in this chapter. 77</p></blockquote></div> 78 79 <p>A <code>gdb.Symbol</code> object has the following attributes: 80 81 <dl> 82 83 <div class="defun"> 84— Instance Variable of Symbol: <b>symtab</b><var><a name="index-symtab-1845"></a></var><br> 85<blockquote> <p>The symbol table in which the symbol appears. This attribute is 86represented as a <code>gdb.Symtab</code> object. See <a href="Symbol-Tables-In-Python.html#Symbol-Tables-In-Python">Symbol Tables In Python</a>. This attribute is not writable. 87</p></blockquote></div> 88 89 <div class="defun"> 90— Instance Variable of Symbol: <b>name</b><var><a name="index-name-1846"></a></var><br> 91<blockquote> <p>The name of the symbol as a string. This attribute is not writable. 92</p></blockquote></div> 93 94 <div class="defun"> 95— Instance Variable of Symbol: <b>linkage_name</b><var><a name="index-linkage_005fname-1847"></a></var><br> 96<blockquote> <p>The name of the symbol, as used by the linker (i.e., may be mangled). 97This attribute is not writable. 98</p></blockquote></div> 99 100 <div class="defun"> 101— Instance Variable of Symbol: <b>print_name</b><var><a name="index-print_005fname-1848"></a></var><br> 102<blockquote> <p>The name of the symbol in a form suitable for output. This is either 103<code>name</code> or <code>linkage_name</code>, depending on whether the user 104asked <span class="sc">gdb</span> to display demangled or mangled names. 105</p></blockquote></div> 106 107 <div class="defun"> 108— Instance Variable of Symbol: <b>addr_class</b><var><a name="index-addr_005fclass-1849"></a></var><br> 109<blockquote> <p>The address class of the symbol. This classifies how to find the value 110of a symbol. Each address class is a constant defined in the 111<code>gdb</code> module and described later in this chapter. 112</p></blockquote></div> 113 114 <div class="defun"> 115— Instance Variable of Symbol: <b>is_argument</b><var><a name="index-is_005fargument-1850"></a></var><br> 116<blockquote> <p><code>True</code> if the symbol is an argument of a function. 117</p></blockquote></div> 118 119 <div class="defun"> 120— Instance Variable of Symbol: <b>is_constant</b><var><a name="index-is_005fconstant-1851"></a></var><br> 121<blockquote> <p><code>True</code> if the symbol is a constant. 122</p></blockquote></div> 123 124 <div class="defun"> 125— Instance Variable of Symbol: <b>is_function</b><var><a name="index-is_005ffunction-1852"></a></var><br> 126<blockquote> <p><code>True</code> if the symbol is a function or a method. 127</p></blockquote></div> 128 129 <div class="defun"> 130— Instance Variable of Symbol: <b>is_variable</b><var><a name="index-is_005fvariable-1853"></a></var><br> 131<blockquote> <p><code>True</code> if the symbol is a variable. 132</p></blockquote></div> 133 </dl> 134 135 <p>The available domain categories in <code>gdb.Symbol</code> are represented 136as constants in the <code>gdb</code> module: 137 138 139<a name="index-SYMBOL_005fUNDEF_005fDOMAIN-1854"></a> 140<a name="index-gdb_002eSYMBOL_005fUNDEF_005fDOMAIN-1855"></a> 141<dl><dt><code>SYMBOL_UNDEF_DOMAIN</code><dd>This is used when a domain has not been discovered or none of the 142following domains apply. This usually indicates an error either 143in the symbol information or in <span class="sc">gdb</span>'s handling of symbols. 144<a name="index-SYMBOL_005fVAR_005fDOMAIN-1856"></a><a name="index-gdb_002eSYMBOL_005fVAR_005fDOMAIN-1857"></a><br><dt><code>SYMBOL_VAR_DOMAIN</code><dd>This domain contains variables, function names, typedef names and enum 145type values. 146<a name="index-SYMBOL_005fSTRUCT_005fDOMAIN-1858"></a><a name="index-gdb_002eSYMBOL_005fSTRUCT_005fDOMAIN-1859"></a><br><dt><code>SYMBOL_STRUCT_DOMAIN</code><dd>This domain holds struct, union and enum type names. 147<a name="index-SYMBOL_005fLABEL_005fDOMAIN-1860"></a><a name="index-gdb_002eSYMBOL_005fLABEL_005fDOMAIN-1861"></a><br><dt><code>SYMBOL_LABEL_DOMAIN</code><dd>This domain contains names of labels (for gotos). 148<a name="index-SYMBOL_005fVARIABLES_005fDOMAIN-1862"></a><a name="index-gdb_002eSYMBOL_005fVARIABLES_005fDOMAIN-1863"></a><br><dt><code>SYMBOL_VARIABLES_DOMAIN</code><dd>This domain holds a subset of the <code>SYMBOLS_VAR_DOMAIN</code>; it 149contains everything minus functions and types. 150<a name="index-SYMBOL_005fFUNCTIONS_005fDOMAIN-1864"></a><a name="index-gdb_002eSYMBOL_005fFUNCTIONS_005fDOMAIN-1865"></a><br><dt><code>SYMBOL_FUNCTION_DOMAIN</code><dd>This domain contains all functions. 151<a name="index-SYMBOL_005fTYPES_005fDOMAIN-1866"></a><a name="index-gdb_002eSYMBOL_005fTYPES_005fDOMAIN-1867"></a><br><dt><code>SYMBOL_TYPES_DOMAIN</code><dd>This domain contains all types. 152</dl> 153 154 <p>The available address class categories in <code>gdb.Symbol</code> are represented 155as constants in the <code>gdb</code> module: 156 157 158<a name="index-SYMBOL_005fLOC_005fUNDEF-1868"></a> 159<a name="index-gdb_002eSYMBOL_005fLOC_005fUNDEF-1869"></a> 160<dl><dt><code>SYMBOL_LOC_UNDEF</code><dd>If this is returned by address class, it indicates an error either in 161the symbol information or in <span class="sc">gdb</span>'s handling of symbols. 162<a name="index-SYMBOL_005fLOC_005fCONST-1870"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fCONST-1871"></a><br><dt><code>SYMBOL_LOC_CONST</code><dd>Value is constant int. 163<a name="index-SYMBOL_005fLOC_005fSTATIC-1872"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fSTATIC-1873"></a><br><dt><code>SYMBOL_LOC_STATIC</code><dd>Value is at a fixed address. 164<a name="index-SYMBOL_005fLOC_005fREGISTER-1874"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fREGISTER-1875"></a><br><dt><code>SYMBOL_LOC_REGISTER</code><dd>Value is in a register. 165<a name="index-SYMBOL_005fLOC_005fARG-1876"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fARG-1877"></a><br><dt><code>SYMBOL_LOC_ARG</code><dd>Value is an argument. This value is at the offset stored within the 166symbol inside the frame's argument list. 167<a name="index-SYMBOL_005fLOC_005fREF_005fARG-1878"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fREF_005fARG-1879"></a><br><dt><code>SYMBOL_LOC_REF_ARG</code><dd>Value address is stored in the frame's argument list. Just like 168<code>LOC_ARG</code> except that the value's address is stored at the 169offset, not the value itself. 170<a name="index-SYMBOL_005fLOC_005fREGPARM_005fADDR-1880"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fREGPARM_005fADDR-1881"></a><br><dt><code>SYMBOL_LOC_REGPARM_ADDR</code><dd>Value is a specified register. Just like <code>LOC_REGISTER</code> except 171the register holds the address of the argument instead of the argument 172itself. 173<a name="index-SYMBOL_005fLOC_005fLOCAL-1882"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fLOCAL-1883"></a><br><dt><code>SYMBOL_LOC_LOCAL</code><dd>Value is a local variable. 174<a name="index-SYMBOL_005fLOC_005fTYPEDEF-1884"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fTYPEDEF-1885"></a><br><dt><code>SYMBOL_LOC_TYPEDEF</code><dd>Value not used. Symbols in the domain <code>SYMBOL_STRUCT_DOMAIN</code> all 175have this class. 176<a name="index-SYMBOL_005fLOC_005fBLOCK-1886"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fBLOCK-1887"></a><br><dt><code>SYMBOL_LOC_BLOCK</code><dd>Value is a block. 177<a name="index-SYMBOL_005fLOC_005fCONST_005fBYTES-1888"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fCONST_005fBYTES-1889"></a><br><dt><code>SYMBOL_LOC_CONST_BYTES</code><dd>Value is a byte-sequence. 178<a name="index-SYMBOL_005fLOC_005fUNRESOLVED-1890"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fUNRESOLVED-1891"></a><br><dt><code>SYMBOL_LOC_UNRESOLVED</code><dd>Value is at a fixed address, but the address of the variable has to be 179determined from the minimal symbol table whenever the variable is 180referenced. 181<a name="index-SYMBOL_005fLOC_005fOPTIMIZED_005fOUT-1892"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fOPTIMIZED_005fOUT-1893"></a><br><dt><code>SYMBOL_LOC_OPTIMIZED_OUT</code><dd>The value does not actually exist in the program. 182<a name="index-SYMBOL_005fLOC_005fCOMPUTED-1894"></a><a name="index-gdb_002eSYMBOL_005fLOC_005fCOMPUTED-1895"></a><br><dt><code>SYMBOL_LOC_COMPUTED</code><dd>The value's address is a computed location. 183</dl> 184 185 </body></html> 186 187