Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* GDB scope does not work quite right for Pascal
  2002-02-01  4:29 ` GDB scope does not work quite right for Pascal levi
@ 2001-10-12  8:29   ` Pierre Muller
  2001-10-12  9:58   ` Maurice Lombardi
  1 sibling, 0 replies; 12+ messages in thread
From: Pierre Muller @ 2001-10-12  8:29 UTC (permalink / raw)
  To: adam.oldham; +Cc: gdb, core, gpc

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3015 bytes --]

At 14:44 12/10/01 , vous avez écrit:

> >Number:         222
> >Category:       gdb
> >Synopsis:       GDB scope does not work quite right for Pascal
> >Confidential:   no
> >Severity:       non-critical
> >Priority:       medium
> >Responsible:    unassigned
> >State:          open
> >Class:          sw-bug
> >Submitter-Id:   net
> >Arrival-Date:   Fri Oct 12 05:48:01 PDT 2001
> >Closed-Date:
> >Last-Modified:
> >Originator:     Adam Oldham
> >Release:        gdb 20010813
> >Organization:
> >Environment:
>Mandrake 8.1, Kernel 2.4.8, glibc 2.2, Intel Platform
> >Description:
>Source is compiled with FPC (Free Pascal Compiler).  This can happen with 
>any source of pascal.  When you declare nested functions, gdb's scope does 
>not allow the viewing of the variables that are from the parent function 
>that should be within the scope.
> >How-To-Repeat:
>The simple program attached will produce the problem.  When compiled and 
>run, the correct output is displayed, but if you run GDB on it, and break 
>on function test2 and print out int1 which is a global variable for the 
>function test1, you receive:
>"No symbol "INT1" in current context."

   There are several remarks to that bug report:
   1) I don't know at all how nested functions work in C
Are they allowed? Do they also use a paremt fram pushing method ?
If yes, can locals from the calling function be found in C?
Maybe someone from the gdb mailing list can answer that question.
If this is already implemented for C its probably easier to just take
the same method.

   2) There is a solution, I implemented it in the IDE for Free Pascal
but it is rather complicated.
   Let me try to explain this solution to everyone.
   Nested functions in pascal get a hidden parameter that contains the
frame pointer (ebp value for i386 cpu) of the calling function. This allows the
program to access correctly local variable of the function that called the 
nested
function. This value is searched in the backtrace at the location where
the frame pointer are usually saved ( i.e. at offset 0 of the local ebp 
value for i386)
If we find the corresponding frame (which is not always the first frame 
above the current one)
then we can try if we find the unfound local symbol in that frame).

    To ease this search, I inserted a pseudo-parameter to the function called
parent_ebp (in lower case, while normal Free Pascal symbols are uppercased)
that indicate the location of this parnt frame pointer.

3)  As maintainer of the pascal language specific part of GDB,
I am of course willing to introduce this into the gdb sources, but I would
really like to get first some feedback from the gpc list.
    Does gpc do anything about this calling frame hidden parameter ?
Could we agree to use the same method for both compiler
in order to get better support for Pascal ?



Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
  2002-02-01  4:29 ` GDB scope does not work quite right for Pascal levi
  2001-10-12  8:29   ` Pierre Muller
@ 2001-10-12  9:58   ` Maurice Lombardi
  2002-02-01  4:29     ` levi
  2002-02-01  4:29     ` levi
  1 sibling, 2 replies; 12+ messages in thread
From: Maurice Lombardi @ 2001-10-12  9:58 UTC (permalink / raw)
  To: Pierre Muller; +Cc: adam.oldham, gdb, core, gpc

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3449 bytes --]

Pierre Muller wrote:

> At 14:44 12/10/01 , vous avez écrit:
> 
>> >Number:         222
>> >Category:       gdb
>> >Synopsis:       GDB scope does not work quite right for Pascal
>> >Confidential:   no
>> >Severity:       non-critical
>> >Priority:       medium
>> >Responsible:    unassigned
>> >State:          open
>> >Class:          sw-bug
>> >Submitter-Id:   net
>> >Arrival-Date:   Fri Oct 12 05:48:01 PDT 2001
>> >Closed-Date:
>> >Last-Modified:
>> >Originator:     Adam Oldham
>> >Release:        gdb 20010813
>> >Organization:
>> >Environment:
>> Mandrake 8.1, Kernel 2.4.8, glibc 2.2, Intel Platform
>> >Description:
>> Source is compiled with FPC (Free Pascal Compiler).  This can happen 
>> with any source of pascal. 


