From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24790 invoked by alias); 16 May 2008 17:24:24 -0000 Received: (qmail 24777 invoked by uid 22791); 16 May 2008 17:24:23 -0000 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 16 May 2008 17:24:06 +0000 Received: from brahms.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by brahms.sibelius.xs4all.nl (8.14.1/8.14.1) with ESMTP id m4GHNvv7011791; Fri, 16 May 2008 19:23:57 +0200 (CEST) Received: (from kettenis@localhost) by brahms.sibelius.xs4all.nl (8.14.1/8.14.1/Submit) id m4GHNvWv024856; Fri, 16 May 2008 19:23:57 +0200 (CEST) Date: Fri, 16 May 2008 17:24:00 -0000 Message-Id: <200805161723.m4GHNvWv024856@brahms.sibelius.xs4all.nl> From: Mark Kettenis To: aristovski@qnx.com CC: gdb@sourceware.org In-reply-to: <482DA814.7030703@qnx.com> (message from Aleksandar Ristovski on Fri, 16 May 2008 11:28:20 -0400) Subject: Re: Frame lost after 'leave' and before 'ret' instruction on i386? References: <482DA814.7030703@qnx.com> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00130.txt.bz2 > Date: Fri, 16 May 2008 11:28:20 -0400 > From: Aleksandar Ristovski > > 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 : push %ebp > 0x080484f5 : mov %esp,%ebp > 0x080484f7 : sub $0x8,%esp > 0x080484fa : sub $0xc,%esp > 0x080484fd : push $0x8048570 > 0x08048502 : call 0x8048348 > 0x08048507 : add $0x10,%esp > 0x0804850a : leave > 0x0804850b : ret > End of assembler dump. > (gdb) info registers > ... > eip 0x804850b 0x804850b > ... > (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? The compiler is supposed to give us unwind info for the function's epilogue, but unfortunately GCC doesn't. There's not much we can do about it in GDB. Fortunately it isnt an issue that users see a lot.