DWARF-4 : missing DW_TAG_typedef for anonymous structures in C++

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I'm writing a small program to parse the DWARF debugging info as printed by readelf -wi. I'm compiling this example program as C and C++ :

typedef struct
{
    char  b[4];
} some_typedef_name;

int main()
{
    some_typedef_name  x;
    return 0;
}

(I'm using GCC 4.6.3 with -xc or -xc++ and -gdwarf-4, binutils 2.22)

The debugging output in C clearly shows that 'some_typedef_name' is the typedef name, as it has it's own 'DW_TAG_typedef' tag. The C++ output is different, and simply shows '17some_typedef_name' as the linkage name and no DW_TAG_typedef.


The debug output looks like this:

In C++ :

Contents of the .debug_types section:

  Compilation Unit @ offset 0x0:
 <snip>
   Signature:     d3090b96a7044acb
   Type Offset:   0x1d
 <0><17>: Abbrev Number: 1 (DW_TAG_type_unit)
    <18>   DW_AT_language    : 4    (C++)
    <19>   DW_AT_stmt_list   : 0x0
 <1><1d>: Abbrev Number: 2 (DW_TAG_structure_type)
    <snip>
<21> DW_AT_linkage_name: (indirect string, offset: 0x54): 17some_typedef_name
    <25>   DW_AT_sibling     : <0x34>
 <snip>


In C :

Contents of the .debug_types section:

  Compilation Unit @ offset 0x0:
 <snip>
   Signature:     d3090b96a7044acb
   Type Offset:   0x1d
 <0><17>: Abbrev Number: 1 (DW_TAG_type_unit)
    <18>   DW_AT_language    : 1    (ANSI C)
    <19>   DW_AT_stmt_list   : 0x0
 <1><1d>: Abbrev Number: 2 (DW_TAG_structure_type)
    <1e>   DW_AT_byte_size   : 4
    <1f>   DW_AT_decl_file   : 1
    <20>   DW_AT_decl_line   : 1
    <21>   DW_AT_sibling     : <0x30>
 <2><25>: Abbrev Number: 3 (DW_TAG_member)
 <snip>

Contents of the .debug_info section:
 <snip>
 <1><37>: Abbrev Number: 8 (DW_TAG_typedef)
<38> DW_AT_name : (indirect string, offset: 0x0): some_typedef_name
    <sip>
    <3e>   DW_AT_type        : signature: d3090b96a7044acb
<snip>


When the example changes to :


typedef struct mystruct
{
    char  b[4];
} some_typedef_name;


Then the C++ output is correct and very similar to the C one:

Contents of the .debug_types section:

  Compilation Unit @ offset 0x0:
  <snip>
   Signature:     efb28d8a85f10bad
   Type Offset:   0x25
 <0><17>: Abbrev Number: 1 (DW_TAG_type_unit)
    <18>   DW_AT_language    : 4    (C++)
    <snip>
 <1><25>: Abbrev Number: 2 (DW_TAG_structure_type)
    <26>   DW_AT_name        : (indirect string, offset: 0x54): mystruct
<snip>

Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
<snip>
 <1><37>: Abbrev Number: 8 (DW_TAG_typedef)
<38> DW_AT_name : (indirect string, offset: 0x35): some_typedef_name
    <snip>
    <3e>   DW_AT_type        : signature: efb28d8a85f10bad

This looks like a bug.
Can anyone confirm this?

Thank you.

- Jan





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux