toolchain/share/doc/gdb/Symbols.html

677 lines
42 KiB
HTML

<html lang="en">
<head>
<title>Symbols - Debugging with GDB</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Debugging with GDB">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="Languages.html#Languages" title="Languages">
<link rel="next" href="Altering.html#Altering" title="Altering">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988-2019 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software'' and ``Free Software Needs
Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.
(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
this GNU Manual. Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom.''
-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="Symbols"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Altering.html#Altering">Altering</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Languages.html#Languages">Languages</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>
<h2 class="chapter">16 Examining the Symbol Table</h2>
<p>The commands described in this chapter allow you to inquire about the
symbols (names of variables, functions and types) defined in your
program. This information is inherent in the text of your program and
does not change as your program executes. <span class="sc">gdb</span> finds it in your
program's symbol table, in the file indicated when you started <span class="sc">gdb</span>
(see <a href="File-Options.html#File-Options">Choosing Files</a>), or by one of the
file-management commands (see <a href="Files.html#Files">Commands to Specify Files</a>).
<p><a name="index-symbol-names-1097"></a><a name="index-names-of-symbols-1098"></a><a name="index-quoting-names-1099"></a><a name="quoting-names"></a>Occasionally, you may need to refer to symbols that contain unusual
characters, which <span class="sc">gdb</span> ordinarily treats as word delimiters. The
most frequent case is in referring to static variables in other
source files (see <a href="Variables.html#Variables">Program Variables</a>). File names
are recorded in object files as debugging symbols, but <span class="sc">gdb</span> would
ordinarily parse a typical file name, like <samp><span class="file">foo.c</span></samp>, as the three words
&lsquo;<samp><span class="samp">foo</span></samp>&rsquo; &lsquo;<samp><span class="samp">.</span></samp>&rsquo; &lsquo;<samp><span class="samp">c</span></samp>&rsquo;. To allow <span class="sc">gdb</span> to recognize
&lsquo;<samp><span class="samp">foo.c</span></samp>&rsquo; as a single symbol, enclose it in single quotes; for example,
<pre class="smallexample"> p 'foo.c'::x
</pre>
<p class="noindent">looks up the value of <code>x</code> in the scope of the file <samp><span class="file">foo.c</span></samp>.
<a name="index-case_002dinsensitive-symbol-names-1100"></a>
<a name="index-case-sensitivity-in-symbol-names-1101"></a>
<a name="index-set-case_002dsensitive-1102"></a>
<dl><dt><code>set case-sensitive on</code><dt><code>set case-sensitive off</code><dt><code>set case-sensitive auto</code><dd>Normally, when <span class="sc">gdb</span> looks up symbols, it matches their names
with case sensitivity determined by the current source language.
Occasionally, you may wish to control that. The command <code>set
case-sensitive</code> lets you do that by specifying <code>on</code> for
case-sensitive matches or <code>off</code> for case-insensitive ones. If
you specify <code>auto</code>, case sensitivity is reset to the default
suitable for the source language. The default is case-sensitive
matches for all languages except for Fortran, for which the default is
case-insensitive matches.
<p><a name="index-show-case_002dsensitive-1103"></a><br><dt><code>show case-sensitive</code><dd>This command shows the current setting of case sensitivity for symbols
lookups.
<p><a name="index-set-print-type-methods-1104"></a><br><dt><code>set print type methods</code><dt><code>set print type methods on</code><dt><code>set print type methods off</code><dd>Normally, when <span class="sc">gdb</span> prints a class, it displays any methods
declared in that class. You can control this behavior either by
passing the appropriate flag to <code>ptype</code>, or using <samp><span class="command">set
print type methods</span></samp>. Specifying <code>on</code> will cause <span class="sc">gdb</span> to
display the methods; this is the default. Specifying <code>off</code> will
cause <span class="sc">gdb</span> to omit the methods.
<p><a name="index-show-print-type-methods-1105"></a><br><dt><code>show print type methods</code><dd>This command shows the current setting of method display when printing
classes.
<p><a name="index-set-print-type-nested_002dtype_002dlimit-1106"></a><br><dt><code>set print type nested-type-limit </code><var>limit</var><dt><code>set print type nested-type-limit unlimited</code><dd>Set the limit of displayed nested types that the type printer will
show. A <var>limit</var> of <code>unlimited</code> or <code>-1</code> will show all
nested definitions. By default, the type printer will not show any nested
types defined in classes.
<p><a name="index-show-print-type-nested_002dtype_002dlimit-1107"></a><br><dt><code>show print type nested-type-limit</code><dd>This command shows the current display limit of nested types when
printing classes.
<p><a name="index-set-print-type-typedefs-1108"></a><br><dt><code>set print type typedefs</code><dt><code>set print type typedefs on</code><dt><code>set print type typedefs off</code><dd>
Normally, when <span class="sc">gdb</span> prints a class, it displays any typedefs
defined in that class. You can control this behavior either by
passing the appropriate flag to <code>ptype</code>, or using <samp><span class="command">set
print type typedefs</span></samp>. Specifying <code>on</code> will cause <span class="sc">gdb</span> to
display the typedef definitions; this is the default. Specifying
<code>off</code> will cause <span class="sc">gdb</span> to omit the typedef definitions.
Note that this controls whether the typedef definition itself is
printed, not whether typedef names are substituted when printing other
types.
<p><a name="index-show-print-type-typedefs-1109"></a><br><dt><code>show print type typedefs</code><dd>This command shows the current setting of typedef display when
printing classes.
<p><a name="index-info-address-1110"></a><a name="index-address-of-a-symbol-1111"></a><br><dt><code>info address </code><var>symbol</var><dd>Describe where the data for <var>symbol</var> is stored. For a register
variable, this says which register it is kept in. For a non-register
local variable, this prints the stack-frame offset at which the variable
is always stored.
<p>Note the contrast with &lsquo;<samp><span class="samp">print &amp;</span><var>symbol</var></samp>&rsquo;, which does not work
at all for a register variable, and for a stack local variable prints
the exact address of the current instantiation of the variable.
<p><a name="index-info-symbol-1112"></a><a name="index-symbol-from-address-1113"></a><a name="index-closest-symbol-and-offset-for-an-address-1114"></a><br><dt><code>info symbol </code><var>addr</var><dd>Print the name of a symbol which is stored at the address <var>addr</var>.
If no symbol is stored exactly at <var>addr</var>, <span class="sc">gdb</span> prints the
nearest symbol and an offset from it:
<pre class="smallexample"> (gdb) info symbol 0x54320
_initialize_vx + 396 in section .text
</pre>
<p class="noindent">This is the opposite of the <code>info address</code> command. You can use
it to find out the name of a variable or a function given its address.
<p>For dynamically linked executables, the name of executable or shared
library containing the symbol is also printed:
<pre class="smallexample"> (gdb) info symbol 0x400225
_start + 5 in section .text of /tmp/a.out
(gdb) info symbol 0x2aaaac2811cf
__read_nocancel + 6 in section .text of /usr/lib64/libc.so.6
</pre>
<p><a name="index-demangle-1115"></a><a name="index-demangle-1116"></a><br><dt><code>demangle </code><span class="roman">[</span><code>-l </code><var>language</var><span class="roman">]</span> <span class="roman">[</span><var>&ndash;</var><span class="roman">]</span> <var>name</var><dd>Demangle <var>name</var>.
If <var>language</var> is provided it is the name of the language to demangle
<var>name</var> in. Otherwise <var>name</var> is demangled in the current language.
<p>The &lsquo;<samp><span class="samp">--</span></samp>&rsquo; option specifies the end of options,
and is useful when <var>name</var> begins with a dash.
<p>The parameter <code>demangle-style</code> specifies how to interpret the kind
of mangling used. See <a href="Print-Settings.html#Print-Settings">Print Settings</a>.
<p><a name="index-whatis-1117"></a><br><dt><code>whatis[/</code><var>flags</var><code>] [</code><var>arg</var><code>]</code><dd>Print the data type of <var>arg</var>, which can be either an expression
or a name of a data type. With no argument, print the data type of
<code>$</code>, the last value in the value history.
<p>If <var>arg</var> is an expression (see <a href="Expressions.html#Expressions">Expressions</a>), it
is not actually evaluated, and any side-effecting operations (such as
assignments or function calls) inside it do not take place.
<p>If <var>arg</var> is a variable or an expression, <code>whatis</code> prints its
literal type as it is used in the source code. If the type was
defined using a <code>typedef</code>, <code>whatis</code> will <em>not</em> print
the data type underlying the <code>typedef</code>. If the type of the
variable or the expression is a compound data type, such as
<code>struct</code> or <code>class</code>, <code>whatis</code> never prints their
fields or methods. It just prints the <code>struct</code>/<code>class</code>
name (a.k.a. its <dfn>tag</dfn>). If you want to see the members of
such a compound data type, use <code>ptype</code>.
<p>If <var>arg</var> is a type name that was defined using <code>typedef</code>,
<code>whatis</code> <dfn>unrolls</dfn> only one level of that <code>typedef</code>.
Unrolling means that <code>whatis</code> will show the underlying type used
in the <code>typedef</code> declaration of <var>arg</var>. However, if that
underlying type is also a <code>typedef</code>, <code>whatis</code> will not
unroll it.
<p>For C code, the type names may also have the form &lsquo;<samp><span class="samp">class
</span><var>class-name</var></samp>&rsquo;, &lsquo;<samp><span class="samp">struct </span><var>struct-tag</var></samp>&rsquo;, &lsquo;<samp><span class="samp">union
</span><var>union-tag</var></samp>&rsquo; or &lsquo;<samp><span class="samp">enum </span><var>enum-tag</var></samp>&rsquo;.
<p><var>flags</var> can be used to modify how the type is displayed.
Available flags are:
<dl>
<dt><code>r</code><dd>Display in &ldquo;raw&rdquo; form. Normally, <span class="sc">gdb</span> substitutes template
parameters and typedefs defined in a class when printing the class'
members. The <code>/r</code> flag disables this.
<br><dt><code>m</code><dd>Do not print methods defined in the class.
<br><dt><code>M</code><dd>Print methods defined in the class. This is the default, but the flag
exists in case you change the default with <samp><span class="command">set print type methods</span></samp>.
<br><dt><code>t</code><dd>Do not print typedefs defined in the class. Note that this controls
whether the typedef definition itself is printed, not whether typedef
names are substituted when printing other types.
<br><dt><code>T</code><dd>Print typedefs defined in the class. This is the default, but the flag
exists in case you change the default with <samp><span class="command">set print type typedefs</span></samp>.
<br><dt><code>o</code><dd>Print the offsets and sizes of fields in a struct, similar to what the
<samp><span class="command">pahole</span></samp> tool does. This option implies the <code>/tm</code> flags.
<p>For example, given the following declarations:
<pre class="smallexample"> struct tuv
{
int a1;
char *a2;
int a3;
};
struct xyz
{
int f1;
char f2;
void *f3;
struct tuv f4;
};
union qwe
{
struct tuv fff1;
struct xyz fff2;
};
struct tyu
{
int a1 : 1;
int a2 : 3;
int a3 : 23;
char a4 : 2;
int64_t a5;
int a6 : 5;
int64_t a7 : 3;
};
</pre>
<p>Issuing a <kbd>ptype /o struct tuv</kbd> command would print:
<pre class="smallexample"> (gdb) ptype /o struct tuv
/* offset | size */ type = struct tuv {
/* 0 | 4 */ int a1;
/* XXX 4-byte hole */
/* 8 | 8 */ char *a2;
/* 16 | 4 */ int a3;
/* total size (bytes): 24 */
}
</pre>
<p>Notice the format of the first column of comments. There, you can
find two parts separated by the &lsquo;<samp><span class="samp">|</span></samp>&rsquo; character: the <em>offset</em>,
which indicates where the field is located inside the struct, in
bytes, and the <em>size</em> of the field. Another interesting line is
the marker of a <em>hole</em> in the struct, indicating that it may be
possible to pack the struct and make it use less space by reorganizing
its fields.
<p>It is also possible to print offsets inside an union:
<pre class="smallexample"> (gdb) ptype /o union qwe
/* offset | size */ type = union qwe {
/* 24 */ struct tuv {
/* 0 | 4 */ int a1;
/* XXX 4-byte hole */
/* 8 | 8 */ char *a2;
/* 16 | 4 */ int a3;
/* total size (bytes): 24 */
} fff1;
/* 40 */ struct xyz {
/* 0 | 4 */ int f1;
/* 4 | 1 */ char f2;
/* XXX 3-byte hole */
/* 8 | 8 */ void *f3;
/* 16 | 24 */ struct tuv {
/* 16 | 4 */ int a1;
/* XXX 4-byte hole */
/* 24 | 8 */ char *a2;
/* 32 | 4 */ int a3;
/* total size (bytes): 24 */
} f4;
/* total size (bytes): 40 */
} fff2;
/* total size (bytes): 40 */
}
</pre>
<p>In this case, since <code>struct tuv</code> and <code>struct xyz</code> occupy the
same space (because we are dealing with an union), the offset is not
printed for them. However, you can still examine the offset of each
of these structures' fields.
<p>Another useful scenario is printing the offsets of a struct containing
bitfields:
<pre class="smallexample"> (gdb) ptype /o struct tyu
/* offset | size */ type = struct tyu {
/* 0:31 | 4 */ int a1 : 1;
/* 0:28 | 4 */ int a2 : 3;
/* 0: 5 | 4 */ int a3 : 23;
/* 3: 3 | 1 */ signed char a4 : 2;
/* XXX 3-bit hole */
/* XXX 4-byte hole */
/* 8 | 8 */ int64_t a5;
/* 16:27 | 4 */ int a6 : 5;
/* 16:56 | 8 */ int64_t a7 : 3;
/* total size (bytes): 24 */
}
</pre>
<p>Note how the offset information is now extended to also include how
many bits are left to be used in each bitfield.
</dl>
<p><a name="index-ptype-1118"></a><br><dt><code>ptype[/</code><var>flags</var><code>] [</code><var>arg</var><code>]</code><dd><code>ptype</code> accepts the same arguments as <code>whatis</code>, but prints a
detailed description of the type, instead of just the name of the type.
See <a href="Expressions.html#Expressions">Expressions</a>.
<p>Contrary to <code>whatis</code>, <code>ptype</code> always unrolls any
<code>typedef</code>s in its argument declaration, whether the argument is
a variable, expression, or a data type. This means that <code>ptype</code>
of a variable or an expression will not print literally its type as
present in the source code&mdash;use <code>whatis</code> for that. <code>typedef</code>s at
the pointer or reference targets are also unrolled. Only <code>typedef</code>s of
fields, methods and inner <code>class typedef</code>s of <code>struct</code>s,
<code>class</code>es and <code>union</code>s are not unrolled even with <code>ptype</code>.
<p>For example, for this variable declaration:
<pre class="smallexample"> typedef double real_t;
struct complex { real_t real; double imag; };
typedef struct complex complex_t;
complex_t var;
real_t *real_pointer_var;
</pre>
<p class="noindent">the two commands give this output:
<pre class="smallexample"> (gdb) whatis var
type = complex_t
(gdb) ptype var
type = struct complex {
real_t real;
double imag;
}
(gdb) whatis complex_t
type = struct complex
(gdb) whatis struct complex
type = struct complex
(gdb) ptype struct complex
type = struct complex {
real_t real;
double imag;
}
(gdb) whatis real_pointer_var
type = real_t *
(gdb) ptype real_pointer_var
type = double *
</pre>
<p class="noindent">As with <code>whatis</code>, using <code>ptype</code> without an argument refers to
the type of <code>$</code>, the last value in the value history.
<p><a name="index-incomplete-type-1119"></a>Sometimes, programs use opaque data types or incomplete specifications
of complex data structure. If the debug information included in the
program does not allow <span class="sc">gdb</span> to display a full declaration of
the data type, it will say &lsquo;<samp><span class="samp">&lt;incomplete type&gt;</span></samp>&rsquo;. For example,
given these declarations:
<pre class="smallexample"> struct foo;
struct foo *fooptr;
</pre>
<p class="noindent">but no definition for <code>struct foo</code> itself, <span class="sc">gdb</span> will say:
<pre class="smallexample"> (gdb) ptype foo
$1 = &lt;incomplete type&gt;
</pre>
<p class="noindent">&ldquo;Incomplete type&rdquo; is C terminology for data types that are not
completely specified.
<p><a name="index-unknown-type-1120"></a>Othertimes, information about a variable's type is completely absent
from the debug information included in the program. This most often
happens when the program or library where the variable is defined
includes no debug information at all. <span class="sc">gdb</span> knows the variable
exists from inspecting the linker/loader symbol table (e.g., the ELF
dynamic symbol table), but such symbols do not contain type
information. Inspecting the type of a (global) variable for which
<span class="sc">gdb</span> has no type information shows:
<pre class="smallexample"> (gdb) ptype var
type = &lt;data variable, no debug info&gt;
</pre>
<p>See <a href="Variables.html#Variables">no debug info variables</a>, for how to print the values
of such variables.
<p><a name="index-info-types-1121"></a><br><dt><code>info types </code><var>regexp</var><dt><code>info types</code><dd>Print a brief description of all types whose names match the regular
expression <var>regexp</var> (or all types in your program, if you supply
no argument). Each complete typename is matched as though it were a
complete line; thus, &lsquo;<samp><span class="samp">i type value</span></samp>&rsquo; gives information on all
types in your program whose names include the string <code>value</code>, but
&lsquo;<samp><span class="samp">i type ^value$</span></samp>&rsquo; gives information only on types whose complete
name is <code>value</code>.
<p>In programs using different languages, <span class="sc">gdb</span> chooses the syntax
to print the type description according to the
&lsquo;<samp><span class="samp">set language</span></samp>&rsquo; value: using &lsquo;<samp><span class="samp">set language auto</span></samp>&rsquo;
(see <a href="Automatically.html#Automatically">Set Language Automatically</a>) means to use the
language of the type, other values mean to use
the manually specified language (see <a href="Manually.html#Manually">Set Language Manually</a>).
<p>This command differs from <code>ptype</code> in two ways: first, like
<code>whatis</code>, it does not print a detailed description; second, it
lists all source files and line numbers where a type is defined.
<p><a name="index-info-type_002dprinters-1122"></a><br><dt><code>info type-printers</code><dd>Versions of <span class="sc">gdb</span> that ship with Python scripting enabled may
have &ldquo;type printers&rdquo; available. When using <samp><span class="command">ptype</span></samp> or
<samp><span class="command">whatis</span></samp>, these printers are consulted when the name of a type
is needed. See <a href="Type-Printing-API.html#Type-Printing-API">Type Printing API</a>, for more information on writing
type printers.
<p><code>info type-printers</code> displays all the available type printers.
<p><a name="index-enable-type_002dprinter-1123"></a><a name="index-disable-type_002dprinter-1124"></a><br><dt><code>enable type-printer </code><var>name</var><code>...</code><br><dt><code>disable type-printer </code><var>name</var><code>...</code><dd>These commands can be used to enable or disable type printers.
<p><a name="index-info-scope-1125"></a><a name="index-local-variables-1126"></a><br><dt><code>info scope </code><var>location</var><dd>List all the variables local to a particular scope. This command
accepts a <var>location</var> argument&mdash;a function name, a source line, or
an address preceded by a &lsquo;<samp><span class="samp">*</span></samp>&rsquo;, and prints all the variables local
to the scope defined by that location. (See <a href="Specify-Location.html#Specify-Location">Specify Location</a>, for
details about supported forms of <var>location</var>.) For example:
<pre class="smallexample"> (gdb) <b>info scope command_line_handler</b>
Scope for command_line_handler:
Symbol rl is an argument at stack/frame offset 8, length 4.
Symbol linebuffer is in static storage at address 0x150a18, length 4.
Symbol linelength is in static storage at address 0x150a1c, length 4.
Symbol p is a local variable in register $esi, length 4.
Symbol p1 is a local variable in register $ebx, length 4.
Symbol nline is a local variable in register $edx, length 4.
Symbol repeat is a local variable at frame offset -8, length 4.
</pre>
<p class="noindent">This command is especially useful for determining what data to collect
during a <dfn>trace experiment</dfn>, see <a href="Tracepoint-Actions.html#Tracepoint-Actions">collect</a>.
<p><a name="index-info-source-1127"></a><br><dt><code>info source</code><dd>Show information about the current source file&mdash;that is, the source file for
the function containing the current point of execution:
<ul>
<li>the name of the source file, and the directory containing it,
<li>the directory it was compiled in,
<li>its length, in lines,
<li>which programming language it is written in,
<li>if the debug information provides it, the program that compiled the file
(which may include, e.g., the compiler version and command line arguments),
<li>whether the executable includes debugging information for that file, and
if so, what format the information is in (e.g., STABS, Dwarf 2, etc.), and
<li>whether the debugging information includes information about
preprocessor macros.
</ul>
<p><a name="index-info-sources-1128"></a><br><dt><code>info sources</code><dd>Print the names of all source files in your program for which there is
debugging information, organized into two lists: files whose symbols
have already been read, and files whose symbols will be read when needed.
<p><a name="index-info-functions-1129"></a><br><dt><code>info functions [-q]</code><dd>Print the names and data types of all defined functions.
Similarly to &lsquo;<samp><span class="samp">info types</span></samp>&rsquo;, this command groups its output by source
files and annotates each function definition with its source line
number.
<p>In programs using different languages, <span class="sc">gdb</span> chooses the syntax
to print the function name and type according to the
&lsquo;<samp><span class="samp">set language</span></samp>&rsquo; value: using &lsquo;<samp><span class="samp">set language auto</span></samp>&rsquo;
(see <a href="Automatically.html#Automatically">Set Language Automatically</a>) means to use the
language of the function, other values mean to use
the manually specified language (see <a href="Manually.html#Manually">Set Language Manually</a>).
<p>The optional flag &lsquo;<samp><span class="samp">-q</span></samp>&rsquo;, which stands for &lsquo;<samp><span class="samp">quiet</span></samp>&rsquo;, disables
printing header information and messages explaining why no functions
have been printed.
<br><dt><code>info functions [-q] [-t </code><var>type_regexp</var><code>] [</code><var>regexp</var><code>]</code><dd>Like &lsquo;<samp><span class="samp">info functions</span></samp>&rsquo;, but only print the names and data types
of the functions selected with the provided regexp(s).
<p>If <var>regexp</var> is provided, print only the functions whose names
match the regular expression <var>regexp</var>.
Thus, &lsquo;<samp><span class="samp">info fun step</span></samp>&rsquo; finds all functions whose
names include <code>step</code>; &lsquo;<samp><span class="samp">info fun ^step</span></samp>&rsquo; finds those whose names
start with <code>step</code>. If a function name contains characters that
conflict with the regular expression language (e.g.
&lsquo;<samp><span class="samp">operator*()</span></samp>&rsquo;), they may be quoted with a backslash.
<p>If <var>type_regexp</var> is provided, print only the functions whose
types, as printed by the <code>whatis</code> command, match
the regular expression <var>type_regexp</var>.
If <var>type_regexp</var> contains space(s), it should be enclosed in
quote characters. If needed, use backslash to escape the meaning
of special characters or quotes.
Thus, &lsquo;<samp><span class="samp">info fun -t '^int ('</span></samp>&rsquo; finds the functions that return
an integer; &lsquo;<samp><span class="samp">info fun -t '(.*int.*'</span></samp>&rsquo; finds the functions that
have an argument type containing int; &lsquo;<samp><span class="samp">info fun -t '^int (' ^step</span></samp>&rsquo;
finds the functions whose names start with <code>step</code> and that return
int.
<p>If both <var>regexp</var> and <var>type_regexp</var> are provided, a function
is printed only if its name matches <var>regexp</var> and its type matches
<var>type_regexp</var>.
<p><a name="index-info-variables-1130"></a><br><dt><code>info variables [-q]</code><dd>Print the names and data types of all variables that are defined
outside of functions (i.e. excluding local variables).
The printed variables are grouped by source files and annotated with
their respective source line numbers.
<p>In programs using different languages, <span class="sc">gdb</span> chooses the syntax
to print the variable name and type according to the
&lsquo;<samp><span class="samp">set language</span></samp>&rsquo; value: using &lsquo;<samp><span class="samp">set language auto</span></samp>&rsquo;
(see <a href="Automatically.html#Automatically">Set Language Automatically</a>) means to use the
language of the variable, other values mean to use
the manually specified language (see <a href="Manually.html#Manually">Set Language Manually</a>).
<p>The optional flag &lsquo;<samp><span class="samp">-q</span></samp>&rsquo;, which stands for &lsquo;<samp><span class="samp">quiet</span></samp>&rsquo;, disables
printing header information and messages explaining why no variables
have been printed.
<br><dt><code>info variables [-q] [-t </code><var>type_regexp</var><code>] [</code><var>regexp</var><code>]</code><dd>Like <kbd>info variables</kbd>, but only print the variables selected
with the provided regexp(s).
<p>If <var>regexp</var> is provided, print only the variables whose names
match the regular expression <var>regexp</var>.
<p>If <var>type_regexp</var> is provided, print only the variables whose
types, as printed by the <code>whatis</code> command, match
the regular expression <var>type_regexp</var>.
If <var>type_regexp</var> contains space(s), it should be enclosed in
quote characters. If needed, use backslash to escape the meaning
of special characters or quotes.
<p>If both <var>regexp</var> and <var>type_regexp</var> are provided, an argument
is printed only if its name matches <var>regexp</var> and its type matches
<var>type_regexp</var>.
<p><a name="index-info-classes-1131"></a><a name="index-Objective_002dC_002c-classes-and-selectors-1132"></a><br><dt><code>info classes</code><dt><code>info classes </code><var>regexp</var><dd>Display all Objective-C classes in your program, or
(with the <var>regexp</var> argument) all those matching a particular regular
expression.
<p><a name="index-info-selectors-1133"></a><br><dt><code>info selectors</code><dt><code>info selectors </code><var>regexp</var><dd>Display all Objective-C selectors in your program, or
(with the <var>regexp</var> argument) all those matching a particular regular
expression.
<p><a name="index-opaque-data-types-1134"></a><a name="index-set-opaque_002dtype_002dresolution-1135"></a><br><dt><code>set opaque-type-resolution on</code><dd>Tell <span class="sc">gdb</span> to resolve opaque types. An opaque type is a type
declared as a pointer to a <code>struct</code>, <code>class</code>, or
<code>union</code>&mdash;for example, <code>struct MyType *</code>&mdash;that is used in one
source file although the full declaration of <code>struct MyType</code> is in
another source file. The default is on.
<p>A change in the setting of this subcommand will not take effect until
the next time symbols for a file are loaded.
<br><dt><code>set opaque-type-resolution off</code><dd>Tell <span class="sc">gdb</span> not to resolve opaque types. In this case, the type
is printed as follows:
<pre class="smallexample"> {&lt;no data fields&gt;}
</pre>
<p><a name="index-show-opaque_002dtype_002dresolution-1136"></a><br><dt><code>show opaque-type-resolution</code><dd>Show whether opaque types are resolved or not.
<p><a name="index-set-print-symbol_002dloading-1137"></a><a name="index-print-messages-when-symbols-are-loaded-1138"></a><br><dt><code>set print symbol-loading</code><dt><code>set print symbol-loading full</code><dt><code>set print symbol-loading brief</code><dt><code>set print symbol-loading off</code><dd>The <code>set print symbol-loading</code> command allows you to control the
printing of messages when <span class="sc">gdb</span> loads symbol information.
By default a message is printed for the executable and one for each
shared library, and normally this is what you want. However, when
debugging apps with large numbers of shared libraries these messages
can be annoying.
When set to <code>brief</code> a message is printed for each executable,
and when <span class="sc">gdb</span> loads a collection of shared libraries at once
it will only print one message regardless of the number of shared
libraries. When set to <code>off</code> no messages are printed.
<p><a name="index-show-print-symbol_002dloading-1139"></a><br><dt><code>show print symbol-loading</code><dd>Show whether messages will be printed when a <span class="sc">gdb</span> command
entered from the keyboard causes symbol information to be loaded.
<p><a name="index-maint-print-symbols-1140"></a><a name="index-symbol-dump-1141"></a><a name="index-maint-print-psymbols-1142"></a><a name="index-partial-symbol-dump-1143"></a><a name="index-maint-print-msymbols-1144"></a><a name="index-minimal-symbol-dump-1145"></a><br><dt><code>maint print symbols </code><span class="roman">[</span><code>-pc </code><var>address</var><span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span><dt><code>maint print symbols </code><span class="roman">[</span><code>-objfile </code><var>objfile</var><span class="roman">]</span> <span class="roman">[</span><code>-source </code><var>source</var><span class="roman">]</span> <span class="roman">[</span><code>--</code><span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span><dt><code>maint print psymbols </code><span class="roman">[</span><code>-objfile </code><var>objfile</var><span class="roman">]</span> <span class="roman">[</span><code>-pc </code><var>address</var><span class="roman">]</span> <span class="roman">[</span><code>--</code><span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span><dt><code>maint print psymbols </code><span class="roman">[</span><code>-objfile </code><var>objfile</var><span class="roman">]</span> <span class="roman">[</span><code>-source </code><var>source</var><span class="roman">]</span> <span class="roman">[</span><code>--</code><span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span><dt><code>maint print msymbols </code><span class="roman">[</span><code>-objfile </code><var>objfile</var><span class="roman">]</span> <span class="roman">[</span><code>--</code><span class="roman">]</span> <span class="roman">[</span><var>filename</var><span class="roman">]</span><dd>Write a dump of debugging symbol data into the file <var>filename</var> or
the terminal if <var>filename</var> is unspecified.
If <code>-objfile </code><var>objfile</var> is specified, only dump symbols for
that objfile.
If <code>-pc </code><var>address</var> is specified, only dump symbols for the file
with code at that address. Note that <var>address</var> may be a symbol like
<code>main</code>.
If <code>-source </code><var>source</var> is specified, only dump symbols for that
source file.
<p>These commands are used to debug the <span class="sc">gdb</span> symbol-reading code.
These commands do not modify internal <span class="sc">gdb</span> state, therefore
&lsquo;<samp><span class="samp">maint print symbols</span></samp>&rsquo; will only print symbols for already expanded symbol
tables.
You can use the command <code>info sources</code> to find out which files these are.
If you use &lsquo;<samp><span class="samp">maint print psymbols</span></samp>&rsquo; instead, the dump shows information
about symbols that <span class="sc">gdb</span> only knows partially&mdash;that is, symbols
defined in files that <span class="sc">gdb</span> has skimmed, but not yet read completely.
Finally, &lsquo;<samp><span class="samp">maint print msymbols</span></samp>&rsquo; just dumps &ldquo;minimal symbols&rdquo;, e.g.,
&ldquo;ELF symbols&rdquo;.
<p>See <a href="Files.html#Files">Commands to Specify Files</a>, for a discussion of how
<span class="sc">gdb</span> reads symbols (in the description of <code>symbol-file</code>).
<p><a name="index-maint-info-symtabs-1146"></a><a name="index-maint-info-psymtabs-1147"></a><a name="index-listing-_0040value_007bGDBN_007d_0027s-internal-symbol-tables-1148"></a><a name="index-symbol-tables_002c-listing-_0040value_007bGDBN_007d_0027s-internal-1149"></a><a name="index-full-symbol-tables_002c-listing-_0040value_007bGDBN_007d_0027s-internal-1150"></a><a name="index-partial-symbol-tables_002c-listing-_0040value_007bGDBN_007d_0027s-internal-1151"></a><br><dt><code>maint info symtabs </code><span class="roman">[</span> <var>regexp</var> <span class="roman">]</span><dt><code>maint info psymtabs </code><span class="roman">[</span> <var>regexp</var> <span class="roman">]</span><dd>
List the <code>struct symtab</code> or <code>struct partial_symtab</code>
structures whose names match <var>regexp</var>. If <var>regexp</var> is not
given, list them all. The output includes expressions which you can
copy into a <span class="sc">gdb</span> debugging this one to examine a particular
structure in more detail. For example:
<pre class="smallexample"> (gdb) maint info psymtabs dwarf2read
{ objfile /home/gnu/build/gdb/gdb
((struct objfile *) 0x82e69d0)
{ psymtab /home/gnu/src/gdb/dwarf2read.c
((struct partial_symtab *) 0x8474b10)
readin no
fullname (null)
text addresses 0x814d3c8 -- 0x8158074
globals (* (struct partial_symbol **) 0x8507a08 @ 9)
statics (* (struct partial_symbol **) 0x40e95b78 @ 2882)
dependencies (none)
}
}
(gdb) maint info symtabs
(gdb)
</pre>
<p class="noindent">We see that there is one partial symbol table whose filename contains
the string &lsquo;<samp><span class="samp">dwarf2read</span></samp>&rsquo;, belonging to the &lsquo;<samp><span class="samp">gdb</span></samp>&rsquo; executable;
and we see that <span class="sc">gdb</span> has not read in any symtabs yet at all.
If we set a breakpoint on a function, that will cause <span class="sc">gdb</span> to
read the symtab for the compilation unit containing that function:
<pre class="smallexample"> (gdb) break dwarf2_psymtab_to_symtab
Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
line 1574.
(gdb) maint info symtabs
{ objfile /home/gnu/build/gdb/gdb
((struct objfile *) 0x82e69d0)
{ symtab /home/gnu/src/gdb/dwarf2read.c
((struct symtab *) 0x86c1f38)
dirname (null)
fullname (null)
blockvector ((struct blockvector *) 0x86c1bd0) (primary)
linetable ((struct linetable *) 0x8370fa0)
debugformat DWARF 2
}
}
(gdb)
</pre>
<p><a name="index-maint-info-line_002dtable-1152"></a><a name="index-listing-_0040value_007bGDBN_007d_0027s-internal-line-tables-1153"></a><a name="index-line-tables_002c-listing-_0040value_007bGDBN_007d_0027s-internal-1154"></a><br><dt><code>maint info line-table </code><span class="roman">[</span> <var>regexp</var> <span class="roman">]</span><dd>
List the <code>struct linetable</code> from all <code>struct symtab</code>
instances whose name matches <var>regexp</var>. If <var>regexp</var> is not
given, list the <code>struct linetable</code> from all <code>struct symtab</code>.
<p><a name="index-maint-set-symbol_002dcache_002dsize-1155"></a><a name="index-symbol-cache-size-1156"></a><br><dt><code>maint set symbol-cache-size </code><var>size</var><dd>Set the size of the symbol cache to <var>size</var>.
The default size is intended to be good enough for debugging
most applications. This option exists to allow for experimenting
with different sizes.
<p><a name="index-maint-show-symbol_002dcache_002dsize-1157"></a><br><dt><code>maint show symbol-cache-size</code><dd>Show the size of the symbol cache.
<p><a name="index-maint-print-symbol_002dcache-1158"></a><a name="index-symbol-cache_002c-printing-its-contents-1159"></a><br><dt><code>maint print symbol-cache</code><dd>Print the contents of the symbol cache.
This is useful when debugging symbol cache issues.
<p><a name="index-maint-print-symbol_002dcache_002dstatistics-1160"></a><a name="index-symbol-cache_002c-printing-usage-statistics-1161"></a><br><dt><code>maint print symbol-cache-statistics</code><dd>Print symbol cache usage statistics.
This helps determine how well the cache is being utilized.
<p><a name="index-maint-flush_002dsymbol_002dcache-1162"></a><a name="index-symbol-cache_002c-flushing-1163"></a><br><dt><code>maint flush-symbol-cache</code><dd>Flush the contents of the symbol cache, all entries are removed.
This command is useful when debugging the symbol cache.
It is also useful when collecting performance data.
</dl>
</body></html>