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=
"Output%20Formats">Output Formats
</a>,
13 Next:
<a rel=
"next" accesskey=
"n" href=
"Memory.html#Memory">Memory
</a>,
14 Previous:
<a rel=
"previous" accesskey=
"p" href=
"Arrays.html#Arrays">Arrays
</a>,
15 Up:
<a rel=
"up" accesskey=
"u" href=
"Data.html#Data">Data
</a>
19 <h3 class=
"section">Output formats
</h3>
21 <p>By default, GDB prints a value according to its data type. Sometimes
22 this is not what you want. For example, you might want to print a number
23 in hex, or a pointer in decimal. Or you might want to view data in memory
24 at a certain address as a character string or as an instruction. To do
25 these things, specify an
<dfn>output format
</dfn> when you print a value.
27 <p>The simplest use of output formats is to say how to print a value
28 already computed. This is done by starting the arguments of the
29 <code>print
</code> command with a slash and a format letter. The format
30 letters supported are:
34 <dd>Regard the bits of the value as an integer, and print the integer in
37 <br><dt><code>d
</code>
38 <dd>Print as integer in signed decimal.
40 <br><dt><code>u
</code>
41 <dd>Print as integer in unsigned decimal.
43 <br><dt><code>o
</code>
44 <dd>Print as integer in octal.
46 <br><dt><code>t
</code>
47 <dd>Print as integer in binary. The letter
<code>t
</code> stands for
"two".
48 <a rel=
"footnote" href=
"#fn-1"><sup>1</sup></a>
50 <br><dt><code>a
</code>
51 <dd>Print as an address, both absolute in hexadecimal and as an offset from
52 the nearest preceding symbol. You can use this format used to discover
53 where (in what function) an unknown address is located:
55 <pre class=
"example"> (gdb) p/a
0x54320
56 $
3 =
0x54320 <_initialize_vx+
396>
59 <p>The command
<code>info symbol
0x54320</code> yields similar results.
60 See
<a href=
"Symbols.html#Symbols">info symbol
</a>.
62 <br><dt><code>c
</code>
63 <dd>Regard as an integer and print it as a character constant.
65 <br><dt><code>f
</code>
66 <dd>Regard the bits of the value as a floating point number and print
67 using typical floating point syntax.
70 <p>For example, to print the program counter in hex (see
<a href=
"Registers.html#Registers">Registers
</a>), type
72 <pre class=
"example"> p/x $pc
75 <p>Note that no space is required before the slash; this is because command
76 names in GDB cannot contain a slash.
78 <p>To reprint the last value in the value history with a different format,
79 you can use the
<code>print
</code> command with just a format and no
80 expression. For example,
<code>p/x
</code> reprints the last value in hex.
82 <div class=
"footnote">
86 <li><a name=
"fn-1"></a>
87 <p><code>b
</code> cannot be used because these format letters are also
88 used with the
<code>x
</code> command, where
<code>b
</code> stands for ``byte'';
89 see
<a href=
"Memory.html#Memory">Examining memory
</a>.
</p>