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-2021 Free Software Foundation, Inc.
4
5Permission is granted to copy, distribute and/or modify this document
6under the terms of the GNU Free Documentation License, Version 1.3 or
7any later version published by the Free Software Foundation; with the
8Invariant Sections being "Free Software" and "Free Software Needs
9Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
10and with the Back-Cover Texts as in (a) below.
11
12(a) The FSF's Back-Cover Text is: "You are free to copy and modify
13this GNU Manual.  Buying copies from GNU Press supports the FSF in
14developing GNU and promoting software freedom." -->
15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
16<head>
17<title>Debugging with GDB: Symbol Tables In Python</title>
18
19<meta name="description" content="Debugging with GDB: Symbol Tables In Python">
20<meta name="keywords" content="Debugging with GDB: Symbol Tables In Python">
21<meta name="resource-type" content="document">
22<meta name="distribution" content="global">
23<meta name="Generator" content="makeinfo">
24<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
25<link href="index.html#Top" rel="start" title="Top">
26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
28<link href="Python-API.html#Python-API" rel="up" title="Python API">
29<link href="Line-Tables-In-Python.html#Line-Tables-In-Python" rel="next" title="Line Tables In Python">
30<link href="Symbols-In-Python.html#Symbols-In-Python" rel="previous" title="Symbols In Python">
31<style type="text/css">
32<!--
33a.summary-letter {text-decoration: none}
34blockquote.smallquotation {font-size: smaller}
35div.display {margin-left: 3.2em}
36div.example {margin-left: 3.2em}
37div.indentedblock {margin-left: 3.2em}
38div.lisp {margin-left: 3.2em}
39div.smalldisplay {margin-left: 3.2em}
40div.smallexample {margin-left: 3.2em}
41div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
42div.smalllisp {margin-left: 3.2em}
43kbd {font-style:oblique}
44pre.display {font-family: inherit}
45pre.format {font-family: inherit}
46pre.menu-comment {font-family: serif}
47pre.menu-preformatted {font-family: serif}
48pre.smalldisplay {font-family: inherit; font-size: smaller}
49pre.smallexample {font-size: smaller}
50pre.smallformat {font-family: inherit; font-size: smaller}
51pre.smalllisp {font-size: smaller}
52span.nocodebreak {white-space:nowrap}
53span.nolinebreak {white-space:nowrap}
54span.roman {font-family:serif; font-weight:normal}
55span.sansserif {font-family:sans-serif; font-weight:normal}
56ul.no-bullet {list-style: none}
57-->
58</style>
59
60
61</head>
62
63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
64<a name="Symbol-Tables-In-Python"></a>
65<div class="header">
66<p>
67Next: <a href="Line-Tables-In-Python.html#Line-Tables-In-Python" accesskey="n" rel="next">Line Tables In Python</a>, Previous: <a href="Symbols-In-Python.html#Symbols-In-Python" accesskey="p" rel="previous">Symbols In Python</a>, Up: <a href="Python-API.html#Python-API" accesskey="u" rel="up">Python 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>
68</div>
69<hr>
70<a name="Symbol-table-representation-in-Python"></a>
71<h4 class="subsubsection">23.2.2.28 Symbol table representation in Python</h4>
72
73<a name="index-symbol-tables-in-python"></a>
74<a name="index-gdb_002eSymtab"></a>
75<a name="index-gdb_002eSymtab_005fand_005fline"></a>
76
77<p>Access to symbol table data maintained by <small>GDB</small> on the inferior
78is exposed to Python via two objects: <code>gdb.Symtab_and_line</code> and
79<code>gdb.Symtab</code>.  Symbol table and line data for a frame is returned
80from the <code>find_sal</code> method in <code>gdb.Frame</code> object.
81See <a href="Frames-In-Python.html#Frames-In-Python">Frames In Python</a>.
82</p>
83<p>For more information on <small>GDB</small>&rsquo;s symbol table management, see
84<a href="Symbols.html#Symbols">Examining the Symbol Table</a>, for more information.
85</p>
86<p>A <code>gdb.Symtab_and_line</code> object has the following attributes:
87</p>
88<dl>
89<dt><a name="index-Symtab_005fand_005fline_002esymtab"></a>Variable: <strong>Symtab_and_line.symtab</strong></dt>
90<dd><p>The symbol table object (<code>gdb.Symtab</code>) for this frame.
91This attribute is not writable.
92</p></dd></dl>
93
94<dl>
95<dt><a name="index-Symtab_005fand_005fline_002epc"></a>Variable: <strong>Symtab_and_line.pc</strong></dt>
96<dd><p>Indicates the start of the address range occupied by code for the
97current source line.  This attribute is not writable.
98</p></dd></dl>
99
100<dl>
101<dt><a name="index-Symtab_005fand_005fline_002elast"></a>Variable: <strong>Symtab_and_line.last</strong></dt>
102<dd><p>Indicates the end of the address range occupied by code for the current
103source line.  This attribute is not writable.
104</p></dd></dl>
105
106<dl>
107<dt><a name="index-Symtab_005fand_005fline_002eline"></a>Variable: <strong>Symtab_and_line.line</strong></dt>
108<dd><p>Indicates the current line number for this object.  This
109attribute is not writable.
110</p></dd></dl>
111
112<p>A <code>gdb.Symtab_and_line</code> object has the following methods:
113</p>
114<dl>
115<dt><a name="index-Symtab_005fand_005fline_002eis_005fvalid"></a>Function: <strong>Symtab_and_line.is_valid</strong> <em>()</em></dt>
116<dd><p>Returns <code>True</code> if the <code>gdb.Symtab_and_line</code> object is valid,
117<code>False</code> if not.  A <code>gdb.Symtab_and_line</code> object can become
118invalid if the Symbol table and line object it refers to does not
119exist in <small>GDB</small> any longer.  All other
120<code>gdb.Symtab_and_line</code> methods will throw an exception if it is
121invalid at the time the method is called.
122</p></dd></dl>
123
124<p>A <code>gdb.Symtab</code> object has the following attributes:
125</p>
126<dl>
127<dt><a name="index-Symtab_002efilename"></a>Variable: <strong>Symtab.filename</strong></dt>
128<dd><p>The symbol table&rsquo;s source filename.  This attribute is not writable.
129</p></dd></dl>
130
131<dl>
132<dt><a name="index-Symtab_002eobjfile"></a>Variable: <strong>Symtab.objfile</strong></dt>
133<dd><p>The symbol table&rsquo;s backing object file.  See <a href="Objfiles-In-Python.html#Objfiles-In-Python">Objfiles In Python</a>.
134This attribute is not writable.
135</p></dd></dl>
136
137<dl>
138<dt><a name="index-Symtab_002eproducer"></a>Variable: <strong>Symtab.producer</strong></dt>
139<dd><p>The name and possibly version number of the program that
140compiled the code in the symbol table.
141The contents of this string is up to the compiler.
142If no producer information is available then <code>None</code> is returned.
143This attribute is not writable.
144</p></dd></dl>
145
146<p>A <code>gdb.Symtab</code> object has the following methods:
147</p>
148<dl>
149<dt><a name="index-Symtab_002eis_005fvalid"></a>Function: <strong>Symtab.is_valid</strong> <em>()</em></dt>
150<dd><p>Returns <code>True</code> if the <code>gdb.Symtab</code> object is valid,
151<code>False</code> if not.  A <code>gdb.Symtab</code> object can become invalid if
152the symbol table it refers to does not exist in <small>GDB</small> any
153longer.  All other <code>gdb.Symtab</code> methods will throw an exception
154if it is invalid at the time the method is called.
155</p></dd></dl>
156
157<dl>
158<dt><a name="index-Symtab_002efullname"></a>Function: <strong>Symtab.fullname</strong> <em>()</em></dt>
159<dd><p>Return the symbol table&rsquo;s source absolute file name.
160</p></dd></dl>
161
162<dl>
163<dt><a name="index-Symtab_002eglobal_005fblock"></a>Function: <strong>Symtab.global_block</strong> <em>()</em></dt>
164<dd><p>Return the global block of the underlying symbol table.
165See <a href="Blocks-In-Python.html#Blocks-In-Python">Blocks In Python</a>.
166</p></dd></dl>
167
168<dl>
169<dt><a name="index-Symtab_002estatic_005fblock"></a>Function: <strong>Symtab.static_block</strong> <em>()</em></dt>
170<dd><p>Return the static block of the underlying symbol table.
171See <a href="Blocks-In-Python.html#Blocks-In-Python">Blocks In Python</a>.
172</p></dd></dl>
173
174<dl>
175<dt><a name="index-Symtab_002elinetable"></a>Function: <strong>Symtab.linetable</strong> <em>()</em></dt>
176<dd><p>Return the line table associated with the symbol table.
177See <a href="Line-Tables-In-Python.html#Line-Tables-In-Python">Line Tables In Python</a>.
178</p></dd></dl>
179
180<hr>
181<div class="header">
182<p>
183Next: <a href="Line-Tables-In-Python.html#Line-Tables-In-Python" accesskey="n" rel="next">Line Tables In Python</a>, Previous: <a href="Symbols-In-Python.html#Symbols-In-Python" accesskey="p" rel="previous">Symbols In Python</a>, Up: <a href="Python-API.html#Python-API" accesskey="u" rel="up">Python 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>
184</div>
185
186
187
188</body>
189</html>
190