开发者

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

开发者 https://www.devze.com 2023-02-20 00:02 出处:网络
In the disassembly there\'s such code: movl$0x6,-0x4(%rbp) I try to print the value this way but fails:

In the disassembly there's such code:

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

I try to print the value this way but fails:

(gdb) p  0x4(%esp)
A syntax error in expression, near `%开发者_如何学JAVAesp)'.
(gdb) p 0x4+$esp
Argument to arithmetic operation not a number or boolean.

How to print it correctly?


It looks like you're working with 64 bit code, in which case you just need, e.g.:

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

If you want to see what's actually at this address, then you need to cast the void * address, e.g.

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

or, more succinctly, use x instead of p, e.g.

(gdb) x /w $rbp-0x4
0x7fff5fbff71c: 0x00007fff
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号