and any pascal compiler: it happens also for gpc

 When you declare nested functions, gdb's 
>> scope does not allow the viewing of the variables that are from the 
>> parent function that should be within the scope.
>> >How-To-Repeat:
>> The simple program attached will produce the problem.  When compiled 
>> and run, the correct output is displayed, but if you run GDB on it, 
>> and break on function test2 and print out int1 which is a global 
>> variable for the function test1, you receive:
>> "No symbol "INT1" in current context."
> 
> 
>   There are several remarks to that bug report:
>   1) I don't know at all how nested functions work in C
> Are they allowed? 


AKAIK no, they are not allowed, and this is the root of the problem,
since gdb is written mainly by/for C programmers.

> Do they also use a paremt fram pushing method ?
> If yes, can locals from the calling function be found in C?
> Maybe someone from the gdb mailing list can answer that question.
> If this is already implemented for C its probably easier to just take
> the same method.
> 
>   2) There is a solution, I implemented it in the IDE for Free Pascal
> but it is rather complicated.
>   Let me try to explain this solution to everyone.
>   Nested functions in pascal get a hidden parameter that contains the
> frame pointer (ebp value for i386 cpu) of the calling function. This 
> allows the
> program to access correctly local variable of the function that called 
> the nested
> function. This value is searched in the backtrace at the location where
> the frame pointer are usually saved ( i.e. at offset 0 of the local ebp 
> value for i386)
> If we find the corresponding frame (which is not always the first frame 
> above the current one)
> then we can try if we find the unfound local symbol in that frame).
> 
>    To ease this search, I inserted a pseudo-parameter to the function 
> called
> parent_ebp (in lower case, while normal Free Pascal symbols are uppercased)
> that indicate the location of this parnt frame pointer.
> 
> 3)  As maintainer of the pascal language specific part of GDB,
> I am of course willing to introduce this into the gdb sources, but I would
> really like to get first some feedback from the gpc list.
>    Does gpc do anything about this calling frame hidden parameter ?
> Could we agree to use the same method for both compiler
> in order to get better support for Pascal ?

Do'nt know, only Peter or Franck probably can tell.

-- 
        Maurice Lombardi
Laboratoire de  Spectrometrie Physique,
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex     FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:Maurice.Lombardi@ujf-grenoble.fr


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
  2002-02-01  4:29     ` levi
@ 2001-10-12 10:16       ` Daniel Jacobowitz
  2002-02-01  4:29       ` levi
  1 sibling, 0 replies; 12+ messages in thread
From: Daniel Jacobowitz @ 2001-10-12 10:16 UTC (permalink / raw)
  To: Maurice Lombardi; +Cc: Pierre Muller, adam.oldham, gdb, core, gpc

On Fri, Oct 12, 2001 at 06:57:32PM +0200, Maurice Lombardi wrote:
> >  There are several remarks to that bug report:
> >  1) I don't know at all how nested functions work in C
> >Are they allowed? 
> 
> 
> AKAIK no, they are not allowed, and this is the root of the problem,
> since gdb is written mainly by/for C programmers.

They aren't allowed by standard C.  GCC does in fact allow them,
although their use isn't recommended.  I think GDB's support for them
is somewhat crusty.


-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
  2002-02-01  4:29       ` levi
@ 2001-10-12 10:40         ` Andrew Cagney
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Cagney @ 2001-10-12 10:40 UTC (permalink / raw)
  To: Daniel Jacobowitz, Pierre Muller
  Cc: Maurice Lombardi, adam.oldham, gdb, core, gpc

> On Fri, Oct 12, 2001 at 06:57:32PM +0200, Maurice Lombardi wrote:
> 
>> > There are several remarks to that bug report:
>> > 1) I don't know at all how nested functions work in C
>> >Are they allowed? 
> 
>> 
>> 
>> AKAIK no, they are not allowed, and this is the root of the problem,
>> since gdb is written mainly by/for C programmers.
> 
> 
> They aren't allowed by standard C.  GCC does in fact allow them,
> although their use isn't recommended.  I think GDB's support for them
> is somewhat crusty.


The thread 
http://sources.redhat.com/ml/gdb-patches/2001-07/msg00714.html is 
probably relevant.

Following on Joel's strategy (Ada) the first thing needed is probably a 
testcase so that people know the status of the underlying code

Andrew



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
  2001-10-12  9:58   ` Maurice Lombardi
@ 2002-02-01  4:29     ` levi
  2001-10-12 10:16       ` Daniel Jacobowitz
  2002-02-01  4:29       ` levi
  2002-02-01  4:29     ` levi
  1 sibling, 2 replies; 12+ messages in thread
