如何获取基指针,堆栈指针和保存的基指针的值

时间:2015-03-16 22:01:22

标签: c pointers gdb stack

我知道如何使用gdb和使用信息框架,但我找不到基础,堆栈和保存的基本指针的值。我怎么得到这些?我可以在信息信息框架中找到它们还是我必须做其他事情?

1 个答案:

答案 0 :(得分:3)

info reg将告诉您寄存器的内容,包括堆栈指针(64位x86上的rsp)和64位x86上的基址指针(rbp):

(gdb) info reg
rax            0x401340 4199232
rbx            0x0  0
rcx            0x0  0
rdx            0x7fffffffe608   140737488348680
rsi            0x7fffffffe5f8   140737488348664
rdi            0x0  0
rbp            0x0  0x0
rsp            0x7fffffffe508   0x7fffffffe508
r8             0x7ffff7dd4e80   140737351863936
r9             0x7ffff7dea560   140737351951712
r10            0x7fffffffe2d0   140737488347856
r11            0x7ffff7a50290   140737348174480
r12            0x4013e2 4199394
r13            0x7fffffffe5f0   140737488348656
r14            0x0  0
r15            0x0  0
rip            0x7ffff7a50290   0x7ffff7a50290 <__GI_exit>
eflags         0x202    [ IF ]
cs             0x33 51
ss             0x2b 43
ds             0x0  0
es             0x0  0
fs             0x0  0
gs             0x0  0

其余信息可通过info frame

获取
(gdb) info frame
Stack level 0, frame at 0x7fffffffe510:
 rip = 0x7ffff7a50290 in __GI_exit (exit.c:104); saved rip = 0x40134d
 called by frame at 0x7fffffffe520
 source language c.
 Arglist at 0x7fffffffe500, args: status=0
 Locals at 0x7fffffffe500, Previous frame's sp is 0x7fffffffe510
 Saved registers:
  rip at 0x7fffffffe508