我在使用gdb调试我的代码时,遇到了这个问题。gdb显示如下:
(gdb) ni
0x08048ca5 in getbufn ()
(gdb) disas 0x08048c98
Dump of assembler code for function getbufn:
0x08048c89 <+0>: push %ebp
0x08048c8a <+1>: mov %esp,%ebp
0x08048c8c <+3>: sub $0x208,%esp
0x08048c92 <+9>: lea -0x200(%ebp),%eax
0x08048c98 <+15>: mov %eax,(%esp)
0x08048c9b <+18>: call 0x8048bf4 <Gets>
0x08048ca0 <+23>: mov $0x1,%eax
=> 0x08048ca5 <+28>: leave
0x08048ca6 <+29>: ret
End of assembler dump.
(gdb) p /x $ebp
$1 = 0x55683950
(gdb) p /x $esp
$2 = 0x55683748
(gdb) ni
0x08048ca6 in getbufn ()
(gdb) p /x $ebp
$3 = 0x4030201
(gdb) p /x $esp
$4 = 0x55683954
(gdb) x /1xw $esp
0x55683954: 0x55683750
(gdb) si
Cannot access memory at address 0x4030205
(gdb)
0x08048ca6中的代码是“ret”,意思是jmp(%esp), addl 0x4,%esp 所以我想知道为什么gdb的最后一句是“Cannot access memory at address 0x4030205” 是不是应该执行地址0x55683750的指令代码?
谢谢!