From: levi @ 2002-02-01  4:29 UTC (permalink / raw)
  To: levi; +Cc: Pierre Muller, adam.oldham, gdb, core, gpc

On Fri, Oct 12, 2001 at 06:57:32PM +0200, Maurice Lombardi wrote:
> >  There are several remarks to that bug report:
> >  1) I don't know at all how nested functions work in C
> >Are they allowed? 
> 
> 
> AKAIK no, they are not allowed, and this is the root of the problem,
> since gdb is written mainly by/for C programmers.

They aren't allowed by standard C.  GCC does in fact allow them,
although their use isn't recommended.  I think GDB's support for them
is somewhat crusty.


-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer



^ permalink raw reply	[flat|nested] 12+ messages in thread

* GDB scope does not work quite right for Pascal
       [not found] <20011012124403.21432.qmail@sourceware.cygnus.com>
@ 2002-02-01  4:29 ` levi
  2001-10-12  8:29   ` Pierre Muller
  2001-10-12  9:58   ` Maurice Lombardi
  0 siblings, 2 replies; 12+ messages in thread
From: levi @ 2002-02-01  4:29 UTC (permalink / raw)
  To: levi; +Cc: gdb, core, gpc

At 14:44 12/10/01 , vous avez écrit:

> >Number:         222
> >Category:       gdb
> >Synopsis:       GDB scope does not work quite right for Pascal
> >Confidential:   no
> >Severity:       non-critical
> >Priority:       medium
> >Responsible:    unassigned
> >State:          open
> >Class:          sw-bug
> >Submitter-Id:   net
> >Arrival-Date:   Fri Oct 12 05:48:01 PDT 2001
> >Closed-Date:
> >Last-Modified:
> >Originator:     Adam Oldham
> >Release:        gdb 20010813
> >Organization:
> >Environment:
>Mandrake 8.1, Kernel 2.4.8, glibc 2.2, Intel Platform
> >Description:
>Source is compiled with FPC (Free Pascal Compiler).  This can happen with 
>any source of pascal.  When you declare nested functions, gdb's scope does 
>not allow the viewing of the variables that are from the parent function 
>that should be within the scope.
> >How-To-Repeat:
>The simple program attached will produce the problem.  When compiled and 
>run, the correct output is displayed, but if you run GDB on it, and break 
>on function test2 and print out int1 which is a global variable for the 
>function test1, you receive:
>"No symbol "INT1" in current context."

   There are several remarks to that bug report:
   1) I don't know at all how nested functions work in C
Are they allowed? Do they also use a paremt fram pushing method ?
If yes, can locals from the calling function be found in C?
Maybe someone from the gdb mailing list can answer that question.
If this is already implemented for C its probably easier to just take
the same method.

   2) There is a solution, I implemented it in the IDE for Free Pascal
but it is rather complicated.
   Let me try to explain this solution to everyone.
   Nested functions in pascal get a hidden parameter that contains the
frame pointer (ebp value for i386 cpu) of the calling function. This allows the
program to access correctly local variable of the function that called the 
nested
function. This value is searched in the backtrace at the location where
the frame pointer are usually saved ( i.e. at offset 0 of the local ebp 
value for i386)
If we find the corresponding frame (which is not always the first frame 
above the current one)
then we can try if we find the unfound local symbol in that frame).

    To ease this search, I inserted a pseudo-parameter to the function called
parent_ebp (in lower case, while normal Free Pascal symbols are uppercased)
that indicate the location of this parnt frame pointer.

3)  As maintainer of the pascal language specific part of GDB,
I am of course willing to introduce this into the gdb sources, but I would
really like to get first some feedback from the gpc list.
    Does gpc do anything about this calling frame hidden parameter ?
Could we agree to use the same method for both compiler
in order to get better support for Pascal ?



Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
  2002-02-01  4:29     ` levi
  2001-10-12 10:16       ` Daniel Jacobowitz
@ 2002-02-01  4:29       ` levi
  2001-10-12 10:40         ` Andrew Cagney
  1 sibling, 1 reply; 12+ messages in thread
From: levi @ 2002-02-01  4:29 UTC (permalink / raw)
  To: levi; +Cc: Maurice Lombardi, adam.oldham, gdb, core, gpc

> On Fri, Oct 12, 2001 at 06:57:32PM +0200, Maurice Lombardi wrote:
> 
>> > There are several remarks to that bug report:
>> > 1) I don't know at all how nested functions work in C
>> >Are they allowed? 
> 
>> 
>> 
>> AKAIK no, they are not allowed, and this is the root of the problem,
>> since gdb is written mainly by/for C programmers.
> 
> 
> They aren't allowed by standard C.  GCC does in fact allow them,
> although their use isn't recommended.  I think GDB's support for them
> is somewhat crusty.


The thread 
http://sources.redhat.com/ml/gdb-patches/2001-07/msg00714.html is 
probably relevant.

Following on Joel's strategy (Ada) the first thing needed is probably a 
testcase so that people know the status of the underlying code

Andrew





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
  2001-10-12  9:58   ` Maurice Lombardi
  2002-02-01  4:29     ` levi
@ 2002-02-01  4:29     ` levi
  1 sibling, 0 replies; 12+ messages in thread
