tags:

views:

123

answers:

2

"Names starting with $ refer to registers (with the values they would have if the program were to return to the stack frame now selected, restoring all registers saved by frames farther in) or else to debugger "convenience" variables (any such name not a known register). Use assignment expressions to give values to convenience variables."

above line are from help print in gdb. can someone please explain above lines.specially which register is being referred here? Thanks.

+1  A: 

It is referring to CPU registers. For example, EAX, ECX, ESP, EIP...

jeffamaphone
in the stack frame automatic variables are stored ,so do auto variables also stored in register at run time.there are register variable as well so what is the difference between auto and register variable if auto variable is also stored in register......?
mawia
Stack allocated variables are stored on the stack, but the compiler, at its option, can optimize those into a register and not waste space on the stack depending on usage. If you build debug with no optimizations, this shouldn't happen (depending on your compiler), but in release mode this is going to happen all the time.
jeffamaphone
+2  A: 

So, according to the man page, print is to "Display the value of an expression." So, these would be talking about the register values in your CPU at the current breakpoint. Here is some detailed information on debugging register values.

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

You can get more information on what registers are available to you with

info registers

and

info all-registers

and then additional information on a particular register with

info registers register_name

Hope this helps!

Shane C. Mason