From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1060 invoked by alias); 15 Oct 2004 18:50:38 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 1051 invoked from network); 15 Oct 2004 18:50:36 -0000 Received: from unknown (HELO walton.sibelius.xs4all.nl) (82.92.89.47) by sourceware.org with SMTP; 15 Oct 2004 18:50:36 -0000 Received: from elgar.sibelius.xs4all.nl (elgar.sibelius.xs4all.nl [192.168.0.2]) by walton.sibelius.xs4all.nl (8.13.0/8.13.0) with ESMTP id i9FIoZF9019588; Fri, 15 Oct 2004 20:50:36 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (localhost [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.12.6p3/8.12.6) with ESMTP id i9FIoZZO000879; Fri, 15 Oct 2004 20:50:35 +0200 (CEST) (envelope-from kettenis@elgar.sibelius.xs4all.nl) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.12.6p3/8.12.6/Submit) id i9FIoZ0f000876; Fri, 15 Oct 2004 20:50:35 +0200 (CEST) Date: Sat, 16 Oct 2004 11:54:00 -0000 Message-Id: <200410151850.i9FIoZ0f000876@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: david@streamline-computing.com CC: gdb@sources.redhat.com In-reply-to: <1097848160.1773.91.camel@localhost.localdomain> (message from David Lecomber on Fri, 15 Oct 2004 14:49:20 +0100) Subject: Re: i386 prologue References: <1097848160.1773.91.camel@localhost.localdomain> X-SW-Source: 2004-10/txt/msg00334.txt.bz2 From: David Lecomber Content-Type: text/plain Date: Fri, 15 Oct 2004 14:49:20 +0100 The code there seems very specific to GNU compilers, expecting either an "enter" - or a pushl %ebp. Not really; some of the code there is trying to support the System V compiler. But since I've never seen such a compiler, that code patch might have suffered some bit rot. However, the instructions you mention ar really pretty generic. The `enter' instruction's sole purpose is setting up a stack frame (but nobody uses it), and `pushl %ebp; movl %esp, %ebp' is the canonical way to set up a stack frame suggested by the i386 System V psABI. Well, here's what you get from Intel version 7.1 fortran compiler: Dump of assembler code for function test: 0x0804afd0 : push %ebx 0x0804afd1 : mov %esp,%ebx 0x0804afd3 : and $0xfffffff0,%esp 0x0804afd6 : push %edi 0x0804afd7 : push %esi 0x0804afd8 : push %ebp 0x0804afd9 : sub $0x74,%esp 0x0804afdc : movl $0x81d34ac,0x81ad07c 0x0804afe6 : movl $0x81d34a0,0x81ad088 0x0804aff0 : push $0x81ad06c 0x0804aff5 : push $0x4 0x0804aff7 : call 0x816ca94 0x0804affc : push $0x81ad098 0x0804b001 : push $0x0 0x0804b003 : call 0x81698b0 0x0804b008 : add $0x10,%esp 0x0804b00b : test %eax,%eax That's fairly non-standard indeed. This suggests that on some intel processors the above performs better than the almost equivalent: push %ebp mov %esp, %ebx and $0xfffffff0, %esp push %edi push %esi push %ebx I've never seen GCC generate such code. and even: 0x080b71c8 : push %ebp 0x080b71c9 : push %ebx 0x080b71ca : sub $0x34,%esp 0x080b71cd : mov 0x40(%esp),%ebx 0x080b71d1 : mov (%ebx),%edx 0x080b71d3 : movl $0xffffffff,0x81e4588 0x080b71dd : test %edx,%edx 0x080b71df : jle 0x80b7d51 0x080b71e5 : mov 0x84711b0,%eax 0x080b71ea : movl $0xd52,0x81e458c 0x080b71f4 : movl $0xffffffff,0x81e4590 0x080b71fe : mov 0xfffffffc(%eax,%edx,4),%eax 0x080b7202 : cmp $0xfffffffe,%eax 0x080b7205 : je 0x80b7d2f Ah, a frameless leaf-function. I think GCC nowadays generates these too. This seriously upsets things.. the stack becomes absolutely useless!! If there is no other way to unwind the stack, yes. Is there some alternative -- does libunwind offer a solution? Or is the prologue stuff the Right Thing To Do [TM]? Last time I looked libunwind doesn't even try to unwind frameless functions. The solution is to get the compiler to generate unwind information. GCC can generate DWARF2 Call Frame Info, which GDB can use. I don't know if ICC can do that too. Mark