如何在gdb中打印-0x4(%rbp)? [英] How to print -0x4(%rbp) in gdb?
本文介绍了如何在gdb中打印-0x4(%rbp)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ b
movl $ 0x6,-0x4(%rbp)
在反汇编中有这样的代码: code>
我尝试以这种方式打印该值,但失败:
(gdb)p 0x4(%esp)
表达式中的语法错误,接近'%esp')。
(gdb)p 0x4 + $ esp
算术运算的参数不是数字或布尔值。
如何正确打印?
解决方案
看起来您正在使用64位代码,在这种情况下,您只需要,例如:
(gdb)p $ rbp-0x4
$ 1 =(void *)0x7fff5fbff71c
如果您想查看 这个地址,那么您需要投射 void *
地址,例如
(gdb)p / x *(int *)($ rbp-0x4)
$ 2 = 0x7fff
或者更简洁地使用 x
而不是例如
(gdb)x / w $ rbp-0x4
0x7fff5fbff71c: 0x00007fff
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.
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
这篇关于如何在gdb中打印-0x4(%rbp)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文