3 <title>Debugging with GDB
</title>
4 <meta http-equiv=
"Content-Type" content=
"text/html">
5 <meta name=
"description" content=
"Debugging with GDB">
6 <meta name=
"generator" content=
"makeinfo 4.3">
7 <link href=
"http://www.gnu.org/software/texinfo/" rel=
"generator-home">
12 Node:
<a name=
"Data">Data
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Tracepoints.html#Tracepoints">Tracepoints
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Source.html#Source">Source
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"index.html#Top">Top
</a>
19 <h2 class=
"chapter">Examining Data
</h2>
21 <p>The usual way to examine data in your program is with the
<code>print
</code>
22 command (abbreviated
<code>p
</code>), or its synonym
<code>inspect
</code>. It
23 evaluates and prints the value of an expression of the language your
24 program is written in (see
<a href=
"Languages.html#Languages">Using GDB with Different Languages
</a>).
27 <dt><code>print
</code><var>expr
</var><code></code>
28 <dd><dt><code>print /
</code><var>f
</var><code> </code><var>expr
</var><code></code>
29 <dd><var>expr
</var> is an expression (in the source language). By default the
30 value of
<var>expr
</var> is printed in a format appropriate to its data type;
31 you can choose a different format by specifying
<code>/
</code><var>f
</var><code></code>, where
32 <var>f
</var> is a letter specifying the format; see
<a href=
"Output-Formats.html#Output%20Formats">Output formats
</a>.
34 <br><dt><code>print
</code>
35 <dd><dt><code>print /
</code><var>f
</var><code></code>
36 <dd>If you omit
<var>expr
</var>, GDB displays the last value again (from the
37 <dfn>value history
</dfn>; see
<a href=
"Value-History.html#Value%20History">Value history
</a>). This allows you to
38 conveniently inspect the same value in an alternative format.
41 <p>A more low-level way of examining data is with the
<code>x
</code> command.
42 It examines data in memory at a specified address and prints it in a
43 specified format. See
<a href=
"Memory.html#Memory">Examining memory
</a>.
45 <p>If you are interested in information about types, or about how the
46 fields of a struct or a class are declared, use the
<code>ptype
</code><var>exp
</var><code></code>
47 command rather than
<code>print
</code>. See
<a href=
"Symbols.html#Symbols">Examining the Symbol Table
</a>.
50 <li><a accesskey=
"1" href=
"Expressions.html#Expressions">Expressions
</a>: Expressions
51 <li><a accesskey=
"2" href=
"Variables.html#Variables">Variables
</a>: Program variables
52 <li><a accesskey=
"3" href=
"Arrays.html#Arrays">Arrays
</a>: Artificial arrays
53 <li><a accesskey=
"4" href=
"Output-Formats.html#Output%20Formats">Output Formats
</a>: Output formats
54 <li><a accesskey=
"5" href=
"Memory.html#Memory">Memory
</a>: Examining memory
55 <li><a accesskey=
"6" href=
"Auto-Display.html#Auto%20Display">Auto Display
</a>: Automatic display
56 <li><a accesskey=
"7" href=
"Print-Settings.html#Print%20Settings">Print Settings
</a>: Print settings
57 <li><a accesskey=
"8" href=
"Value-History.html#Value%20History">Value History
</a>: Value history
58 <li><a accesskey=
"9" href=
"Convenience-Vars.html#Convenience%20Vars">Convenience Vars
</a>: Convenience variables
59 <li><a href=
"Registers.html#Registers">Registers
</a>: Registers
60 <li><a href=
"Floating-Point-Hardware.html#Floating%20Point%20Hardware">Floating Point Hardware
</a>: Floating point hardware
61 <li><a href=
"Memory-Region-Attributes.html#Memory%20Region%20Attributes">Memory Region Attributes
</a>: Memory region attributes