From: levi @ 2002-02-01  4:29 UTC (permalink / raw)
  To: levi; +Cc: adam.oldham, gdb, core, gpc

Pierre Muller wrote:

> At 14:44 12/10/01 , vous avez écrit:
> 
>> >Number:         222
>> >Category:       gdb
>> >Synopsis:       GDB scope does not work quite right for Pascal
>> >Confidential:   no
>> >Severity:       non-critical
>> >Priority:       medium
>> >Responsible:    unassigned
>> >State:          open
>> >Class:          sw-bug
>> >Submitter-Id:   net
>> >Arrival-Date:   Fri Oct 12 05:48:01 PDT 2001
>> >Closed-Date:
>> >Last-Modified:
>> >Originator:     Adam Oldham
>> >Release:        gdb 20010813
>> >Organization:
>> >Environment:
>> Mandrake 8.1, Kernel 2.4.8, glibc 2.2, Intel Platform
>> >Description:
>> Source is compiled with FPC (Free Pascal Compiler).  This can happen 
>> with any source of pascal. 


and any pascal compiler: it happens also for gpc

 When you declare nested functions, gdb's 
>> scope does not allow the viewing of the variables that are from the 
>> parent function that should be within the scope.
>> >How-To-Repeat:
>> The simple program attached will produce the problem.  When compiled 
>> and run, the correct output is displayed, but if you run GDB on it, 
>> and break on function test2 and print out int1 which is a global 
>> variable for the function test1, you receive:
>> "No symbol "INT1" in current context."
> 
> 
>   There are several remarks to that bug report:
>   1) I don't know at all how nested functions work in C
> Are they allowed? 


AKAIK no, they are not allowed, and this is the root of the problem,
since gdb is written mainly by/for C programmers.

> Do they also use a paremt fram pushing method ?
> If yes, can locals from the calling function be found in C?
> Maybe someone from the gdb mailing list can answer that question.
> If this is already implemented for C its probably easier to just take
> the same method.
> 
>   2) There is a solution, I implemented it in the IDE for Free Pascal
> but it is rather complicated.
>   Let me try to explain this solution to everyone.
>   Nested functions in pascal get a hidden parameter that contains the
> frame pointer (ebp value for i386 cpu) of the calling function. This 
> allows the
> program to access correctly local variable of the function that called 
> the nested
> function. This value is searched in the backtrace at the location where
> the frame pointer are usually saved ( i.e. at offset 0 of the local ebp 
> value for i386)
> If we find the corresponding frame (which is not always the first frame 
> above the current one)
> then we can try if we find the unfound local symbol in that frame).
> 
>    To ease this search, I inserted a pseudo-parameter to the function 
> called
> parent_ebp (in lower case, while normal Free Pascal symbols are uppercased)
> that indicate the location of this parnt frame pointer.
> 
> 3)  As maintainer of the pascal language specific part of GDB,
> I am of course willing to introduce this into the gdb sources, but I would
> really like to get first some feedback from the gpc list.
>    Does gpc do anything about this calling frame hidden parameter ?
> Could we agree to use the same method for both compiler
> in order to get better support for Pascal ?

Do'nt know, only Peter or Franck probably can tell.

-- 
        Maurice Lombardi
Laboratoire de  Spectrometrie Physique,
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex     FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:Maurice.Lombardi@ujf-grenoble.fr




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
       [not found] <A3E34B558F5CD211B4980008C7A4A99003883EC6@sparrow.gso.mcs.m arconi.com>
@ 2002-02-01  4:29 ` levi
  2001-10-12 16:38   ` Pierre Muller
  0 siblings, 1 reply; 12+ messages in thread
From: levi @ 2002-02-01  4:29 UTC (permalink / raw)
  To: levi; +Cc: Maurice Lombardi, gdb, core, gpc

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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
  2001-10-12 11:21 Oldham, Adam
