Bug 10156 - [3.3/3.4 Regression] g++ 3.2 fails to emit debug location info for a local variable inside a class constructor
Summary: [3.3/3.4 Regression] g++ 3.2 fails to emit debug location info for a local va...
Status: RESOLVED DUPLICATE of bug 11098
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 3.2
: P2 critical
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-19 22:26 UTC by peter.thompson
Modified: 2004-01-17 04:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-05 16:35:31


Attachments
foo.ii (4.26 KB, text/plain)
2003-05-21 15:17 UTC, peter.thompson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Jacobowitz 2003-03-19 17:30:38 UTC
From: Daniel Jacobowitz <drow@mvista.com>
To: peter.thompson@etnus.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: debug/10156: g++ 3.2 fails to emit debug location info for a local variable inside a class constructor
Date: Wed, 19 Mar 2003 17:30:38 -0500

 On Wed, Mar 19, 2003 at 10:22:11PM -0000, peter.thompson@etnus.com wrote:
 > 
 > >Number:         10156
 > >Category:       debug
 > >Synopsis:       g++ 3.2 fails to emit debug location info for a local variable inside a class constructor
 > >Confidential:   no
 > >Severity:       critical
 > >Priority:       medium
 > >Responsible:    unassigned
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Wed Mar 19 22:26:00 UTC 2003
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Peter Thompson - Etnus
 > >Release:        gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
 > >Organization:
 > >Environment:
 > i686 platform
 > gcc 3.2 compilers (also tried 3.2.1, and 3.2.2 versions with same results)
 > >Description:
 > We ran into this problem with our debugger, TotalView, but were able to replicate the problem, with a little bit of effort, with gdb.
 
 Just FYI, the same problem was reported as a GDB bug c++/1141; I
 forwarded it to gcc-bugs and got no response, and haven't had time to
 look at it myself.  There's a smaller testcase there.
 
 -- 
 Daniel Jacobowitz
 MontaVista Software                         Debian GNU/Linux Developer

Comment 1 peter.thompson 2003-03-19 17:42:46 UTC
From: Peter Thompson <peter.thompson@etnus.com>
To: Daniel Jacobowitz <drow@mvista.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: debug/10156: g++ 3.2 fails to emit debug location info for a
 local variable inside a class constructor
Date: Wed, 19 Mar 2003 17:42:46 -0500

 Thanks Daniel,
 
 I looked at 1141, and concur with your analysis, since it agrees with 
 ours ;-)  It was submitted only a week ago, so I'm not too surprised it 
 hasn't been hit yet.
 
 Regards,
 PeterT
 
 
 Daniel Jacobowitz wrote:
 > On Wed, Mar 19, 2003 at 10:22:11PM -0000, peter.thompson@etnus.com wrote:
 > 
 >>>Number:         10156
 >>>Category:       debug
 >>>Synopsis:       g++ 3.2 fails to emit debug location info for a local variable inside a class constructor
 >>>Confidential:   no
 >>>Severity:       critical
 >>>Priority:       medium
 >>>Responsible:    unassigned
 >>>State:          open
 >>>Class:          sw-bug
 >>>Submitter-Id:   net
 >>>Arrival-Date:   Wed Mar 19 22:26:00 UTC 2003
 >>>Closed-Date:
 >>>Last-Modified:
 >>>Originator:     Peter Thompson - Etnus
 >>>Release:        gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
 >>>Organization:
 >>>Environment:
 >>
 >>i686 platform
 >>gcc 3.2 compilers (also tried 3.2.1, and 3.2.2 versions with same results)
 >>
 >>>Description:
 >>
 >>We ran into this problem with our debugger, TotalView, but were able to replicate the problem, with a little bit of effort, with gdb.
 > 
 > 
 > Just FYI, the same problem was reported as a GDB bug c++/1141; I
 > forwarded it to gcc-bugs and got no response, and haven't had time to
 > look at it myself.  There's a smaller testcase there.
 >
Comment 2 peter.thompson 2003-03-19 22:26:00 UTC
We ran into this problem with our debugger, TotalView, but were able to replicate the problem, with a little bit of effort, with gdb.

Inside a class constructor, a local variable that is not a member of the class is used to hold a temporary value.  Setting a breakpoint, or stepping into the constructor, and looking for the value of the variable after it as assigned shows "No symbol "i" in current context."

Looking at the dwarf output with readelf -wi, it is possible to see that though 'i' is apparently defined

 <2><186e>: Abbrev Number: 38 (DW_TAG_variable)
     DW_AT_name        : i	
     DW_AT_decl_file   : 1	
     DW_AT_decl_line   : 12	
     DW_AT_type        : <cb5>	

AND refined correctly in one of the copies of the constructors:

 <2><18a8>: Abbrev Number: 41 (DW_TAG_variable)
     DW_AT_abstract_origin: <186e>	
     DW_AT_location    : 2 byte block: 91 7c 	(DW_OP_fbreg: -4; )

it is not referenced correctly in the copy of the subroutine which we are able to step into:

 <2><18dc>: Abbrev Number: 42 (DW_TAG_variable)
     DW_AT_abstract_origin: <186e>	

Here the DW_AT_location attribute is missing, resulting in the debuggers being unable to locate it.

Release:
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

Environment:
i686 platform
gcc 3.2 compilers (also tried 3.2.1, and 3.2.2 versions with same results)

How-To-Repeat:
Compile with -g

Debug the output file with gdb
Set a breakpoint at line 30,   A x (a, b);
Run
Step  (to get into the constructor, gdb misses any breakpoints set directly in the constructor.  Not your problem!)
Next a few times to get past
i = 42;
print i

Should get No Symbol "i" in current context.


Also look at the dwarf info from the executable with 

readelf -wi 

This will show a DW_AT_location for i in one copy of the constructor, but will only show a DW_AT_abstract_origin for the copy of the constructor that gdb steps into.
Comment 3 Dara Hazeghi 2003-05-31 08:30:01 UTC
Hello,

do you know whether this problem is still present in gcc 3.3? Thanks,

Dara
Comment 4 peter.thompson 2003-06-02 01:26:41 UTC
Subject: Re:  g++ 3.2 fails to emit debug location info for
 a local variable inside a class constructor

Just tested with 3.3 and it still looks broken to me.

PeterT


dhazeghi@yahoo.com wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10156
> 
> 
> dhazeghi@yahoo.com changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Status|UNCONFIRMED                 |WAITING
> 
> 
> ------- Additional Comments From dhazeghi@yahoo.com  2003-05-31 08:30 -------
> Hello,
> 
> do you know whether this problem is still present in gcc 3.3? Thanks,
> 
> Dara
> 
> 
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
> You are on the CC list for the bug, or are watching someone who is.

Comment 5 Andrew Pinski 2003-06-02 01:30:36 UTC
According to the submitter it still is busted with 3.3
Comment 6 Daniel Jacobowitz 2003-06-02 15:49:41 UTC
I've confirmed this with both 3.3 and a 3.4 20030528 snapshot.
Comment 7 Andrew Pinski 2003-07-05 16:35:31 UTC
Most likely the same bug as bug 11098 which is for destructors.
Also in 2.95.3, I can print out the variable i (compiled with -gdwarf-2) so this is a 
regression.
Comment 8 Mark Mitchell 2003-07-15 01:12:36 UTC

*** This bug has been marked as a duplicate of 11098 ***