From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7678 invoked by alias); 16 Apr 2006 23:33:33 -0000 Received: (qmail 7670 invoked by uid 22791); 16 Apr 2006 23:33:32 -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; Sun, 16 Apr 2006 23:33:30 +0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.4/8.13.4) with ESMTP id k3GNXMek020519; Mon, 17 Apr 2006 01:33:22 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.6/8.13.6) with ESMTP id k3GNXMJt018641; Mon, 17 Apr 2006 01:33:22 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.6/8.13.6/Submit) id k3GNXLeX004661; Mon, 17 Apr 2006 01:33:21 +0200 (CEST) Date: Mon, 17 Apr 2006 01:33:00 -0000 Message-Id: <200604162333.k3GNXLeX004661@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: nickrob@snap.net.nz CC: gdb@sources.redhat.com In-reply-to: <17474.53281.404673.189792@farnswood.snap.net.nz> (message from Nick Roberts on Mon, 17 Apr 2006 11:15:45 +1200) Subject: Re: info frame References: <17474.53281.404673.189792@farnswood.snap.net.nz> Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00220.txt.bz2 > From: Nick Roberts > Date: Mon, 17 Apr 2006 11:15:45 +1200 > > 'info frame' says that the frame is at a different address (0xbffff710) > to $fp (0xbffff708). This wasn't the case with older versions e.g 5.2.1: > > nickrob/31 gdb myprog > GNU gdb 5.2.1-2mdk (Mandrake Linux) > Copyright 2002 Free Software Foundation, Inc. > ... > (gdb) inf frame > Stack level 0, frame at 0xbffff728: > eip = 0x80484a9 in main (myprog.c:47); saved eip 0x4006015a > called by frame at 0xbffff768 > source language c. > Arglist at 0xbffff728, args: argc=1, argv=0xbffff794 > Locals at 0xbffff728, Previous frame's sp is 0x0 > Saved registers: > ebp at 0xbffff728, eip at 0xbffff72c > (gdb) p $fp > $1 = (void *) 0xbffff728 > > nickrob/32 src/gdb/gdb myprog > GNU gdb 6.4.50.20060405-cvs > Copyright (C) 2006 Free Software Foundation, Inc. > ... > (gdb) info frame > Stack level 0, frame at 0xbffff710: > eip = 0x80484a9 in main (myprog.c:47); saved eip 0x4006015a > source language c. > Arglist at 0xbffff708, args: argc=1, argv=0xbffff774 > Locals at 0xbffff708, Previous frame's sp is 0xbffff710 > Saved registers: > ebp at 0xbffff708, eip at 0xbffff70c > (gdb) p $fp > $1 = (void *) 0xbffff708 > > Can this be right? Yes, current GDB uses the convention that the frame address is the Canonical Frame Address (CFA) as used by the DWARF 2 Call Frame Info (CFI). In general the CFA is the value of the stack pointer when the current function was called. Since on i386 the "call" instruction pushes the return address on the stack, and the "standard" prologue: push %ebp mov %esp,%ebp pushes another 32-bit word onto the stack, which gives the offset 0xbffff710 - 0xbffff708 = 8 that you're seeing. Note that while %ebp is usually used as a frame pointer register, the architecture doesn't actually force you to do that. Nowadays compilers can and will generate frameless functions, and for those, the value %ebp is meaningless. Mark