Symbols-In-Guile.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Free Software" and "Free Software Needs
  8. Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
  9. and with the Back-Cover Texts as in (a) below.
  10. (a) The FSF's Back-Cover Text is: "You are free to copy and modify
  11. this GNU Manual. Buying copies from GNU Press supports the FSF in
  12. developing GNU and promoting software freedom." -->
  13. <!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <title>Debugging with GDB: Symbols In Guile</title>
  16. <meta name="description" content="Debugging with GDB: Symbols In Guile">
  17. <meta name="keywords" content="Debugging with GDB: Symbols In Guile">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  22. <link href="index.html#Top" rel="start" title="Top">
  23. <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
  24. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  25. <link href="Guile-API.html#Guile-API" rel="up" title="Guile API">
  26. <link href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile" rel="next" title="Symbol Tables In Guile">
  27. <link href="Blocks-In-Guile.html#Blocks-In-Guile" rel="previous" title="Blocks In Guile">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.smallquotation {font-size: smaller}
  32. div.display {margin-left: 3.2em}
  33. div.example {margin-left: 3.2em}
  34. div.indentedblock {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  39. div.smalllisp {margin-left: 3.2em}
  40. kbd {font-style:oblique}
  41. pre.display {font-family: inherit}
  42. pre.format {font-family: inherit}
  43. pre.menu-comment {font-family: serif}
  44. pre.menu-preformatted {font-family: serif}
  45. pre.smalldisplay {font-family: inherit; font-size: smaller}
  46. pre.smallexample {font-size: smaller}
  47. pre.smallformat {font-family: inherit; font-size: smaller}
  48. pre.smalllisp {font-size: smaller}
  49. span.nocodebreak {white-space:nowrap}
  50. span.nolinebreak {white-space:nowrap}
  51. span.roman {font-family:serif; font-weight:normal}
  52. span.sansserif {font-family:sans-serif; font-weight:normal}
  53. ul.no-bullet {list-style: none}
  54. -->
  55. </style>
  56. </head>
  57. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  58. <a name="Symbols-In-Guile"></a>
  59. <div class="header">
  60. <p>
  61. Next: <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>
  62. </div>
  63. <hr>
  64. <a name="Guile-representation-of-Symbols_002e"></a>
  65. <h4 class="subsubsection">23.3.3.17 Guile representation of Symbols.</h4>
  66. <a name="index-symbols-in-guile"></a>
  67. <a name="index-_003cgdb_003asymbol_003e"></a>
  68. <p><small>GDB</small> represents every variable, function and type as an
  69. entry in a symbol table. See <a href="Symbols.html#Symbols">Examining the Symbol Table</a>.
  70. Guile represents these symbols in <small>GDB</small> with the
  71. <code>&lt;gdb:symbol&gt;</code> object.
  72. </p>
  73. <p>The following symbol-related procedures are provided by the
  74. <code>(gdb)</code> module:
  75. </p>
  76. <dl>
  77. <dt><a name="index-symbol_003f"></a>Scheme Procedure: <strong>symbol?</strong> <em>object</em></dt>
  78. <dd><p>Return <code>#t</code> if <var>object</var> is an object of type <code>&lt;gdb:symbol&gt;</code>.
  79. Otherwise return <code>#f</code>.
  80. </p></dd></dl>
  81. <dl>
  82. <dt><a name="index-symbol_002dvalid_003f"></a>Scheme Procedure: <strong>symbol-valid?</strong> <em>symbol</em></dt>
  83. <dd><p>Return <code>#t</code> if the <code>&lt;gdb:symbol&gt;</code> object is valid,
  84. <code>#f</code> if not. A <code>&lt;gdb:symbol&gt;</code> object can become invalid if
  85. the symbol it refers to does not exist in <small>GDB</small> any longer.
  86. All other <code>&lt;gdb:symbol&gt;</code> procedures will throw an exception if it is
  87. invalid at the time the procedure is called.
  88. </p></dd></dl>
  89. <dl>
  90. <dt><a name="index-symbol_002dtype"></a>Scheme Procedure: <strong>symbol-type</strong> <em>symbol</em></dt>
  91. <dd><p>Return the type of <var>symbol</var> or <code>#f</code> if no type is recorded.
  92. The result is an object of type <code>&lt;gdb:type&gt;</code>.
  93. See <a href="Types-In-Guile.html#Types-In-Guile">Types In Guile</a>.
  94. </p></dd></dl>
  95. <dl>
  96. <dt><a name="index-symbol_002dsymtab"></a>Scheme Procedure: <strong>symbol-symtab</strong> <em>symbol</em></dt>
  97. <dd><p>Return the symbol table in which <var>symbol</var> appears.
  98. The result is an object of type <code>&lt;gdb:symtab&gt;</code>.
  99. See <a href="Symbol-Tables-In-Guile.html#Symbol-Tables-In-Guile">Symbol Tables In Guile</a>.
  100. </p></dd></dl>
  101. <dl>
  102. <dt><a name="index-symbol_002dline"></a>Scheme Procedure: <strong>symbol-line</strong> <em>symbol</em></dt>
  103. <dd><p>Return the line number in the source code at which <var>symbol</var> was defined.
  104. This is an integer.
  105. </p></dd></dl>
  106. <dl>
  107. <dt><a name="index-symbol_002dname"></a>Scheme Procedure: <strong>symbol-name</strong> <em>symbol</em></dt>
  108. <dd><p>Return the name of <var>symbol</var> as a string.
  109. </p></dd></dl>
  110. <dl>
  111. <dt><a name="index-symbol_002dlinkage_002dname"></a>Scheme Procedure: <strong>symbol-linkage-name</strong> <em>symbol</em></dt>
  112. <dd><p>Return the name of <var>symbol</var>, as used by the linker (i.e., may be mangled).
  113. </p></dd></dl>
  114. <dl>
  115. <dt><a name="index-symbol_002dprint_002dname"></a>Scheme Procedure: <strong>symbol-print-name</strong> <em>symbol</em></dt>
  116. <dd><p>Return the name of <var>symbol</var> in a form suitable for output. This is either
  117. <code>name</code> or <code>linkage_name</code>, depending on whether the user
  118. asked <small>GDB</small> to display demangled or mangled names.
  119. </p></dd></dl>
  120. <dl>
  121. <dt><a name="index-symbol_002daddr_002dclass"></a>Scheme Procedure: <strong>symbol-addr-class</strong> <em>symbol</em></dt>
  122. <dd><p>Return the address class of the symbol. This classifies how to find the value
  123. of a symbol. Each address class is a constant defined in the
  124. <code>(gdb)</code> module and described later in this chapter.
  125. </p></dd></dl>
  126. <dl>
  127. <dt><a name="index-symbol_002dneeds_002dframe_003f"></a>Scheme Procedure: <strong>symbol-needs-frame?</strong> <em>symbol</em></dt>
  128. <dd><p>Return <code>#t</code> if evaluating <var>symbol</var>&rsquo;s value requires a frame
  129. (see <a href="Frames-In-Guile.html#Frames-In-Guile">Frames In Guile</a>) and <code>#f</code> otherwise. Typically,
  130. local variables will require a frame, but other symbols will not.
  131. </p></dd></dl>
  132. <dl>
  133. <dt><a name="index-symbol_002dargument_003f"></a>Scheme Procedure: <strong>symbol-argument?</strong> <em>symbol</em></dt>
  134. <dd><p>Return <code>#t</code> if <var>symbol</var> is an argument of a function.
  135. Otherwise return <code>#f</code>.
  136. </p></dd></dl>
  137. <dl>
  138. <dt><a name="index-symbol_002dconstant_003f"></a>Scheme Procedure: <strong>symbol-constant?</strong> <em>symbol</em></dt>
  139. <dd><p>Return <code>#t</code> if <var>symbol</var> is a constant.
  140. Otherwise return <code>#f</code>.
  141. </p></dd></dl>
  142. <dl>
  143. <dt><a name="index-symbol_002dfunction_003f"></a>Scheme Procedure: <strong>symbol-function?</strong> <em>symbol</em></dt>
  144. <dd><p>Return <code>#t</code> if <var>symbol</var> is a function or a method.
  145. Otherwise return <code>#f</code>.
  146. </p></dd></dl>
  147. <dl>
  148. <dt><a name="index-symbol_002dvariable_003f"></a>Scheme Procedure: <strong>symbol-variable?</strong> <em>symbol</em></dt>
  149. <dd><p>Return <code>#t</code> if <var>symbol</var> is a variable.
  150. Otherwise return <code>#f</code>.
  151. </p></dd></dl>
  152. <dl>
  153. <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>
  154. <dd><p>Compute the value of <var>symbol</var>, as a <code>&lt;gdb:value&gt;</code>. For
  155. functions, this computes the address of the function, cast to the
  156. appropriate type. If the symbol requires a frame in order to compute
  157. its value, then <var>frame</var> must be given. If <var>frame</var> is not
  158. given, or if <var>frame</var> is invalid, then an exception is thrown.
  159. </p></dd></dl>
  160. <dl>
  161. <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>
  162. <dd><p>This function searches for a symbol by name. The search scope can be
  163. restricted to the parameters defined in the optional domain and block
  164. arguments.
  165. </p>
  166. <p><var>name</var> is the name of the symbol. It must be a string. The
  167. optional <var>block</var> argument restricts the search to symbols visible
  168. in that <var>block</var>. The <var>block</var> argument must be a
  169. <code>&lt;gdb:block&gt;</code> object. If omitted, the block for the current frame
  170. is used. The optional <var>domain</var> argument restricts
  171. the search to the domain type. The <var>domain</var> argument must be a
  172. domain constant defined in the <code>(gdb)</code> module and described later
  173. in this chapter.
  174. </p>
  175. <p>The result is a list of two elements.
  176. The first element is a <code>&lt;gdb:symbol&gt;</code> object or <code>#f</code> if the symbol
  177. is not found.
  178. If the symbol is found, the second element is <code>#t</code> if the symbol
  179. is a field of a method&rsquo;s object (e.g., <code>this</code> in C<tt>++</tt>),
  180. otherwise it is <code>#f</code>.
  181. If the symbol is not found, the second element is <code>#f</code>.
  182. </p></dd></dl>
  183. <dl>
  184. <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>
  185. <dd><p>This function searches for a global symbol by name.
  186. The search scope can be restricted by the domain argument.
  187. </p>
  188. <p><var>name</var> is the name of the symbol. It must be a string.
  189. The optional <var>domain</var> argument restricts the search to the domain type.
  190. The <var>domain</var> argument must be a domain constant defined in the <code>(gdb)</code>
  191. module and described later in this chapter.
  192. </p>
  193. <p>The result is a <code>&lt;gdb:symbol&gt;</code> object or <code>#f</code> if the symbol
  194. is not found.
  195. </p></dd></dl>
  196. <p>The available domain categories in <code>&lt;gdb:symbol&gt;</code> are represented
  197. as constants in the <code>(gdb)</code> module:
  198. </p>
  199. <dl compact="compact">
  200. <dt><code>SYMBOL_UNDEF_DOMAIN</code>
  201. <a name="index-SYMBOL_005fUNDEF_005fDOMAIN-1"></a>
  202. </dt>
  203. <dd><p>This is used when a domain has not been discovered or none of the
  204. following domains apply. This usually indicates an error either
  205. in the symbol information or in <small>GDB</small>&rsquo;s handling of symbols.
  206. </p>
  207. </dd>
  208. <dt><code>SYMBOL_VAR_DOMAIN</code>
  209. <a name="index-SYMBOL_005fVAR_005fDOMAIN-1"></a>
  210. </dt>
  211. <dd><p>This domain contains variables, function names, typedef names and enum
  212. type values.
  213. </p>
  214. </dd>
  215. <dt><code>SYMBOL_STRUCT_DOMAIN</code>
  216. <a name="index-SYMBOL_005fSTRUCT_005fDOMAIN-1"></a>
  217. </dt>
  218. <dd><p>This domain holds struct, union and enum type names.
  219. </p>
  220. </dd>
  221. <dt><code>SYMBOL_LABEL_DOMAIN</code>
  222. <a name="index-SYMBOL_005fLABEL_005fDOMAIN-1"></a>
  223. </dt>
  224. <dd><p>This domain contains names of labels (for gotos).
  225. </p>
  226. </dd>
  227. <dt><code>SYMBOL_VARIABLES_DOMAIN</code>
  228. <a name="index-SYMBOL_005fVARIABLES_005fDOMAIN"></a>
  229. </dt>
  230. <dd><p>This domain holds a subset of the <code>SYMBOLS_VAR_DOMAIN</code>; it
  231. contains everything minus functions and types.
  232. </p>
  233. </dd>
  234. <dt><code>SYMBOL_FUNCTIONS_DOMAIN</code>
  235. <a name="index-SYMBOL_005fFUNCTIONS_005fDOMAIN"></a>
  236. </dt>
  237. <dd><p>This domain contains all functions.
  238. </p>
  239. </dd>
  240. <dt><code>SYMBOL_TYPES_DOMAIN</code>
  241. <a name="index-SYMBOL_005fTYPES_005fDOMAIN"></a>
  242. </dt>
  243. <dd><p>This domain contains all types.
  244. </p></dd>
  245. </dl>
  246. <p>The available address class categories in <code>&lt;gdb:symbol&gt;</code> are represented
  247. as constants in the <code>gdb</code> module:
  248. </p>
  249. <dl compact="compact">
  250. <dt><code>SYMBOL_LOC_UNDEF</code>
  251. <a name="index-SYMBOL_005fLOC_005fUNDEF-1"></a>
  252. </dt>
  253. <dd><p>If this is returned by address class, it indicates an error either in
  254. the symbol information or in <small>GDB</small>&rsquo;s handling of symbols.
  255. </p>
  256. </dd>
  257. <dt><code>SYMBOL_LOC_CONST</code>
  258. <a name="index-SYMBOL_005fLOC_005fCONST-1"></a>
  259. </dt>
  260. <dd><p>Value is constant int.
  261. </p>
  262. </dd>
  263. <dt><code>SYMBOL_LOC_STATIC</code>
  264. <a name="index-SYMBOL_005fLOC_005fSTATIC-1"></a>
  265. </dt>
  266. <dd><p>Value is at a fixed address.
  267. </p>
  268. </dd>
  269. <dt><code>SYMBOL_LOC_REGISTER</code>
  270. <a name="index-SYMBOL_005fLOC_005fREGISTER-1"></a>
  271. </dt>
  272. <dd><p>Value is in a register.
  273. </p>
  274. </dd>
  275. <dt><code>SYMBOL_LOC_ARG</code>
  276. <a name="index-SYMBOL_005fLOC_005fARG-1"></a>
  277. </dt>
  278. <dd><p>Value is an argument. This value is at the offset stored within the
  279. symbol inside the frame&rsquo;s argument list.
  280. </p>
  281. </dd>
  282. <dt><code>SYMBOL_LOC_REF_ARG</code>
  283. <a name="index-SYMBOL_005fLOC_005fREF_005fARG-1"></a>
  284. </dt>
  285. <dd><p>Value address is stored in the frame&rsquo;s argument list. Just like
  286. <code>LOC_ARG</code> except that the value&rsquo;s address is stored at the
  287. offset, not the value itself.
  288. </p>
  289. </dd>
  290. <dt><code>SYMBOL_LOC_REGPARM_ADDR</code>
  291. <a name="index-SYMBOL_005fLOC_005fREGPARM_005fADDR-1"></a>
  292. </dt>
  293. <dd><p>Value is a specified register. Just like <code>LOC_REGISTER</code> except
  294. the register holds the address of the argument instead of the argument
  295. itself.
  296. </p>
  297. </dd>
  298. <dt><code>SYMBOL_LOC_LOCAL</code>
  299. <a name="index-SYMBOL_005fLOC_005fLOCAL-1"></a>
  300. </dt>
  301. <dd><p>Value is a local variable.
  302. </p>
  303. </dd>
  304. <dt><code>SYMBOL_LOC_TYPEDEF</code>
  305. <a name="index-SYMBOL_005fLOC_005fTYPEDEF-1"></a>
  306. </dt>
  307. <dd><p>Value not used. Symbols in the domain <code>SYMBOL_STRUCT_DOMAIN</code> all
  308. have this class.
  309. </p>
  310. </dd>
  311. <dt><code>SYMBOL_LOC_BLOCK</code>
  312. <a name="index-SYMBOL_005fLOC_005fBLOCK-1"></a>
  313. </dt>
  314. <dd><p>Value is a block.
  315. </p>
  316. </dd>
  317. <dt><code>SYMBOL_LOC_CONST_BYTES</code>
  318. <a name="index-SYMBOL_005fLOC_005fCONST_005fBYTES-1"></a>
  319. </dt>
  320. <dd><p>Value is a byte-sequence.
  321. </p>
  322. </dd>
  323. <dt><code>SYMBOL_LOC_UNRESOLVED</code>
  324. <a name="index-SYMBOL_005fLOC_005fUNRESOLVED-1"></a>
  325. </dt>
  326. <dd><p>Value is at a fixed address, but the address of the variable has to be
  327. determined from the minimal symbol table whenever the variable is
  328. referenced.
  329. </p>
  330. </dd>
  331. <dt><code>SYMBOL_LOC_OPTIMIZED_OUT</code>
  332. <a name="index-SYMBOL_005fLOC_005fOPTIMIZED_005fOUT-1"></a>
  333. </dt>
  334. <dd><p>The value does not actually exist in the program.
  335. </p>
  336. </dd>
  337. <dt><code>SYMBOL_LOC_COMPUTED</code>
  338. <a name="index-SYMBOL_005fLOC_005fCOMPUTED-2"></a>
  339. </dt>
  340. <dd><p>The value&rsquo;s address is a computed location.
  341. </p></dd>
  342. </dl>
  343. <hr>
  344. <div class="header">
  345. <p>
  346. Next: <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>
  347. </div>
  348. </body>
  349. </html>