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</title> 18 19<meta name="description" content="Debugging with GDB: Symbols"> 20<meta name="keywords" content="Debugging with GDB: Symbols"> 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="index.html#Top" rel="up" title="Top"> 29<link href="Altering.html#Altering" rel="next" title="Altering"> 30<link href="Unsupported-Languages.html#Unsupported-Languages" rel="previous" title="Unsupported Languages"> 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"></a> 65<div class="header"> 66<p> 67Next: <a href="Altering.html#Altering" accesskey="n" rel="next">Altering</a>, Previous: <a href="Languages.html#Languages" accesskey="p" rel="previous">Languages</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<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="Examining-the-Symbol-Table"></a> 71<h2 class="chapter">16 Examining the Symbol Table</h2> 72 73<p>The commands described in this chapter allow you to inquire about the 74symbols (names of variables, functions and types) defined in your 75program. This information is inherent in the text of your program and 76does not change as your program executes. <small>GDB</small> finds it in your 77program’s symbol table, in the file indicated when you started <small>GDB</small> 78(see <a href="File-Options.html#File-Options">Choosing Files</a>), or by one of the 79file-management commands (see <a href="Files.html#Files">Commands to Specify Files</a>). 80</p> 81<a name="index-symbol-names"></a> 82<a name="index-names-of-symbols"></a> 83<a name="index-quoting-names"></a> 84<a name="quoting-names"></a><p>Occasionally, you may need to refer to symbols that contain unusual 85characters, which <small>GDB</small> ordinarily treats as word delimiters. The 86most frequent case is in referring to static variables in other 87source files (see <a href="Variables.html#Variables">Program Variables</a>). File names 88are recorded in object files as debugging symbols, but <small>GDB</small> would 89ordinarily parse a typical file name, like <samp>foo.c</samp>, as the three words 90‘<samp>foo</samp>’ ‘<samp>.</samp>’ ‘<samp>c</samp>’. To allow <small>GDB</small> to recognize 91‘<samp>foo.c</samp>’ as a single symbol, enclose it in single quotes; for example, 92</p> 93<div class="smallexample"> 94<pre class="smallexample">p 'foo.c'::x 95</pre></div> 96 97<p>looks up the value of <code>x</code> in the scope of the file <samp>foo.c</samp>. 98</p> 99<dl compact="compact"> 100<dd><a name="index-case_002dinsensitive-symbol-names"></a> 101<a name="index-case-sensitivity-in-symbol-names"></a> 102<a name="index-set-case_002dsensitive"></a> 103</dd> 104<dt><code>set case-sensitive on</code></dt> 105<dt><code>set case-sensitive off</code></dt> 106<dt><code>set case-sensitive auto</code></dt> 107<dd><p>Normally, when <small>GDB</small> looks up symbols, it matches their names 108with case sensitivity determined by the current source language. 109Occasionally, you may wish to control that. The command <code>set 110case-sensitive</code> lets you do that by specifying <code>on</code> for 111case-sensitive matches or <code>off</code> for case-insensitive ones. If 112you specify <code>auto</code>, case sensitivity is reset to the default 113suitable for the source language. The default is case-sensitive 114matches for all languages except for Fortran, for which the default is 115case-insensitive matches. 116</p> 117<a name="index-show-case_002dsensitive"></a> 118</dd> 119<dt><code>show case-sensitive</code></dt> 120<dd><p>This command shows the current setting of case sensitivity for symbols 121lookups. 122</p> 123<a name="index-set-print-type-methods"></a> 124</dd> 125<dt><code>set print type methods</code></dt> 126<dt><code>set print type methods on</code></dt> 127<dt><code>set print type methods off</code></dt> 128<dd><p>Normally, when <small>GDB</small> prints a class, it displays any methods 129declared in that class. You can control this behavior either by 130passing the appropriate flag to <code>ptype</code>, or using <code>set 131print type methods</code>. Specifying <code>on</code> will cause <small>GDB</small> to 132display the methods; this is the default. Specifying <code>off</code> will 133cause <small>GDB</small> to omit the methods. 134</p> 135<a name="index-show-print-type-methods"></a> 136</dd> 137<dt><code>show print type methods</code></dt> 138<dd><p>This command shows the current setting of method display when printing 139classes. 140</p> 141<a name="index-set-print-type-nested_002dtype_002dlimit"></a> 142</dd> 143<dt><code>set print type nested-type-limit <var>limit</var></code></dt> 144<dt><code>set print type nested-type-limit unlimited</code></dt> 145<dd><p>Set the limit of displayed nested types that the type printer will 146show. A <var>limit</var> of <code>unlimited</code> or <code>-1</code> will show all 147nested definitions. By default, the type printer will not show any nested 148types defined in classes. 149</p> 150<a name="index-show-print-type-nested_002dtype_002dlimit"></a> 151</dd> 152<dt><code>show print type nested-type-limit</code></dt> 153<dd><p>This command shows the current display limit of nested types when 154printing classes. 155</p> 156<a name="index-set-print-type-typedefs"></a> 157</dd> 158<dt><code>set print type typedefs</code></dt> 159<dt><code>set print type typedefs on</code></dt> 160<dt><code>set print type typedefs off</code></dt> 161<dd> 162<p>Normally, when <small>GDB</small> prints a class, it displays any typedefs 163defined in that class. You can control this behavior either by 164passing the appropriate flag to <code>ptype</code>, or using <code>set 165print type typedefs</code>. Specifying <code>on</code> will cause <small>GDB</small> to 166display the typedef definitions; this is the default. Specifying 167<code>off</code> will cause <small>GDB</small> to omit the typedef definitions. 168Note that this controls whether the typedef definition itself is 169printed, not whether typedef names are substituted when printing other 170types. 171</p> 172<a name="index-show-print-type-typedefs"></a> 173</dd> 174<dt><code>show print type typedefs</code></dt> 175<dd><p>This command shows the current setting of typedef display when 176printing classes. 177</p> 178<a name="index-info-address"></a> 179<a name="index-address-of-a-symbol"></a> 180</dd> 181<dt><code>info address <var>symbol</var></code></dt> 182<dd><p>Describe where the data for <var>symbol</var> is stored. For a register 183variable, this says which register it is kept in. For a non-register 184local variable, this prints the stack-frame offset at which the variable 185is always stored. 186</p> 187<p>Note the contrast with ‘<samp>print &<var>symbol</var></samp>’, which does not work 188at all for a register variable, and for a stack local variable prints 189the exact address of the current instantiation of the variable. 190</p> 191<a name="index-info-symbol"></a> 192<a name="index-symbol-from-address"></a> 193<a name="index-closest-symbol-and-offset-for-an-address"></a> 194</dd> 195<dt><code>info symbol <var>addr</var></code></dt> 196<dd><p>Print the name of a symbol which is stored at the address <var>addr</var>. 197If no symbol is stored exactly at <var>addr</var>, <small>GDB</small> prints the 198nearest symbol and an offset from it: 199</p> 200<div class="smallexample"> 201<pre class="smallexample">(gdb) info symbol 0x54320 202_initialize_vx + 396 in section .text 203</pre></div> 204 205<p>This is the opposite of the <code>info address</code> command. You can use 206it to find out the name of a variable or a function given its address. 207</p> 208<p>For dynamically linked executables, the name of executable or shared 209library containing the symbol is also printed: 210</p> 211<div class="smallexample"> 212<pre class="smallexample">(gdb) info symbol 0x400225 213_start + 5 in section .text of /tmp/a.out 214(gdb) info symbol 0x2aaaac2811cf 215__read_nocancel + 6 in section .text of /usr/lib64/libc.so.6 216</pre></div> 217 218<a name="index-demangle-1"></a> 219<a name="index-demangle"></a> 220</dd> 221<dt><code>demangle <span class="roman">[</span>-l <var>language</var><span class="roman">]</span> <span class="roman">[</span><var>--</var><span class="roman">]</span> <var>name</var></code></dt> 222<dd><p>Demangle <var>name</var>. 223If <var>language</var> is provided it is the name of the language to demangle 224<var>name</var> in. Otherwise <var>name</var> is demangled in the current language. 225</p> 226<p>The ‘<samp>--</samp>’ option specifies the end of options, 227and is useful when <var>name</var> begins with a dash. 228</p> 229<p>The parameter <code>demangle-style</code> specifies how to interpret the kind 230of mangling used. See <a href="Print-Settings.html#Print-Settings">Print Settings</a>. 231</p> 232<a name="index-whatis"></a> 233</dd> 234<dt><code>whatis[/<var>flags</var>] [<var>arg</var>]</code></dt> 235<dd><p>Print the data type of <var>arg</var>, which can be either an expression 236or a name of a data type. With no argument, print the data type of 237<code>$</code>, the last value in the value history. 238</p> 239<p>If <var>arg</var> is an expression (see <a href="Expressions.html#Expressions">Expressions</a>), it 240is not actually evaluated, and any side-effecting operations (such as 241assignments or function calls) inside it do not take place. 242</p> 243<p>If <var>arg</var> is a variable or an expression, <code>whatis</code> prints its 244literal type as it is used in the source code. If the type was 245defined using a <code>typedef</code>, <code>whatis</code> will <em>not</em> print 246the data type underlying the <code>typedef</code>. If the type of the 247variable or the expression is a compound data type, such as 248<code>struct</code> or <code>class</code>, <code>whatis</code> never prints their 249fields or methods. It just prints the <code>struct</code>/<code>class</code> 250name (a.k.a. its <em>tag</em>). If you want to see the members of 251such a compound data type, use <code>ptype</code>. 252</p> 253<p>If <var>arg</var> is a type name that was defined using <code>typedef</code>, 254<code>whatis</code> <em>unrolls</em> only one level of that <code>typedef</code>. 255Unrolling means that <code>whatis</code> will show the underlying type used 256in the <code>typedef</code> declaration of <var>arg</var>. However, if that 257underlying type is also a <code>typedef</code>, <code>whatis</code> will not 258unroll it. 259</p> 260<p>For C code, the type names may also have the form ‘<samp>class 261<var>class-name</var></samp>’, ‘<samp>struct <var>struct-tag</var></samp>’, ‘<samp>union 262<var>union-tag</var></samp>’ or ‘<samp>enum <var>enum-tag</var></samp>’. 263</p> 264<p><var>flags</var> can be used to modify how the type is displayed. 265Available flags are: 266</p> 267<dl compact="compact"> 268<dt><code>r</code></dt> 269<dd><p>Display in “raw” form. Normally, <small>GDB</small> substitutes template 270parameters and typedefs defined in a class when printing the class’ 271members. The <code>/r</code> flag disables this. 272</p> 273</dd> 274<dt><code>m</code></dt> 275<dd><p>Do not print methods defined in the class. 276</p> 277</dd> 278<dt><code>M</code></dt> 279<dd><p>Print methods defined in the class. This is the default, but the flag 280exists in case you change the default with <code>set print type methods</code>. 281</p> 282</dd> 283<dt><code>t</code></dt> 284<dd><p>Do not print typedefs defined in the class. Note that this controls 285whether the typedef definition itself is printed, not whether typedef 286names are substituted when printing other types. 287</p> 288</dd> 289<dt><code>T</code></dt> 290<dd><p>Print typedefs defined in the class. This is the default, but the flag 291exists in case you change the default with <code>set print type typedefs</code>. 292</p> 293</dd> 294<dt><code>o</code></dt> 295<dd><p>Print the offsets and sizes of fields in a struct, similar to what the 296<code>pahole</code> tool does. This option implies the <code>/tm</code> flags. 297</p> 298<p>For example, given the following declarations: 299</p> 300<div class="smallexample"> 301<pre class="smallexample">struct tuv 302{ 303 int a1; 304 char *a2; 305 int a3; 306}; 307 308struct xyz 309{ 310 int f1; 311 char f2; 312 void *f3; 313 struct tuv f4; 314}; 315 316union qwe 317{ 318 struct tuv fff1; 319 struct xyz fff2; 320}; 321 322struct tyu 323{ 324 int a1 : 1; 325 int a2 : 3; 326 int a3 : 23; 327 char a4 : 2; 328 int64_t a5; 329 int a6 : 5; 330 int64_t a7 : 3; 331}; 332</pre></div> 333 334<p>Issuing a <kbd>ptype /o struct tuv</kbd> command would print: 335</p> 336<div class="smallexample"> 337<pre class="smallexample">(gdb) ptype /o struct tuv 338/* offset | size */ type = struct tuv { 339/* 0 | 4 */ int a1; 340/* XXX 4-byte hole */ 341/* 8 | 8 */ char *a2; 342/* 16 | 4 */ int a3; 343 344 /* total size (bytes): 24 */ 345 } 346</pre></div> 347 348<p>Notice the format of the first column of comments. There, you can 349find two parts separated by the ‘<samp>|</samp>’ character: the <em>offset</em>, 350which indicates where the field is located inside the struct, in 351bytes, and the <em>size</em> of the field. Another interesting line is 352the marker of a <em>hole</em> in the struct, indicating that it may be 353possible to pack the struct and make it use less space by reorganizing 354its fields. 355</p> 356<p>It is also possible to print offsets inside an union: 357</p> 358<div class="smallexample"> 359<pre class="smallexample">(gdb) ptype /o union qwe 360/* offset | size */ type = union qwe { 361/* 24 */ struct tuv { 362/* 0 | 4 */ int a1; 363/* XXX 4-byte hole */ 364/* 8 | 8 */ char *a2; 365/* 16 | 4 */ int a3; 366 367 /* total size (bytes): 24 */ 368 } fff1; 369/* 40 */ struct xyz { 370/* 0 | 4 */ int f1; 371/* 4 | 1 */ char f2; 372/* XXX 3-byte hole */ 373/* 8 | 8 */ void *f3; 374/* 16 | 24 */ struct tuv { 375/* 16 | 4 */ int a1; 376/* XXX 4-byte hole */ 377/* 24 | 8 */ char *a2; 378/* 32 | 4 */ int a3; 379 380 /* total size (bytes): 24 */ 381 } f4; 382 383 /* total size (bytes): 40 */ 384 } fff2; 385 386 /* total size (bytes): 40 */ 387 } 388</pre></div> 389 390<p>In this case, since <code>struct tuv</code> and <code>struct xyz</code> occupy the 391same space (because we are dealing with an union), the offset is not 392printed for them. However, you can still examine the offset of each 393of these structures’ fields. 394</p> 395<p>Another useful scenario is printing the offsets of a struct containing 396bitfields: 397</p> 398<div class="smallexample"> 399<pre class="smallexample">(gdb) ptype /o struct tyu 400/* offset | size */ type = struct tyu { 401/* 0:31 | 4 */ int a1 : 1; 402/* 0:28 | 4 */ int a2 : 3; 403/* 0: 5 | 4 */ int a3 : 23; 404/* 3: 3 | 1 */ signed char a4 : 2; 405/* XXX 3-bit hole */ 406/* XXX 4-byte hole */ 407/* 8 | 8 */ int64_t a5; 408/* 16: 0 | 4 */ int a6 : 5; 409/* 16: 5 | 8 */ int64_t a7 : 3; 410"/* XXX 7-byte padding */ 411 412 /* total size (bytes): 24 */ 413 } 414</pre></div> 415 416<p>Note how the offset information is now extended to also include the 417first bit of the bitfield. 418</p></dd> 419</dl> 420 421<a name="index-ptype"></a> 422</dd> 423<dt><code>ptype[/<var>flags</var>] [<var>arg</var>]</code></dt> 424<dd><p><code>ptype</code> accepts the same arguments as <code>whatis</code>, but prints a 425detailed description of the type, instead of just the name of the type. 426See <a href="Expressions.html#Expressions">Expressions</a>. 427</p> 428<p>Contrary to <code>whatis</code>, <code>ptype</code> always unrolls any 429<code>typedef</code>s in its argument declaration, whether the argument is 430a variable, expression, or a data type. This means that <code>ptype</code> 431of a variable or an expression will not print literally its type as 432present in the source code—use <code>whatis</code> for that. <code>typedef</code>s at 433the pointer or reference targets are also unrolled. Only <code>typedef</code>s of 434fields, methods and inner <code>class typedef</code>s of <code>struct</code>s, 435<code>class</code>es and <code>union</code>s are not unrolled even with <code>ptype</code>. 436</p> 437<p>For example, for this variable declaration: 438</p> 439<div class="smallexample"> 440<pre class="smallexample">typedef double real_t; 441struct complex { real_t real; double imag; }; 442typedef struct complex complex_t; 443complex_t var; 444real_t *real_pointer_var; 445</pre></div> 446 447<p>the two commands give this output: 448</p> 449<div class="smallexample"> 450<pre class="smallexample">(gdb) whatis var 451type = complex_t 452(gdb) ptype var 453type = struct complex { 454 real_t real; 455 double imag; 456} 457(gdb) whatis complex_t 458type = struct complex 459(gdb) whatis struct complex 460type = struct complex 461(gdb) ptype struct complex 462type = struct complex { 463 real_t real; 464 double imag; 465} 466(gdb) whatis real_pointer_var 467type = real_t * 468(gdb) ptype real_pointer_var 469type = double * 470</pre></div> 471 472<p>As with <code>whatis</code>, using <code>ptype</code> without an argument refers to 473the type of <code>$</code>, the last value in the value history. 474</p> 475<a name="index-incomplete-type"></a> 476<p>Sometimes, programs use opaque data types or incomplete specifications 477of complex data structure. If the debug information included in the 478program does not allow <small>GDB</small> to display a full declaration of 479the data type, it will say ‘<samp><incomplete type></samp>’. For example, 480given these declarations: 481</p> 482<div class="smallexample"> 483<pre class="smallexample"> struct foo; 484 struct foo *fooptr; 485</pre></div> 486 487<p>but no definition for <code>struct foo</code> itself, <small>GDB</small> will say: 488</p> 489<div class="smallexample"> 490<pre class="smallexample"> (gdb) ptype foo 491 $1 = <incomplete type> 492</pre></div> 493 494<p>“Incomplete type” is C terminology for data types that are not 495completely specified. 496</p> 497<a name="index-unknown-type"></a> 498<p>Othertimes, information about a variable’s type is completely absent 499from the debug information included in the program. This most often 500happens when the program or library where the variable is defined 501includes no debug information at all. <small>GDB</small> knows the variable 502exists from inspecting the linker/loader symbol table (e.g., the ELF 503dynamic symbol table), but such symbols do not contain type 504information. Inspecting the type of a (global) variable for which 505<small>GDB</small> has no type information shows: 506</p> 507<div class="smallexample"> 508<pre class="smallexample"> (gdb) ptype var 509 type = <data variable, no debug info> 510</pre></div> 511 512<p>See <a href="Variables.html#Variables">no debug info variables</a>, for how to print the values 513of such variables. 514</p> 515<a name="index-info-types"></a> 516</dd> 517<dt><code>info types [-q] [<var>regexp</var>]</code></dt> 518<dd><p>Print a brief description of all types whose names match the regular 519expression <var>regexp</var> (or all types in your program, if you supply 520no argument). Each complete typename is matched as though it were a 521complete line; thus, ‘<samp>i type value</samp>’ gives information on all 522types in your program whose names include the string <code>value</code>, but 523‘<samp>i type ^value$</samp>’ gives information only on types whose complete 524name is <code>value</code>. 525</p> 526<p>In programs using different languages, <small>GDB</small> chooses the syntax 527to print the type description according to the 528‘<samp>set language</samp>’ value: using ‘<samp>set language auto</samp>’ 529(see <a href="Automatically.html#Automatically">Set Language Automatically</a>) means to use the 530language of the type, other values mean to use 531the manually specified language (see <a href="Manually.html#Manually">Set Language Manually</a>). 532</p> 533<p>This command differs from <code>ptype</code> in two ways: first, like 534<code>whatis</code>, it does not print a detailed description; second, it 535lists all source files and line numbers where a type is defined. 536</p> 537<p>The output from ‘<samp>into types</samp>’ is proceeded with a header line 538describing what types are being listed. The optional flag ‘<samp>-q</samp>’, 539which stands for ‘<samp>quiet</samp>’, disables printing this header 540information. 541</p> 542<a name="index-info-type_002dprinters"></a> 543</dd> 544<dt><code>info type-printers</code></dt> 545<dd><p>Versions of <small>GDB</small> that ship with Python scripting enabled may 546have “type printers” available. When using <code>ptype</code> or 547<code>whatis</code>, these printers are consulted when the name of a type 548is needed. See <a href="Type-Printing-API.html#Type-Printing-API">Type Printing API</a>, for more information on writing 549type printers. 550</p> 551<p><code>info type-printers</code> displays all the available type printers. 552</p> 553<a name="index-enable-type_002dprinter"></a> 554<a name="index-disable-type_002dprinter"></a> 555</dd> 556<dt><code>enable type-printer <var>name</var>…</code></dt> 557<dt><code>disable type-printer <var>name</var>…</code></dt> 558<dd><p>These commands can be used to enable or disable type printers. 559</p> 560<a name="index-info-scope"></a> 561<a name="index-local-variables"></a> 562</dd> 563<dt><code>info scope <var>location</var></code></dt> 564<dd><p>List all the variables local to a particular scope. This command 565accepts a <var>location</var> argument—a function name, a source line, or 566an address preceded by a ‘<samp>*</samp>’, and prints all the variables local 567to the scope defined by that location. (See <a href="Specify-Location.html#Specify-Location">Specify Location</a>, for 568details about supported forms of <var>location</var>.) For example: 569</p> 570<div class="smallexample"> 571<pre class="smallexample">(gdb) <b>info scope command_line_handler</b> 572Scope for command_line_handler: 573Symbol rl is an argument at stack/frame offset 8, length 4. 574Symbol linebuffer is in static storage at address 0x150a18, length 4. 575Symbol linelength is in static storage at address 0x150a1c, length 4. 576Symbol p is a local variable in register $esi, length 4. 577Symbol p1 is a local variable in register $ebx, length 4. 578Symbol nline is a local variable in register $edx, length 4. 579Symbol repeat is a local variable at frame offset -8, length 4. 580</pre></div> 581 582<p>This command is especially useful for determining what data to collect 583during a <em>trace experiment</em>, see <a href="Tracepoint-Actions.html#Tracepoint-Actions">collect</a>. 584</p> 585<a name="index-info-source"></a> 586</dd> 587<dt><code>info source</code></dt> 588<dd><p>Show information about the current source file—that is, the source file for 589the function containing the current point of execution: 590</p><ul> 591<li> the name of the source file, and the directory containing it, 592</li><li> the directory it was compiled in, 593</li><li> its length, in lines, 594</li><li> which programming language it is written in, 595</li><li> if the debug information provides it, the program that compiled the file 596(which may include, e.g., the compiler version and command line arguments), 597</li><li> whether the executable includes debugging information for that file, and 598if so, what format the information is in (e.g., STABS, Dwarf 2, etc.), and 599</li><li> whether the debugging information includes information about 600preprocessor macros. 601</li></ul> 602 603 604<a name="index-info-sources"></a> 605</dd> 606<dt><code>info sources</code></dt> 607<dd><p>Print the names of all source files in your program for which there is 608debugging information, organized into two lists: files whose symbols 609have already been read, and files whose symbols will be read when needed. 610</p> 611</dd> 612<dt><code>info sources [-dirname | -basename] [--] [<var>regexp</var>]</code></dt> 613<dd><p>Like ‘<samp>info sources</samp>’, but only print the names of the files 614matching the provided <var>regexp</var>. 615By default, the <var>regexp</var> is used to match anywhere in the filename. 616If <code>-dirname</code>, only files having a dirname matching <var>regexp</var> are shown. 617If <code>-basename</code>, only files having a basename matching <var>regexp</var> 618are shown. 619The matching is case-sensitive, except on operating systems that 620have case-insensitive filesystem (e.g., MS-Windows). 621</p> 622<a name="index-info-functions"></a> 623</dd> 624<dt><code>info functions [-q] [-n]</code></dt> 625<dd><p>Print the names and data types of all defined functions. 626Similarly to ‘<samp>info types</samp>’, this command groups its output by source 627files and annotates each function definition with its source line 628number. 629</p> 630<p>In programs using different languages, <small>GDB</small> chooses the syntax 631to print the function name and type according to the 632‘<samp>set language</samp>’ value: using ‘<samp>set language auto</samp>’ 633(see <a href="Automatically.html#Automatically">Set Language Automatically</a>) means to use the 634language of the function, other values mean to use 635the manually specified language (see <a href="Manually.html#Manually">Set Language Manually</a>). 636</p> 637<p>The ‘<samp>-n</samp>’ flag excludes <em>non-debugging symbols</em> from the 638results. A non-debugging symbol is a symbol that comes from the 639executable’s symbol table, not from the debug information (for 640example, DWARF) associated with the executable. 641</p> 642<p>The optional flag ‘<samp>-q</samp>’, which stands for ‘<samp>quiet</samp>’, disables 643printing header information and messages explaining why no functions 644have been printed. 645</p> 646</dd> 647<dt><code>info functions [-q] [-n] [-t <var>type_regexp</var>] [<var>regexp</var>]</code></dt> 648<dd><p>Like ‘<samp>info functions</samp>’, but only print the names and data types 649of the functions selected with the provided regexp(s). 650</p> 651<p>If <var>regexp</var> is provided, print only the functions whose names 652match the regular expression <var>regexp</var>. 653Thus, ‘<samp>info fun step</samp>’ finds all functions whose 654names include <code>step</code>; ‘<samp>info fun ^step</samp>’ finds those whose names 655start with <code>step</code>. If a function name contains characters that 656conflict with the regular expression language (e.g. 657‘<samp>operator*()</samp>’), they may be quoted with a backslash. 658</p> 659<p>If <var>type_regexp</var> is provided, print only the functions whose 660types, as printed by the <code>whatis</code> command, match 661the regular expression <var>type_regexp</var>. 662If <var>type_regexp</var> contains space(s), it should be enclosed in 663quote characters. If needed, use backslash to escape the meaning 664of special characters or quotes. 665Thus, ‘<samp>info fun -t '^int ('</samp>’ finds the functions that return 666an integer; ‘<samp>info fun -t '(.*int.*'</samp>’ finds the functions that 667have an argument type containing int; ‘<samp>info fun -t '^int (' ^step</samp>’ 668finds the functions whose names start with <code>step</code> and that return 669int. 670</p> 671<p>If both <var>regexp</var> and <var>type_regexp</var> are provided, a function 672is printed only if its name matches <var>regexp</var> and its type matches 673<var>type_regexp</var>. 674</p> 675 676<a name="index-info-variables"></a> 677</dd> 678<dt><code>info variables [-q] [-n]</code></dt> 679<dd><p>Print the names and data types of all variables that are defined 680outside of functions (i.e. excluding local variables). 681The printed variables are grouped by source files and annotated with 682their respective source line numbers. 683</p> 684<p>In programs using different languages, <small>GDB</small> chooses the syntax 685to print the variable name and type according to the 686‘<samp>set language</samp>’ value: using ‘<samp>set language auto</samp>’ 687(see <a href="Automatically.html#Automatically">Set Language Automatically</a>) means to use the 688language of the variable, other values mean to use 689the manually specified language (see <a href="Manually.html#Manually">Set Language Manually</a>). 690</p> 691<p>The ‘<samp>-n</samp>’ flag excludes non-debugging symbols from the results. 692</p> 693<p>The optional flag ‘<samp>-q</samp>’, which stands for ‘<samp>quiet</samp>’, disables 694printing header information and messages explaining why no variables 695have been printed. 696</p> 697</dd> 698<dt><code>info variables [-q] [-n] [-t <var>type_regexp</var>] [<var>regexp</var>]</code></dt> 699<dd><p>Like <kbd>info variables</kbd>, but only print the variables selected 700with the provided regexp(s). 701</p> 702<p>If <var>regexp</var> is provided, print only the variables whose names 703match the regular expression <var>regexp</var>. 704</p> 705<p>If <var>type_regexp</var> is provided, print only the variables whose 706types, as printed by the <code>whatis</code> command, match 707the regular expression <var>type_regexp</var>. 708If <var>type_regexp</var> contains space(s), it should be enclosed in 709quote characters. If needed, use backslash to escape the meaning 710of special characters or quotes. 711</p> 712<p>If both <var>regexp</var> and <var>type_regexp</var> are provided, an argument 713is printed only if its name matches <var>regexp</var> and its type matches 714<var>type_regexp</var>. 715</p> 716<a name="index-info-modules"></a> 717<a name="index-modules"></a> 718</dd> 719<dt><code>info modules <span class="roman">[</span>-q<span class="roman">]</span> <span class="roman">[</span><var>regexp</var><span class="roman">]</span></code></dt> 720<dd><p>List all Fortran modules in the program, or all modules matching the 721optional regular expression <var>regexp</var>. 722</p> 723<p>The optional flag ‘<samp>-q</samp>’, which stands for ‘<samp>quiet</samp>’, disables 724printing header information and messages explaining why no modules 725have been printed. 726</p> 727<a name="index-info-module"></a> 728<a name="index-Fortran-modules_002c-information-about"></a> 729<a name="index-functions-and-variables-by-Fortran-module"></a> 730<a name="index-module-functions-and-variables"></a> 731</dd> 732<dt><code>info module functions <span class="roman">[</span>-q<span class="roman">]</span> <span class="roman">[</span>-m <var>module-regexp</var><span class="roman">]</span> <span class="roman">[</span>-t <var>type-regexp</var><span class="roman">]</span> <span class="roman">[</span><var>regexp</var><span class="roman">]</span></code></dt> 733<dt><code>info module variables <span class="roman">[</span>-q<span class="roman">]</span> <span class="roman">[</span>-m <var>module-regexp</var><span class="roman">]</span> <span class="roman">[</span>-t <var>type-regexp</var><span class="roman">]</span> <span class="roman">[</span><var>regexp</var><span class="roman">]</span></code></dt> 734<dd><p>List all functions or variables within all Fortran modules. The set 735of functions or variables listed can be limited by providing some or 736all of the optional regular expressions. If <var>module-regexp</var> is 737provided, then only Fortran modules matching <var>module-regexp</var> will 738be searched. Only functions or variables whose type matches the 739optional regular expression <var>type-regexp</var> will be listed. And 740only functions or variables whose name matches the optional regular 741expression <var>regexp</var> will be listed. 742</p> 743<p>The optional flag ‘<samp>-q</samp>’, which stands for ‘<samp>quiet</samp>’, disables 744printing header information and messages explaining why no functions 745or variables have been printed. 746</p> 747<a name="index-info-classes"></a> 748<a name="index-Objective_002dC_002c-classes-and-selectors"></a> 749</dd> 750<dt><code>info classes</code></dt> 751<dt><code>info classes <var>regexp</var></code></dt> 752<dd><p>Display all Objective-C classes in your program, or 753(with the <var>regexp</var> argument) all those matching a particular regular 754expression. 755</p> 756<a name="index-info-selectors"></a> 757</dd> 758<dt><code>info selectors</code></dt> 759<dt><code>info selectors <var>regexp</var></code></dt> 760<dd><p>Display all Objective-C selectors in your program, or 761(with the <var>regexp</var> argument) all those matching a particular regular 762expression. 763</p> 764 765<a name="index-opaque-data-types"></a> 766<a name="index-set-opaque_002dtype_002dresolution"></a> 767</dd> 768<dt><code>set opaque-type-resolution on</code></dt> 769<dd><p>Tell <small>GDB</small> to resolve opaque types. An opaque type is a type 770declared as a pointer to a <code>struct</code>, <code>class</code>, or 771<code>union</code>—for example, <code>struct MyType *</code>—that is used in one 772source file although the full declaration of <code>struct MyType</code> is in 773another source file. The default is on. 774</p> 775<p>A change in the setting of this subcommand will not take effect until 776the next time symbols for a file are loaded. 777</p> 778</dd> 779<dt><code>set opaque-type-resolution off</code></dt> 780<dd><p>Tell <small>GDB</small> not to resolve opaque types. In this case, the type 781is printed as follows: 782</p><div class="smallexample"> 783<pre class="smallexample">{<no data fields>} 784</pre></div> 785 786<a name="index-show-opaque_002dtype_002dresolution"></a> 787</dd> 788<dt><code>show opaque-type-resolution</code></dt> 789<dd><p>Show whether opaque types are resolved or not. 790</p> 791<a name="index-set-print-symbol_002dloading"></a> 792<a name="index-print-messages-when-symbols-are-loaded"></a> 793</dd> 794<dt><code>set print symbol-loading</code></dt> 795<dt><code>set print symbol-loading full</code></dt> 796<dt><code>set print symbol-loading brief</code></dt> 797<dt><code>set print symbol-loading off</code></dt> 798<dd><p>The <code>set print symbol-loading</code> command allows you to control the 799printing of messages when <small>GDB</small> loads symbol information. 800By default a message is printed for the executable and one for each 801shared library, and normally this is what you want. However, when 802debugging apps with large numbers of shared libraries these messages 803can be annoying. 804When set to <code>brief</code> a message is printed for each executable, 805and when <small>GDB</small> loads a collection of shared libraries at once 806it will only print one message regardless of the number of shared 807libraries. When set to <code>off</code> no messages are printed. 808</p> 809<a name="index-show-print-symbol_002dloading"></a> 810</dd> 811<dt><code>show print symbol-loading</code></dt> 812<dd><p>Show whether messages will be printed when a <small>GDB</small> command 813entered from the keyboard causes symbol information to be loaded. 814</p> 815<a name="index-maint-print-symbols"></a> 816<a name="index-symbol-dump"></a> 817<a name="index-maint-print-psymbols"></a> 818<a name="index-partial-symbol-dump"></a> 819<a name="index-maint-print-msymbols"></a> 820<a name="index-minimal-symbol-dump"></a> 821</dd> 822<dt><code>maint print symbols <span class="roman">[</span>-pc <var>address</var><span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span></code></dt> 823<dt><code>maint print symbols <span class="roman">[</span>-objfile <var>objfile</var><span class="roman">]</span> <span class="roman">[</span>-source <var>source</var><span class="roman">]</span> <span class="roman">[</span>--<span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span></code></dt> 824<dt><code>maint print psymbols <span class="roman">[</span>-objfile <var>objfile</var><span class="roman">]</span> <span class="roman">[</span>-pc <var>address</var><span class="roman">]</span> <span class="roman">[</span>--<span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span></code></dt> 825<dt><code>maint print psymbols <span class="roman">[</span>-objfile <var>objfile</var><span class="roman">]</span> <span class="roman">[</span>-source <var>source</var><span class="roman">]</span> <span class="roman">[</span>--<span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span></code></dt> 826<dt><code>maint print msymbols <span class="roman">[</span>-objfile <var>objfile</var><span class="roman">]</span> <span class="roman">[</span>--<span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span></code></dt> 827<dd><p>Write a dump of debugging symbol data into the file <var>filename</var> or 828the terminal if <var>filename</var> is unspecified. 829If <code>-objfile <var>objfile</var></code> is specified, only dump symbols for 830that objfile. 831If <code>-pc <var>address</var></code> is specified, only dump symbols for the file 832with code at that address. Note that <var>address</var> may be a symbol like 833<code>main</code>. 834If <code>-source <var>source</var></code> is specified, only dump symbols for that 835source file. 836</p> 837<p>These commands are used to debug the <small>GDB</small> symbol-reading code. 838These commands do not modify internal <small>GDB</small> state, therefore 839‘<samp>maint print symbols</samp>’ will only print symbols for already expanded symbol 840tables. 841You can use the command <code>info sources</code> to find out which files these are. 842If you use ‘<samp>maint print psymbols</samp>’ instead, the dump shows information 843about symbols that <small>GDB</small> only knows partially—that is, symbols 844defined in files that <small>GDB</small> has skimmed, but not yet read completely. 845Finally, ‘<samp>maint print msymbols</samp>’ just dumps “minimal symbols”, e.g., 846“ELF symbols”. 847</p> 848<p>See <a href="Files.html#Files">Commands to Specify Files</a>, for a discussion of how 849<small>GDB</small> reads symbols (in the description of <code>symbol-file</code>). 850</p> 851<a name="index-maint-info-symtabs"></a> 852<a name="index-maint-info-psymtabs"></a> 853<a name="index-listing-GDB_0027s-internal-symbol-tables"></a> 854<a name="index-symbol-tables_002c-listing-GDB_0027s-internal"></a> 855<a name="index-full-symbol-tables_002c-listing-GDB_0027s-internal"></a> 856<a name="index-partial-symbol-tables_002c-listing-GDB_0027s-internal"></a> 857</dd> 858<dt><code>maint info symtabs <span class="roman">[</span> <var>regexp</var> <span class="roman">]</span></code></dt> 859<dt><code>maint info psymtabs <span class="roman">[</span> <var>regexp</var> <span class="roman">]</span></code></dt> 860<dd> 861<p>List the <code>struct symtab</code> or <code>struct partial_symtab</code> 862structures whose names match <var>regexp</var>. If <var>regexp</var> is not 863given, list them all. The output includes expressions which you can 864copy into a <small>GDB</small> debugging this one to examine a particular 865structure in more detail. For example: 866</p> 867<div class="smallexample"> 868<pre class="smallexample">(gdb) maint info psymtabs dwarf2read 869{ objfile /home/gnu/build/gdb/gdb 870 ((struct objfile *) 0x82e69d0) 871 { psymtab /home/gnu/src/gdb/dwarf2read.c 872 ((struct partial_symtab *) 0x8474b10) 873 readin no 874 fullname (null) 875 text addresses 0x814d3c8 -- 0x8158074 876 globals (* (struct partial_symbol **) 0x8507a08 @ 9) 877 statics (* (struct partial_symbol **) 0x40e95b78 @ 2882) 878 dependencies (none) 879 } 880} 881(gdb) maint info symtabs 882(gdb) 883</pre></div> 884<p>We see that there is one partial symbol table whose filename contains 885the string ‘<samp>dwarf2read</samp>’, belonging to the ‘<samp>gdb</samp>’ executable; 886and we see that <small>GDB</small> has not read in any symtabs yet at all. 887If we set a breakpoint on a function, that will cause <small>GDB</small> to 888read the symtab for the compilation unit containing that function: 889</p> 890<div class="smallexample"> 891<pre class="smallexample">(gdb) break dwarf2_psymtab_to_symtab 892Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c, 893line 1574. 894(gdb) maint info symtabs 895{ objfile /home/gnu/build/gdb/gdb 896 ((struct objfile *) 0x82e69d0) 897 { symtab /home/gnu/src/gdb/dwarf2read.c 898 ((struct symtab *) 0x86c1f38) 899 dirname (null) 900 fullname (null) 901 blockvector ((struct blockvector *) 0x86c1bd0) (primary) 902 linetable ((struct linetable *) 0x8370fa0) 903 debugformat DWARF 2 904 } 905} 906(gdb) 907</pre></div> 908 909<a name="index-maint-info-line_002dtable"></a> 910<a name="index-listing-GDB_0027s-internal-line-tables"></a> 911<a name="index-line-tables_002c-listing-GDB_0027s-internal"></a> 912</dd> 913<dt><code>maint info line-table <span class="roman">[</span> <var>regexp</var> <span class="roman">]</span></code></dt> 914<dd> 915<p>List the <code>struct linetable</code> from all <code>struct symtab</code> 916instances whose name matches <var>regexp</var>. If <var>regexp</var> is not 917given, list the <code>struct linetable</code> from all <code>struct symtab</code>. 918</p> 919<a name="index-maint-set-symbol_002dcache_002dsize"></a> 920<a name="index-symbol-cache-size"></a> 921</dd> 922<dt><code>maint set symbol-cache-size <var>size</var></code></dt> 923<dd><p>Set the size of the symbol cache to <var>size</var>. 924The default size is intended to be good enough for debugging 925most applications. This option exists to allow for experimenting 926with different sizes. 927</p> 928<a name="index-maint-show-symbol_002dcache_002dsize"></a> 929</dd> 930<dt><code>maint show symbol-cache-size</code></dt> 931<dd><p>Show the size of the symbol cache. 932</p> 933<a name="index-maint-print-symbol_002dcache"></a> 934<a name="index-symbol-cache_002c-printing-its-contents"></a> 935</dd> 936<dt><code>maint print symbol-cache</code></dt> 937<dd><p>Print the contents of the symbol cache. 938This is useful when debugging symbol cache issues. 939</p> 940<a name="index-maint-print-symbol_002dcache_002dstatistics"></a> 941<a name="index-symbol-cache_002c-printing-usage-statistics"></a> 942</dd> 943<dt><code>maint print symbol-cache-statistics</code></dt> 944<dd><p>Print symbol cache usage statistics. 945This helps determine how well the cache is being utilized. 946</p> 947<a name="index-maint-flush_002dsymbol_002dcache"></a> 948<a name="index-symbol-cache_002c-flushing"></a> 949</dd> 950<dt><code>maint flush-symbol-cache</code></dt> 951<dd><p>Flush the contents of the symbol cache, all entries are removed. 952This command is useful when debugging the symbol cache. 953It is also useful when collecting performance data. 954</p> 955</dd> 956</dl> 957 958<hr> 959<div class="header"> 960<p> 961Next: <a href="Altering.html#Altering" accesskey="n" rel="next">Altering</a>, Previous: <a href="Languages.html#Languages" accesskey="p" rel="previous">Languages</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<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> 962</div> 963 964 965 966</body> 967</html> 968