How to print -0x4 (% rbp) in gdb?

The disassembly has the following code:

movl $0x6,-0x4(%rbp) 

I try to print the value this way, but it fails:

 (gdb) p 0x4(%esp) A syntax error in expression, near `%esp)'. (gdb) p 0x4+$esp Argument to arithmetic operation not a number or boolean. 

How to print it?

+6
cpu-registers gdb
source share
1 answer

It looks like you are working with 64-bit code, in which case you just need to, for example:

 (gdb) p $rbp-0x4 $1 = (void *) 0x7fff5fbff71c 

If you want to see what is actually at this address, you need to specify a void * address, for example.

 (gdb) p /x *(int *)($rbp-0x4) $2 = 0x7fff 

or, more succinctly, use x instead of p , for example

 (gdb) x /w $rbp-0x4 0x7fff5fbff71c: 0x00007fff 
+13
source share

All Articles