@ 2002-02-01  4:29 ` levi
  0 siblings, 0 replies; 12+ messages in thread
From: levi @ 2002-02-01  4:29 UTC (permalink / raw)
  To: levi; +Cc: Maurice Lombardi, Oldham, Adam, gdb, core, gpc

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....

Adam

-----Original Message-----
From: Andrew Cagney [mailto:ac131313@cygnus.com]
Sent: Friday, October 12, 2001 1:40 PM
To: Daniel Jacobowitz; Pierre Muller
Cc: Maurice Lombardi; adam.oldham@marconi.com; gdb@sources.redhat.com;
core@freepascal.org; gpc@gnu.de
Subject: Re: GDB scope does not work quite right for Pascal


> On Fri, Oct 12, 2001 at 06:57:32PM +0200, Maurice Lombardi wrote:
> 
>> > There are several remarks to that bug report:
>> > 1) I don't know at all how nested functions work in C
>> >Are they allowed? 
> 
>> 
>> 
>> AKAIK no, they are not allowed, and this is the root of the problem,
>> since gdb is written mainly by/for C programmers.
> 
> 
> They aren't allowed by standard C.  GCC does in fact allow them,
> although their use isn't recommended.  I think GDB's support for them
> is somewhat crusty.


The thread 
http://sources.redhat.com/ml/gdb-patches/2001-07/msg00714.html is 
probably relevant.

Following on Joel's strategy (Ada) the first thing needed is probably a 
testcase so that people know the status of the underlying code

Andrew




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: GDB scope does not work quite right for Pascal
  2002-02-01  4:29 ` levi
@ 2001-10-12 16:38   ` Pierre Muller
  0 siblings, 0 replies; 12+ messages in thread
From: Pierre Muller @ 2001-10-12 16:38 UTC (permalink / raw)
  To: Oldham, Adam, 'Andrew Cagney', Daniel Jacobowitz
  Cc: Maurice Lombardi, gdb, core, gpc

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.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: GDB scope does not work quite right for Pascal
@ 2001-10-12 11:21 Oldham, Adam
  2002-02-01  4:29 ` levi
  0 siblings, 1 reply; 12+ messages in thread
From: Oldham, Adam @ 2001-10-12 11:21 UTC (permalink / raw)
  To: 'Andrew Cagney', Daniel Jacobowitz, Pierre Muller
  Cc: Maurice Lombardi, Oldham, Adam, gdb, core, gpc

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....

Adam

-----Original Message-----
From: Andrew Cagney [ mailto:ac131313@cygnus.com ]
Sent: Friday, October 12, 2001 1:40 PM
To: Daniel Jacobowitz; Pierre Muller
Cc: Maurice Lombardi; adam.oldham@marconi.com; gdb@sources.redhat.com;
core@freepascal.org; gpc@gnu.de
Subject: Re: GDB scope does not work quite right for Pascal


> On Fri, Oct 12, 2001 at 06:57:32PM +0200, Maurice Lombardi wrote:
> 
>> > There are several remarks to that bug report:
>> > 1) I don't know at all how nested functions work in C
>> >Are they allowed? 
> 
>> 
>> 
>> AKAIK no, they are not allowed, and this is the root of the problem,
>> since gdb is written mainly by/for C programmers.
> 
> 
> They aren't allowed by standard C.  GCC does in fact allow them,
> although their use isn't recommended.  I think GDB's support for them
> is somewhat crusty.


The thread 
http://sources.redhat.com/ml/gdb-patches/2001-07/msg00714.html is 
probably relevant.

Following on Joel's strategy (Ada) the first thing needed is probably a 
testcase so that people know the status of the underlying code

Andrew


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2002-02-01 12:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20011012124403.21432.qmail@sourceware.cygnus.com>
2002-02-01  4:29 ` GDB scope does not work quite right for Pascal levi
2001-10-12  8:29   ` Pierre Muller
2001-10-12  9:58   ` Maurice Lombardi
2002-02-01  4:29     ` levi
2001-10-12 10:16       ` Daniel Jacobowitz
2002-02-01  4:29       ` levi
2001-10-12 10:40         ` Andrew Cagney
2002-02-01  4:29     ` levi
     [not found] <A3E34B558F5CD211B4980008C7A4A99003883EC6@sparrow.gso.mcs.m arconi.com>
2002-02-01  4:29 ` levi
2001-10-12 16:38   ` Pierre Muller
2001-10-12 11:21 Oldham, Adam
2002-02-01  4:29 ` levi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox