• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/gdb/
1<html lang="en">
2<head>
3<title>Output Formats - 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.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Data.html#Data" title="Data">
9<link rel="prev" href="Arrays.html#Arrays" title="Arrays">
10<link rel="next" href="Memory.html#Memory" title="Memory">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988-2013 Free Software Foundation, Inc.
14
15Permission is granted to copy, distribute and/or modify this document
16under the terms of the GNU Free Documentation License, Version 1.3 or
17any later version published by the Free Software Foundation; with the
18Invariant Sections being ``Free Software'' and ``Free Software Needs
19Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
20and with the Back-Cover Texts as in (a) below.
21
22(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
23this GNU Manual.  Buying copies from GNU Press supports the FSF in
24developing GNU and promoting software freedom.''
25-->
26<meta http-equiv="Content-Style-Type" content="text/css">
27<style type="text/css"><!--
28  pre.display { font-family:inherit }
29  pre.format  { font-family:inherit }
30  pre.smalldisplay { font-family:inherit; font-size:smaller }
31  pre.smallformat  { font-family:inherit; font-size:smaller }
32  pre.smallexample { font-size:smaller }
33  pre.smalllisp    { font-size:smaller }
34  span.sc    { font-variant:small-caps }
35  span.roman { font-family:serif; font-weight:normal; } 
36  span.sansserif { font-family:sans-serif; font-weight:normal; } 
37--></style>
38<link rel="stylesheet" type="text/css" href="../cs.css">
39</head>
40<body>
41<div class="node">
42<a name="Output-Formats"></a>
43<p>
44Next:&nbsp;<a rel="next" accesskey="n" href="Memory.html#Memory">Memory</a>,
45Previous:&nbsp;<a rel="previous" accesskey="p" href="Arrays.html#Arrays">Arrays</a>,
46Up:&nbsp;<a rel="up" accesskey="u" href="Data.html#Data">Data</a>
47<hr>
48</div>
49
50<h3 class="section">10.5 Output Formats</h3>
51
52<p><a name="index-formatted-output-569"></a><a name="index-output-formats-570"></a>By default, <span class="sc">gdb</span> prints a value according to its data type.  Sometimes
53this is not what you want.  For example, you might want to print a number
54in hex, or a pointer in decimal.  Or you might want to view data in memory
55at a certain address as a character string or as an instruction.  To do
56these things, specify an <dfn>output format</dfn> when you print a value.
57
58   <p>The simplest use of output formats is to say how to print a value
59already computed.  This is done by starting the arguments of the
60<code>print</code> command with a slash and a format letter.  The format
61letters supported are:
62
63     <dl>
64<dt><code>x</code><dd>Regard the bits of the value as an integer, and print the integer in
65hexadecimal.
66
67     <br><dt><code>d</code><dd>Print as integer in signed decimal.
68
69     <br><dt><code>u</code><dd>Print as integer in unsigned decimal.
70
71     <br><dt><code>o</code><dd>Print as integer in octal.
72
73     <br><dt><code>t</code><dd>Print as integer in binary.  The letter &lsquo;<samp><span class="samp">t</span></samp>&rsquo; stands for &ldquo;two&rdquo;. 
74<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
75
76     <br><dt><code>a</code><dd><a name="index-unknown-address_002c-locating-571"></a><a name="index-locate-address-572"></a>Print as an address, both absolute in hexadecimal and as an offset from
77the nearest preceding symbol.  You can use this format used to discover
78where (in what function) an unknown address is located:
79
80     <pre class="smallexample">          (gdb) p/a 0x54320
81          $3 = 0x54320 &lt;_initialize_vx+396&gt;
82</pre>
83     <p class="noindent">The command <code>info symbol 0x54320</code> yields similar results. 
84See <a href="Symbols.html#Symbols">info symbol</a>.
85
86     <br><dt><code>c</code><dd>Regard as an integer and print it as a character constant.  This
87prints both the numerical value and its character representation.  The
88character representation is replaced with the octal escape &lsquo;<samp><span class="samp">\nnn</span></samp>&rsquo;
89for characters outside the 7-bit <span class="sc">ascii</span> range.
90
91     <p>Without this format, <span class="sc">gdb</span> displays <code>char</code>,
92<code>unsigned&nbsp;char</code><!-- /@w -->, and <code>signed&nbsp;char</code><!-- /@w --> data as character
93constants.  Single-byte members of vectors are displayed as integer
94data.
95
96     <br><dt><code>f</code><dd>Regard the bits of the value as a floating point number and print
97using typical floating point syntax.
98
99     <br><dt><code>s</code><dd><a name="index-printing-strings-573"></a><a name="index-printing-byte-arrays-574"></a>Regard as a string, if possible.  With this format, pointers to single-byte
100data are displayed as null-terminated strings and arrays of single-byte data
101are displayed as fixed-length strings.  Other values are displayed in their
102natural types.
103
104     <p>Without this format, <span class="sc">gdb</span> displays pointers to and arrays of
105<code>char</code>, <code>unsigned&nbsp;char</code><!-- /@w -->, and <code>signed&nbsp;char</code><!-- /@w --> as
106strings.  Single-byte members of a vector are displayed as an integer
107array.
108
109     <br><dt><code>z</code><dd>Like &lsquo;<samp><span class="samp">x</span></samp>&rsquo; formatting, the value is treated as an integer and
110printed as hexadecimal, but leading zeros are printed to pad the value
111to the size of the integer type.
112
113     <br><dt><code>r</code><dd><a name="index-raw-printing-575"></a>Print using the &lsquo;<samp><span class="samp">raw</span></samp>&rsquo; formatting.  By default, <span class="sc">gdb</span> will
114use a Python-based pretty-printer, if one is available (see <a href="Pretty-Printing.html#Pretty-Printing">Pretty Printing</a>).  This typically results in a higher-level display of the
115value's contents.  The &lsquo;<samp><span class="samp">r</span></samp>&rsquo; format bypasses any Python
116pretty-printer which might exist. 
117</dl>
118
119   <p>For example, to print the program counter in hex (see <a href="Registers.html#Registers">Registers</a>), type
120
121<pre class="smallexample">     p/x $pc
122</pre>
123   <p class="noindent">Note that no space is required before the slash; this is because command
124names in <span class="sc">gdb</span> cannot contain a slash.
125
126   <p>To reprint the last value in the value history with a different format,
127you can use the <code>print</code> command with just a format and no
128expression.  For example, &lsquo;<samp><span class="samp">p/x</span></samp>&rsquo; reprints the last value in hex.
129
130   <div class="footnote">
131<hr>
132<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> &lsquo;<samp><span class="samp">b</span></samp>&rsquo; cannot be used because these format letters are also
133used with the <code>x</code> command, where &lsquo;<samp><span class="samp">b</span></samp>&rsquo; stands for &ldquo;byte&rdquo;;
134see <a href="Memory.html#Memory">Examining Memory</a>.</p>
135
136   <hr></div>
137
138   </body></html>
139
140