Bug 42862 - Anonymous Structures: Incorrect DWARF data generated
Summary: Anonymous Structures: Incorrect DWARF data generated
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
Depends on:
Blocks:
 
Reported: 2010-01-25 17:02 UTC by Ron Louzon
Modified: 2021-09-10 02:09 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ron Louzon 2010-01-25 17:02:36 UTC
GCC Version: 3.4.4 and 4.1.2

The GNU 4.1.2 C++ compiler is not generating the proper typedef DIEs in the DWARF data.
 
For example, the type definition BASE_UNION is defined as
 
typedef union
{
   char ch;
   int iVal;
   long IVal;
} BASE_UNION;

The GNU 4.1.2 compiler generates the following DWARF data for this type

<1><1279>: Abbrev Number: 35 (DW_TAG_union_type)
   <127a>     DW_AT_sibling     : <12a8>    
   <127e>     DW_AT_name        : $_4    
   <1282>     DW_AT_byte_size   : 4    
   <1283>     DW_AT_decl_file   : 35    
   <1284>     DW_AT_decl_line   : 29    


<2><1285>: Abbrev Number: 36 (DW_TAG_member)
   <1286>     DW_AT_name        : ch    
   <1289>     DW_AT_decl_file   : 35    
   <128a>     DW_AT_decl_line   : 30    
   <128b>     DW_AT_type        : <c0d>    
<2><128f>: Abbrev Number: 36 (DW_TAG_member)
   <1290>     DW_AT_name        : iVal    
   <1295>     DW_AT_decl_file   : 35    
   <1296>     DW_AT_decl_line   : 31    
   <1297>     DW_AT_type        : <b7f>    
<2><129b>: Abbrev Number: 36 (DW_TAG_member)
   <129c>     DW_AT_name        : IVal    
   <12a1>     DW_AT_decl_file   : 35    
   <12a2>     DW_AT_decl_line   : 32    
   <12a3>     DW_AT_type        : <b86>    
 
Notice that the union name has been set to "$_4" in DIE <1279>.  The correct DWARF data would have no name attribute for the union DIE <1279> and it would have a type-def DIE which pointed to the union die such as:

<1><xxxx>: DW_TAG_typedef
	  DW_AT_name        : BASE_UNION
	  DW_AT_decl_line   : 26
	  DW_AT_decl_column : 3
	  DW_AT_decl_file   : 9
	  DW_AT_type        : <0x1279>
 
Interestingly enough, the GNU 3.4.4 compiler generates the following DWARF data from the same source code and this is also incomplete:
 
<1><11d0>: Abbrev Number: 27 (DW_TAG_union_type)
   DW_AT_sibling     : <123f>    
   DW_AT_name        : (indirect string, offset: 0x6e): BASE_UNION    
   DW_AT_byte_size   : 4    
   DW_AT_decl_file   : 3    
   DW_AT_decl_line   : 29