From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5203 invoked by alias); 1 Feb 2002 12:29:37 -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 4916 invoked from network); 1 Feb 2002 12:29:33 -0000 Received: from unknown (HELO compc26.nc3a.nato.int) (195.169.112.86) by sources.redhat.com with SMTP; 1 Feb 2002 12:29:33 -0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by compc26.nc3a.nato.int (Postfix) with ESMTP id 99F0213F3C; Fri, 1 Feb 2002 13:32:11 +0100 (CET) Mail-From: gpc-owner+M415@gnu.de Sun Oct 14 15:28:32 2001 Message-Id: <3.0.6.32.20011013014346.00b8dd40@idefix.wisa.be> X-Sender: pierre@idefix.wisa.be X-Mailer: Perl5 Mail::Internet v1.42 Date: Fri, 01 Feb 2002 04:29:00 -0000 To: levi@localhost.nc3a.nato.int From: levi@localhost.nc3a.nato.int Subject: Re: GDB scope does not work quite right for Pascal Cc: Maurice Lombardi , gdb@sources.redhat.com, core@freepascal.org, gpc@gnu.de In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-SW-Source: 2002-02/txt/msg00005.txt.bz2 At 14:18 12/10/01 -0400, Oldham, Adam wrote: >Yes, I saw some of these threads, but nothing seemed to shed light on fixes >for the scoping of this. It is good to know Ada does this as well so that >maybe us Ada/Pascal people can get together and come up with a fix. > >I submitted code that demonstrates this with my bug report as well.... After some testing on both GNU C and GNU Pascal I discovered that they both use the same method (on djgpp i386 target) The calling frame pointer is passed to the nested function in %ecx register and stored in -4(%ebp) in the function prologue (which does not seem to be handled by skip_prologue function, at least I didn't find anything in version 5.0 sources) So the parent frame is placed in %ecx and stored at offset -4 for GNU gcc or gpc while it is pushed at offset 8 in Free Pascal code. Using -gstabs+ I saw nothing generated to explain the meaning of the %ecx parameter or the -4(%ebp) location. Checking the prologue for this movl %ecx,offset(%ebp) isn't probably sufficient to tell that we are in a nested proc... Moreover this is processor specific, which is bad... Stabs does give info about nesting in the stabs concerning the Consider the following source: int test () { int i = 1; int j; int local () { return j+1; }; j = i+1; return local (); } int main () { printf(" result of test() is %d \n",test()); return 0; } This generates .stabs "local:f(0,1),local,test",36,0,8,_local.3 The ,local,test indicates that local is nested inside test function. But this is not enough as I don't know what happens for instance if parameters are passed by registers... Adding some debug info concerning the location of the parent frame seems like a good idea, no ? The Free Pascal approach to use a pseudo parameter called 'parent_ebp' seems to not be applicable to C as this would be a valid C local variable name. Maybe something beginning with a dollar like for the classes? A similar problem exists for With statements in pascal. Stabs defines even a specific stab number for this but this is also unsupported for now. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pierre Muller To: "Oldham, Adam" , "'Andrew Cagney'" , Daniel Jacobowitz Cc: Maurice Lombardi , gdb@sources.redhat.com, core@freepascal.org, gpc@gnu.de Subject: Re: GDB scope does not work quite right for Pascal Date: Fri, 12 Oct 2001 16:38:00 -0000 Message-ID: <3.0.6.32.20011013014346.00b8dd40@idefix.wisa.be> References: X-SW-Source: 2001-10/msg00135.html Message-ID: <20011012163800.FWgSpIthzne3nKyOUCMfb_tltdhPuUnBNFbShOsWRbE@z> At 14:18 12/10/01 -0400, Oldham, Adam wrote: >Yes, I saw some of these threads, but nothing seemed to shed light on fixes >for the scoping of this. It is good to know Ada does this as well so that >maybe us Ada/Pascal people can get together and come up with a fix. > >I submitted code that demonstrates this with my bug report as well.... After some testing on both GNU C and GNU Pascal I discovered that they both use the same method (on djgpp i386 target) The calling frame pointer is passed to the nested function in %ecx register and stored in -4(%ebp) in the function prologue (which does not seem to be handled by skip_prologue function, at least I didn't find anything in version 5.0 sources) So the parent frame is placed in %ecx and stored at offset -4 for GNU gcc or gpc while it is pushed at offset 8 in Free Pascal code. Using -gstabs+ I saw nothing generated to explain the meaning of the %ecx parameter or the -4(%ebp) location. Checking the prologue for this movl %ecx,offset(%ebp) isn't probably sufficient to tell that we are in a nested proc... Moreover this is processor specific, which is bad... Stabs does give info about nesting in the stabs concerning the Consider the following source: int test () { int i = 1; int j; int local () { return j+1; }; j = i+1; return local (); } int main () { printf(" result of test() is %d \n",test()); return 0; } This generates .stabs "local:f(0,1),local,test",36,0,8,_local.3 The ,local,test indicates that local is nested inside test function. But this is not enough as I don't know what happens for instance if parameters are passed by registers... Adding some debug info concerning the location of the parent frame seems like a good idea, no ? The Free Pascal approach to use a pseudo parameter called 'parent_ebp' seems to not be applicable to C as this would be a valid C local variable name. Maybe something beginning with a dollar like for the classes? A similar problem exists for With statements in pascal. Stabs defines even a specific stab number for this but this is also unsupported for now.