Bug 20998 - [3.4/4.0/4.1 Regression] GCC does not emit debug info for variables in anonymous unions
Summary: [3.4/4.0/4.1 Regression] GCC does not emit debug info for variables in anonym...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.2
Assignee: Richard Henderson
URL:
Keywords: wrong-debug
Depends on:
Blocks:
 
Reported: 2005-04-13 18:01 UTC by Devang Patel
Modified: 2005-10-18 13:19 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3 4.1.0 3.4.0 3.4.4 3.4.5 4.0.2
Known to fail: 3.4.0 4.0.0 4.0.1
Last reconfirmed: 2005-09-09 07:13:15


Attachments
proposed patch (3.06 KB, patch)
2005-09-09 08:42 UTC, Richard Henderson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devang Patel 2005-04-13 18:01:18 UTC
Here  is the simple C++ program :

int main()                                                                                                                                                                                           
{                                                                                                                                                                                                    
  union {                                                                                                                                                                                            
    int z;                                                                                                                                                                                           
    unsigned int w;                                                                                                                                                                                  
  }; w = 0;                                                                                                                                                                                          
                                                                                                                                                                                                     
}
Comment 1 Andrew Pinski 2005-04-13 18:18:01 UTC
Confirmed.
Comment 2 Devang Patel 2005-04-13 18:19:25 UTC
Subject: Re:  GCC does not emit debug info for variables in anonymous unions

It is because of ALIAS_DECL

Comment 3 Andrew Pinski 2005-04-13 18:21:41 UTC
This is a regression from 3.3.3.
Comment 4 Andrew Pinski 2005-07-12 06:06:04 UTC
(In reply to comment #2)
> It is because of ALIAS_DECL
Which means it was caused by:
2002-12-18  Jason Merrill  <jason@redhat.com>
        
        Handle anonymous unions at the tree level.
        C++ ABI change: Mangle anonymous unions using the name of their
        first named field (by depth-first search).  Should not cause
        binary compatibility problems, though, as the compiler previously
        didn't emit anything for affected unions.
        * cp-tree.def (ALIAS_DECL): New tree code.
Comment 5 Andrew Pinski 2005-07-22 21:13:11 UTC
Moving to 4.0.2 pre Mark.
Comment 6 Richard Henderson 2005-09-09 08:42:39 UTC
Created attachment 9699 [details]
proposed patch

This patch bears up against minmal testing on linux.  Please test on Darwin,
or other system that defaults to stabs.
Comment 7 Devang Patel 2005-09-09 18:01:24 UTC
Subject: Re:  [3.4/4.0/4.1 Regression] GCC does not emit debug info for variables in anonymous unions


It does not fix gdb.cp/anon-union.exp (from GDB testsuite) failures  
using darwin GDB. If you do not get any other feedback/info then I'll  
try to get back to this next week.

-
Devang

Comment 8 Richard Henderson 2005-09-09 19:08:12 UTC
Well it does with cvs head gdb on linux, both stabs and dwarf2.  If you'll
verify that you see something akin to 

        .stabs  "z:(0,7)",128,0,0,-4
        .stabs  "w:(0,9)",128,0,0,-4

in your assembly file, I'll close this as fixed on the gcc side.
Comment 9 Andrew Pinski 2005-09-09 20:37:01 UTC
I get:
        .stabs  "z:(0,9)",128,0,6,24
        .stabs  "w:(0,11)",128,0,6,24
Comment 10 Andrew Pinski 2005-09-09 20:44:46 UTC
(In reply to comment #9)
> I get:
>         .stabs  "z:(0,9)",128,0,6,24
>         .stabs  "w:(0,11)",128,0,6,24

After updating my gcc to the today's mainline instead of one from yesterday, darwin's gdb works 
correctly for me.
Comment 11 GCC Commits 2005-09-09 21:06:03 UTC
Subject: Bug 20998

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	rth@gcc.gnu.org	2005-09-09 21:05:57

Modified files:
	gcc            : ChangeLog Makefile.in dbxout.c 
	gcc/cp         : ChangeLog cp-tree.def decl2.c error.c 
	                 name-lookup.c semantics.c 

Log message:
	PR debug/20998
	* dbxout.c: Include expr.h.
	(dbxout_global_decl): Don't suppress for DECL_RTL unset.
	(dbxout_symbol): Handle DECL_VALUE_EXPR.
	* Makefile.in (dbxout.o): Add EXPR_H.
	cp/
	* cp-tree.def (ALIAS_DECL): Remove.
	* cp-lang.c (cp_init_ts): Remove support for it.
	* error.c (dump_decl): Likewise.
	* name-lookup.c (pushdecl): Likewise.
	* semantics.c (finish_id_expression): Likewise.
	* decl2.c (build_anon_union_vars): Use a VAR_DECL with
	DECL_VALUE_EXPR instead.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.422&r2=2.7592.2.423
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/Makefile.in.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1447.2.4&r2=1.1447.2.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dbxout.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.221.2.2&r2=1.221.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.97&r2=1.4648.2.98
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.94.4.3&r2=1.94.4.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.770.2.7&r2=1.770.2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/error.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.279.2.2&r2=1.279.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.109.4.8&r2=1.109.4.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.463.2.9&r2=1.463.2.10

Comment 12 Richard Henderson 2005-09-09 21:06:39 UTC
Fixed.
Comment 13 Richard Henderson 2005-09-09 21:07:20 UTC
Oh, and that's a WONTFIX for 3.4, in case anyone's interested.