This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Frame lost after 'leave' and before 'ret' instruction on i386?
- From: Aleksandar Ristovski <aristovski at qnx dot com>
- To: gdb at sourceware dot org
- Date: Fri, 16 May 2008 11:28:20 -0400
- Subject: Frame lost after 'leave' and before 'ret' instruction on i386?
Hello,
I noticed that after 'leave' asm instruction (and before 'ret') one frame will be lost (skipped).
For example:
(gdb) disassemble doSth
Dump of assembler code for function doSth:
0x080484f4 <doSth+0>: push %ebp
0x080484f5 <doSth+1>: mov %esp,%ebp
0x080484f7 <doSth+3>: sub $0x8,%esp
0x080484fa <doSth+6>: sub $0xc,%esp
0x080484fd <doSth+9>: push $0x8048570
0x08048502 <doSth+14>: call 0x8048348 <printf@plt>
0x08048507 <doSth+19>: add $0x10,%esp
0x0804850a <doSth+22>: leave
0x0804850b <doSth+23>: ret
End of assembler dump.
(gdb) info registers
...
eip 0x804850b 0x804850b <doSth+23>
...
(gdb) bt
#0 0x080483c3 in doSth () at main.c:6
#1 0xb7ebffdc in __libc_start_main () from /lib/libc.so.6
#2 0x08048331 in _start ()
(note 'main' that really made the call is missing... e.g., just before "leave" was executed:
(gdb) bt
#0 doSth () at main.c:6
#1 0x080483da in main () at main.c:10
)
What happens is, we have restored the stack pointer but gdb is unaware of that fact and tries to unwind using already unwound value...
how is this supposed to work?