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