如何在 gdb 中打印 -0x4(%rbp)? [英] How to print -0x4(%rbp) in gdb?
本文介绍了如何在 gdb 中打印 -0x4(%rbp)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
反汇编中有这样的代码:
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 `%esp)'.
(gdb) p 0x4+$esp
Argument to arithmetic operation not a number or boolean.
如何正确打印?
推荐答案
看起来你正在使用 64 位代码,在这种情况下你只需要,例如:
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
如果你想查看 在这个地址实际上是什么,那么你需要转换 void *
地址,例如
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
或者,更简洁地说,使用 x
代替 p
,例如
or, more succinctly, use x
instead of p
, e.g.
(gdb) x /w $rbp-0x4
0x7fff5fbff71c: 0x00007fff
这篇关于如何在 gdb 中打印 -0x4(%rbp)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文