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: Symbols In Guile</title>
18
19<meta name="description" content="Debugging with GDB: Symbols In Guile">
20<meta name="keywords" content="Debugging with GDB: Symbols In Guile">
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="Guile-API.html#Guile-API" rel="up" title="Guile API">
29<link href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile" rel="next" title="Symbol Tables In Guile">
30<link href="Blocks-In-Guile.html#Blocks-In-Guile" rel="previous" title="Blocks In Guile">
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="Symbols-In-Guile"></a>
65<div class="header">
66<p>
67Next: <a href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile" accesskey="n" rel="next">Symbol Tables In Guile</a>, Previous: <a href="Blocks-In-Guile.html#Blocks-In-Guile" accesskey="p" rel="previous">Blocks In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile 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="Guile-representation-of-Symbols_002e"></a>
71<h4 class="subsubsection">23.3.3.17 Guile representation of Symbols.</h4>
72
73<a name="index-symbols-in-guile"></a>
74<a name="index-_003cgdb_003asymbol_003e"></a>
75
76<p><small>GDB</small> represents every variable, function and type as an
77entry in a symbol table.  See <a href="Symbols.html#Symbols">Examining the Symbol Table</a>.
78Guile represents these symbols in <small>GDB</small> with the
79<code>&lt;gdb:symbol&gt;</code> object.
80</p>
81<p>The following symbol-related procedures are provided by the
82<code>(gdb)</code> module:
83</p>
84<dl>
85<dt><a name="index-symbol_003f"></a>Scheme Procedure: <strong>symbol?</strong> <em>object</em></dt>
86<dd><p>Return <code>#t</code> if <var>object</var> is an object of type <code>&lt;gdb:symbol&gt;</code>.
87Otherwise return <code>#f</code>.
88</p></dd></dl>
89
90<dl>
91<dt><a name="index-symbol_002dvalid_003f"></a>Scheme Procedure: <strong>symbol-valid?</strong> <em>symbol</em></dt>
92<dd><p>Return <code>#t</code> if the <code>&lt;gdb:symbol&gt;</code> object is valid,
93<code>#f</code> if not.  A <code>&lt;gdb:symbol&gt;</code> object can become invalid if
94the symbol it refers to does not exist in <small>GDB</small> any longer.
95All other <code>&lt;gdb:symbol&gt;</code> procedures will throw an exception if it is
96invalid at the time the procedure is called.
97</p></dd></dl>
98
99<dl>
100<dt><a name="index-symbol_002dtype"></a>Scheme Procedure: <strong>symbol-type</strong> <em>symbol</em></dt>
101<dd><p>Return the type of <var>symbol</var> or <code>#f</code> if no type is recorded.
102The result is an object of type <code>&lt;gdb:type&gt;</code>.
103See <a href="Types-In-Guile.html#Types-In-Guile">Types In Guile</a>.
104</p></dd></dl>
105
106<dl>
107<dt><a name="index-symbol_002dsymtab"></a>Scheme Procedure: <strong>symbol-symtab</strong> <em>symbol</em></dt>
108<dd><p>Return the symbol table in which <var>symbol</var> appears.
109The result is an object of type <code>&lt;gdb:symtab&gt;</code>.
110See <a href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile">Symbol Tables In Guile</a>.
111</p></dd></dl>
112
113<dl>
114<dt><a name="index-symbol_002dline"></a>Scheme Procedure: <strong>symbol-line</strong> <em>symbol</em></dt>
115<dd><p>Return the line number in the source code at which <var>symbol</var> was defined.
116This is an integer.
117</p></dd></dl>
118
119<dl>
120<dt><a name="index-symbol_002dname"></a>Scheme Procedure: <strong>symbol-name</strong> <em>symbol</em></dt>
121<dd><p>Return the name of <var>symbol</var> as a string.
122</p></dd></dl>
123
124<dl>
125<dt><a name="index-symbol_002dlinkage_002dname"></a>Scheme Procedure: <strong>symbol-linkage-name</strong> <em>symbol</em></dt>
126<dd><p>Return the name of <var>symbol</var>, as used by the linker (i.e., may be mangled).
127</p></dd></dl>
128
129<dl>
130<dt><a name="index-symbol_002dprint_002dname"></a>Scheme Procedure: <strong>symbol-print-name</strong> <em>symbol</em></dt>
131<dd><p>Return the name of <var>symbol</var> in a form suitable for output.  This is either
132<code>name</code> or <code>linkage_name</code>, depending on whether the user
133asked <small>GDB</small> to display demangled or mangled names.
134</p></dd></dl>
135
136<dl>
137<dt><a name="index-symbol_002daddr_002dclass"></a>Scheme Procedure: <strong>symbol-addr-class</strong> <em>symbol</em></dt>
138<dd><p>Return the address class of the symbol.  This classifies how to find the value
139of a symbol.  Each address class is a constant defined in the
140<code>(gdb)</code> module and described later in this chapter.
141</p></dd></dl>
142
143<dl>
144<dt><a name="index-symbol_002dneeds_002dframe_003f"></a>Scheme Procedure: <strong>symbol-needs-frame?</strong> <em>symbol</em></dt>
145<dd><p>Return <code>#t</code> if evaluating <var>symbol</var>&rsquo;s value requires a frame
146(see <a href="Frames-In-Guile.html#Frames-In-Guile">Frames In Guile</a>) and <code>#f</code> otherwise.  Typically,
147local variables will require a frame, but other symbols will not.
148</p></dd></dl>
149
150<dl>
151<dt><a name="index-symbol_002dargument_003f"></a>Scheme Procedure: <strong>symbol-argument?</strong> <em>symbol</em></dt>
152<dd><p>Return <code>#t</code> if <var>symbol</var> is an argument of a function.
153Otherwise return <code>#f</code>.
154</p></dd></dl>
155
156<dl>
157<dt><a name="index-symbol_002dconstant_003f"></a>Scheme Procedure: <strong>symbol-constant?</strong> <em>symbol</em></dt>
158<dd><p>Return <code>#t</code> if <var>symbol</var> is a constant.
159Otherwise return <code>#f</code>.
160</p></dd></dl>
161
162<dl>
163<dt><a name="index-symbol_002dfunction_003f"></a>Scheme Procedure: <strong>symbol-function?</strong> <em>symbol</em></dt>
164<dd><p>Return <code>#t</code> if <var>symbol</var> is a function or a method.
165Otherwise return <code>#f</code>.
166</p></dd></dl>
167
168<dl>
169<dt><a name="index-symbol_002dvariable_003f"></a>Scheme Procedure: <strong>symbol-variable?</strong> <em>symbol</em></dt>
170<dd><p>Return <code>#t</code> if <var>symbol</var> is a variable.
171Otherwise return <code>#f</code>.
172</p></dd></dl>
173
174<dl>
175<dt><a name="index-symbol_002dvalue"></a>Scheme Procedure: <strong>symbol-value</strong> <em>symbol <span class="roman">[</span>#:frame frame<span class="roman">]</span></em></dt>
176<dd><p>Compute the value of <var>symbol</var>, as a <code>&lt;gdb:value&gt;</code>.  For
177functions, this computes the address of the function, cast to the
178appropriate type.  If the symbol requires a frame in order to compute
179its value, then <var>frame</var> must be given.  If <var>frame</var> is not
180given, or if <var>frame</var> is invalid, then an exception is thrown.
181</p></dd></dl>
182
183<dl>
184<dt><a name="index-lookup_002dsymbol"></a>Scheme Procedure: <strong>lookup-symbol</strong> <em>name <span class="roman">[</span>#:block block<span class="roman">]</span> <span class="roman">[</span>#:domain domain<span class="roman">]</span></em></dt>
185<dd><p>This function searches for a symbol by name.  The search scope can be
186restricted to the parameters defined in the optional domain and block
187arguments.
188</p>
189<p><var>name</var> is the name of the symbol.  It must be a string.  The
190optional <var>block</var> argument restricts the search to symbols visible
191in that <var>block</var>.  The <var>block</var> argument must be a
192<code>&lt;gdb:block&gt;</code> object.  If omitted, the block for the current frame
193is used.  The optional <var>domain</var> argument restricts
194the search to the domain type.  The <var>domain</var> argument must be a
195domain constant defined in the <code>(gdb)</code> module and described later
196in this chapter.
197</p>
198<p>The result is a list of two elements.
199The first element is a <code>&lt;gdb:symbol&gt;</code> object or <code>#f</code> if the symbol
200is not found.
201If the symbol is found, the second element is <code>#t</code> if the symbol
202is a field of a method&rsquo;s object (e.g., <code>this</code> in C<tt>++</tt>),
203otherwise it is <code>#f</code>.
204If the symbol is not found, the second element is <code>#f</code>.
205</p></dd></dl>
206
207<dl>
208<dt><a name="index-lookup_002dglobal_002dsymbol"></a>Scheme Procedure: <strong>lookup-global-symbol</strong> <em>name <span class="roman">[</span>#:domain domain<span class="roman">]</span></em></dt>
209<dd><p>This function searches for a global symbol by name.
210The search scope can be restricted by the domain argument.
211</p>
212<p><var>name</var> is the name of the symbol.  It must be a string.
213The optional <var>domain</var> argument restricts the search to the domain type.
214The <var>domain</var> argument must be a domain constant defined in the <code>(gdb)</code>
215module and described later in this chapter.
216</p>
217<p>The result is a <code>&lt;gdb:symbol&gt;</code> object or <code>#f</code> if the symbol
218is not found.
219</p></dd></dl>
220
221<p>The available domain categories in <code>&lt;gdb:symbol&gt;</code> are represented
222as constants in the <code>(gdb)</code> module:
223</p>
224<dl compact="compact">
225<dt><code>SYMBOL_UNDEF_DOMAIN</code>
226<a name="index-SYMBOL_005fUNDEF_005fDOMAIN-1"></a>
227</dt>
228<dd><p>This is used when a domain has not been discovered or none of the
229following domains apply.  This usually indicates an error either
230in the symbol information or in <small>GDB</small>&rsquo;s handling of symbols.
231</p>
232</dd>
233<dt><code>SYMBOL_VAR_DOMAIN</code>
234<a name="index-SYMBOL_005fVAR_005fDOMAIN-1"></a>
235</dt>
236<dd><p>This domain contains variables, function names, typedef names and enum
237type values.
238</p>
239</dd>
240<dt><code>SYMBOL_STRUCT_DOMAIN</code>
241<a name="index-SYMBOL_005fSTRUCT_005fDOMAIN-1"></a>
242</dt>
243<dd><p>This domain holds struct, union and enum type names.
244</p>
245</dd>
246<dt><code>SYMBOL_LABEL_DOMAIN</code>
247<a name="index-SYMBOL_005fLABEL_005fDOMAIN-1"></a>
248</dt>
249<dd><p>This domain contains names of labels (for gotos).
250</p>
251</dd>
252<dt><code>SYMBOL_VARIABLES_DOMAIN</code>
253<a name="index-SYMBOL_005fVARIABLES_005fDOMAIN"></a>
254</dt>
255<dd><p>This domain holds a subset of the <code>SYMBOLS_VAR_DOMAIN</code>; it
256contains everything minus functions and types.
257</p>
258</dd>
259<dt><code>SYMBOL_FUNCTIONS_DOMAIN</code>
260<a name="index-SYMBOL_005fFUNCTIONS_005fDOMAIN"></a>
261</dt>
262<dd><p>This domain contains all functions.
263</p>
264</dd>
265<dt><code>SYMBOL_TYPES_DOMAIN</code>
266<a name="index-SYMBOL_005fTYPES_005fDOMAIN"></a>
267</dt>
268<dd><p>This domain contains all types.
269</p></dd>
270</dl>
271
272<p>The available address class categories in <code>&lt;gdb:symbol&gt;</code> are represented
273as constants in the <code>gdb</code> module:
274</p>
275<dl compact="compact">
276<dt><code>SYMBOL_LOC_UNDEF</code>
277<a name="index-SYMBOL_005fLOC_005fUNDEF-1"></a>
278</dt>
279<dd><p>If this is returned by address class, it indicates an error either in
280the symbol information or in <small>GDB</small>&rsquo;s handling of symbols.
281</p>
282</dd>
283<dt><code>SYMBOL_LOC_CONST</code>
284<a name="index-SYMBOL_005fLOC_005fCONST-1"></a>
285</dt>
286<dd><p>Value is constant int.
287</p>
288</dd>
289<dt><code>SYMBOL_LOC_STATIC</code>
290<a name="index-SYMBOL_005fLOC_005fSTATIC-1"></a>
291</dt>
292<dd><p>Value is at a fixed address.
293</p>
294</dd>
295<dt><code>SYMBOL_LOC_REGISTER</code>
296<a name="index-SYMBOL_005fLOC_005fREGISTER-1"></a>
297</dt>
298<dd><p>Value is in a register.
299</p>
300</dd>
301<dt><code>SYMBOL_LOC_ARG</code>
302<a name="index-SYMBOL_005fLOC_005fARG-1"></a>
303</dt>
304<dd><p>Value is an argument.  This value is at the offset stored within the
305symbol inside the frame&rsquo;s argument list.
306</p>
307</dd>
308<dt><code>SYMBOL_LOC_REF_ARG</code>
309<a name="index-SYMBOL_005fLOC_005fREF_005fARG-1"></a>
310</dt>
311<dd><p>Value address is stored in the frame&rsquo;s argument list.  Just like
312<code>LOC_ARG</code> except that the value&rsquo;s address is stored at the
313offset, not the value itself.
314</p>
315</dd>
316<dt><code>SYMBOL_LOC_REGPARM_ADDR</code>
317<a name="index-SYMBOL_005fLOC_005fREGPARM_005fADDR-1"></a>
318</dt>
319<dd><p>Value is a specified register.  Just like <code>LOC_REGISTER</code> except
320the register holds the address of the argument instead of the argument
321itself.
322</p>
323</dd>
324<dt><code>SYMBOL_LOC_LOCAL</code>
325<a name="index-SYMBOL_005fLOC_005fLOCAL-1"></a>
326</dt>
327<dd><p>Value is a local variable.
328</p>
329</dd>
330<dt><code>SYMBOL_LOC_TYPEDEF</code>
331<a name="index-SYMBOL_005fLOC_005fTYPEDEF-1"></a>
332</dt>
333<dd><p>Value not used.  Symbols in the domain <code>SYMBOL_STRUCT_DOMAIN</code> all
334have this class.
335</p>
336</dd>
337<dt><code>SYMBOL_LOC_BLOCK</code>
338<a name="index-SYMBOL_005fLOC_005fBLOCK-1"></a>
339</dt>
340<dd><p>Value is a block.
341</p>
342</dd>
343<dt><code>SYMBOL_LOC_CONST_BYTES</code>
344<a name="index-SYMBOL_005fLOC_005fCONST_005fBYTES-1"></a>
345</dt>
346<dd><p>Value is a byte-sequence.
347</p>
348</dd>
349<dt><code>SYMBOL_LOC_UNRESOLVED</code>
350<a name="index-SYMBOL_005fLOC_005fUNRESOLVED-1"></a>
351</dt>
352<dd><p>Value is at a fixed address, but the address of the variable has to be
353determined from the minimal symbol table whenever the variable is
354referenced.
355</p>
356</dd>
357<dt><code>SYMBOL_LOC_OPTIMIZED_OUT</code>
358<a name="index-SYMBOL_005fLOC_005fOPTIMIZED_005fOUT-1"></a>
359</dt>
360<dd><p>The value does not actually exist in the program.
361</p>
362</dd>
363<dt><code>SYMBOL_LOC_COMPUTED</code>
364<a name="index-SYMBOL_005fLOC_005fCOMPUTED-2"></a>
365</dt>
366<dd><p>The value&rsquo;s address is a computed location.
367</p></dd>
368</dl>
369
370<hr>
371<div class="header">
372<p>
373Next: <a href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile" accesskey="n" rel="next">Symbol Tables In Guile</a>, Previous: <a href="Blocks-In-Guile.html#Blocks-In-Guile" accesskey="p" rel="previous">Blocks In Guile</a>, Up: <a href="Guile-API.html#Guile-API" accesskey="u" rel="up">Guile 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>
374</div>
375
376
377
378</body>
379</html>
380