• 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>Registers - 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="Convenience-Funs.html#Convenience-Funs" title="Convenience Funs">
10<link rel="next" href="Floating-Point-Hardware.html#Floating-Point-Hardware" title="Floating Point Hardware">
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="Registers"></a>
43<p>
44Next:&nbsp;<a rel="next" accesskey="n" href="Floating-Point-Hardware.html#Floating-Point-Hardware">Floating Point Hardware</a>,
45Previous:&nbsp;<a rel="previous" accesskey="p" href="Convenience-Funs.html#Convenience-Funs">Convenience Funs</a>,
46Up:&nbsp;<a rel="up" accesskey="u" href="Data.html#Data">Data</a>
47<hr>
48</div>
49
50<h3 class="section">10.13 Registers</h3>
51
52<p><a name="index-registers-659"></a>You can refer to machine register contents, in expressions, as variables
53with names starting with &lsquo;<samp><span class="samp">$</span></samp>&rsquo;.  The names of registers are different
54for each machine; use <code>info registers</code> to see the names used on
55your machine.
56
57     
58<a name="index-info-registers-660"></a>
59<dl><dt><code>info registers</code><dd>Print the names and values of all registers except floating-point
60and vector registers (in the selected stack frame).
61
62     <p><a name="index-info-all_002dregisters-661"></a><a name="index-floating-point-registers-662"></a><br><dt><code>info all-registers</code><dd>Print the names and values of all registers, including floating-point
63and vector registers (in the selected stack frame).
64
65     <br><dt><code>info registers </code><var>regname</var><code> ...</code><dd>Print the <dfn>relativized</dfn> value of each specified register <var>regname</var>. 
66As discussed in detail below, register values are normally relative to
67the selected stack frame.  <var>regname</var> may be any register name valid on
68the machine you are using, with or without the initial &lsquo;<samp><span class="samp">$</span></samp>&rsquo;. 
69</dl>
70
71   <p><a name="index-stack-pointer-register-663"></a><a name="index-program-counter-register-664"></a><a name="index-process-status-register-665"></a><a name="index-frame-pointer-register-666"></a><a name="index-standard-registers-667"></a><span class="sc">gdb</span> has four &ldquo;standard&rdquo; register names that are available (in
72expressions) on most machines&mdash;whenever they do not conflict with an
73architecture's canonical mnemonics for registers.  The register names
74<code>$pc</code> and <code>$sp</code> are used for the program counter register and
75the stack pointer.  <code>$fp</code> is used for a register that contains a
76pointer to the current stack frame, and <code>$ps</code> is used for a
77register that contains the processor status.  For example,
78you could print the program counter in hex with
79
80<pre class="smallexample">     p/x $pc
81</pre>
82   <p class="noindent">or print the instruction to be executed next with
83
84<pre class="smallexample">     x/i $pc
85</pre>
86   <p class="noindent">or add four to the stack pointer<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> with
87
88<pre class="smallexample">     set $sp += 4
89</pre>
90   <p>Whenever possible, these four standard register names are available on
91your machine even though the machine has different canonical mnemonics,
92so long as there is no conflict.  The <code>info registers</code> command
93shows the canonical names.  For example, on the SPARC, <code>info
94registers</code> displays the processor status register as <code>$psr</code> but you
95can also refer to it as <code>$ps</code>; and on x86-based machines <code>$ps</code>
96is an alias for the <span class="sc">eflags</span> register.
97
98   <p><span class="sc">gdb</span> always considers the contents of an ordinary register as an
99integer when the register is examined in this way.  Some machines have
100special registers which can hold nothing but floating point; these
101registers are considered to have floating point values.  There is no way
102to refer to the contents of an ordinary register as floating point value
103(although you can <em>print</em> it as a floating point value with
104&lsquo;<samp><span class="samp">print/f $</span><var>regname</var></samp>&rsquo;).
105
106   <p>Some registers have distinct &ldquo;raw&rdquo; and &ldquo;virtual&rdquo; data formats.  This
107means that the data format in which the register contents are saved by
108the operating system is not the same one that your program normally
109sees.  For example, the registers of the 68881 floating point
110coprocessor are always saved in &ldquo;extended&rdquo; (raw) format, but all C
111programs expect to work with &ldquo;double&rdquo; (virtual) format.  In such
112cases, <span class="sc">gdb</span> normally works with the virtual format only (the format
113that makes sense for your program), but the <code>info registers</code> command
114prints the data in both formats.
115
116   <p><a name="index-SSE-registers-_0028x86_0029-668"></a><a name="index-MMX-registers-_0028x86_0029-669"></a>Some machines have special registers whose contents can be interpreted
117in several different ways.  For example, modern x86-based machines
118have SSE and MMX registers that can hold several values packed
119together in several different formats.  <span class="sc">gdb</span> refers to such
120registers in <code>struct</code> notation:
121
122<pre class="smallexample">     (gdb) print $xmm1
123     $1 = {
124       v4_float = {0, 3.43859137e-038, 1.54142831e-044, 1.821688e-044},
125       v2_double = {9.92129282474342e-303, 2.7585945287983262e-313},
126       v16_int8 = "\000\000\000\000\3706;\001\v\000\000\000\r\000\000",
127       v8_int16 = {0, 0, 14072, 315, 11, 0, 13, 0},
128       v4_int32 = {0, 20657912, 11, 13},
129       v2_int64 = {88725056443645952, 55834574859},
130       uint128 = 0x0000000d0000000b013b36f800000000
131     }
132</pre>
133   <p class="noindent">To set values of such registers, you need to tell <span class="sc">gdb</span> which
134view of the register you wish to change, as if you were assigning
135value to a <code>struct</code> member:
136
137<pre class="smallexample">      (gdb) set $xmm1.uint128 = 0x000000000000000000000000FFFFFFFF
138</pre>
139   <p>Normally, register values are relative to the selected stack frame
140(see <a href="Selection.html#Selection">Selecting a Frame</a>).  This means that you get the
141value that the register would contain if all stack frames farther in
142were exited and their saved registers restored.  In order to see the
143true contents of hardware registers, you must select the innermost
144frame (with &lsquo;<samp><span class="samp">frame 0</span></samp>&rsquo;).
145
146   <p>However, <span class="sc">gdb</span> must deduce where registers are saved, from the machine
147code generated by your compiler.  If some registers are not saved, or if
148<span class="sc">gdb</span> is unable to locate the saved registers, the selected stack
149frame makes no difference.
150
151   <div class="footnote">
152<hr>
153<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> This is a way of removing
154one word from the stack, on machines where stacks grow downward in
155memory (most machines, nowadays).  This assumes that the innermost
156stack frame is selected; setting <code>$sp</code> is not allowed when other
157stack frames are selected.  To pop entire frames off the stack,
158regardless of machine architecture, use <code>return</code>;
159see <a href="Returning.html#Returning">Returning from a Function</a>.</p>
160
161   <hr></div>
162
163   </body></html>
164
165