Print the names and values of all registers except floating-point registers (in the selected stack frame).
Print the names and values of all registers, including floating-point registers.
Print the relativized value of each specified register regname. As discussed in detail below, register values are normally relative to the selected stack frame. regname may be any register name valid on the machine you are using, with or without the initial '$'.

8.10 Registers

You can refer to machine register contents, in expressions, as variables with names starting with '$'. The names of registers are different for each machine. Use info registers to view the names used on your machine.

info registers

info all-registers

info registers regname ...

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 pointer3 with3with

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 print it as a floating point value with 'print/f $regname').

3.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; see “Returning from a function” (page 121).

98 Examining Data