80
Chapter 10. Examining Data
gdb has four "standard" register names that are available (in expressions) on most machines--whenever
they do not conflict with an architecture’s canonical mnemonics for registers. The register names
$pc
and
$sp
are used for the program counter register and the stack pointer.
$fp
is used for a register that
contains a pointer to the current stack frame, and
$ps
is used for a register that contains the processor
status. For example, you could print the program counter in hex with
p/x $pc
or print the instruction to be executed next with
x/i $pc
or add four to the stack pointer
2
with
set $sp += 4
Whenever possible, these four standard register names are available on your machine even though the
machine has different canonical mnemonics, so long as there is no conflict. The
info registers
command shows the canonical names. For example, on the SPARC,
info registers
displays the
processor status register as
$psr
but you can also refer to it as
$ps
; and on x86-based machines
$ps
is an alias for the eflags register.
gdb always considers the contents of an ordinary register as an integer when the register is examined
in this way. Some machines have special registers which can hold nothing but floating point; these
registers are considered to have floating point values. There is no way to refer to the contents of
an ordinary register as floating point value (although you can
it as a floating point value with
print/f $
regname
).
Some registers have distinct "raw" and "virtual" data formats. This means that the data format in which
the register contents are saved by the operating system is not the same one that your program normally
sees. For example, the registers of the 68881 floating point coprocessor are always saved in "extended"
(raw) format, but all C programs expect to work with "double" (virtual) format. In such cases, gdb
normally works with the virtual format only (the format that makes sense for your program), but the
info registers
command prints the data in both formats.
Normally, register values are relative to the selected stack frame (refer to Section 8.3
Selecting a
frame
). This means that you get the value that the register would contain if all stack frames farther in
were exited and their saved registers restored. In order to see the true contents of hardware registers,
you must select the innermost frame (with
frame 0
).
However, gdb must deduce where registers are saved, from the machine code generated by your com-
piler. If some registers are not saved, or if gdb is unable to locate the saved registers, the selected stack
frame makes no difference.
2. This is a way of removing one word from the stack, on machines where stacks grow downward in memory
(most machines, nowadays). This assumes that the innermost stack frame is selected; setting
$sp
is not allowed
when other stack frames are selected. To pop entire frames off the stack, regardless of machine architecture, use
return
; (refer to Section 16.4
Returning from a function
.
Содержание ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Страница 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Страница 12: ...2 Chapter 1 Debugging with gdb ...
Страница 28: ...18 Chapter 4 Getting In and Out of gdb ...
Страница 34: ...24 Chapter 5 gdb Commands ...
Страница 44: ...34 Chapter 6 Running Programs Under gdb ...
Страница 68: ...58 Chapter 8 Examining the Stack ...
Страница 98: ...88 Chapter 10 Examining Data ...
Страница 112: ...102 Chapter 12 Tracepoints ...
Страница 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Страница 138: ...128 Chapter 14 Using gdb with Different Languages ...
Страница 144: ...134 Chapter 15 Examining the Symbol Table ...
Страница 170: ...160 Chapter 19 Debugging remote programs ...
Страница 198: ...188 Chapter 21 Controlling gdb ...
Страница 204: ...194 Chapter 22 Canned Sequences of Commands ...
Страница 206: ...196 Chapter 23 Command Interpreters ...
Страница 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Страница 296: ...286 Chapter 27 gdb Annotations ...
Страница 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Страница 322: ...312 Chapter 30 Using History Interactively ...
Страница 362: ...352 Appendix D gdb Remote Serial Protocol ...
Страница 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Страница 386: ...376 Appendix G GNU Free Documentation License ...
Страница 410: ......