gcc currently generates duplicate debug information for enums declared in
namespaces.

Compile this C++ code with -g:

namespace { enum x { i = 1 }; }
x y;

In the .s file, I see this:

        .uleb128 0x3
        .string "x"
        .byte   0x4
        .byte   0x1
        .byte   0x1
        .byte   0x4
        .byte   0x1
        .byte   0x1
        .uleb128 0x4
        .string "i"
        .sleb128 1
        .uleb128 0x4
        .string "i"
        .sleb128 1

Note the duplicate size/file/line info, and the duplication of information
about "i".

readelf --debug-dump shows this:

 <2><57>: Abbrev Number: 3 (DW_TAG_enumeration_type)
     DW_AT_name        : x
     DW_AT_byte_size   : 4
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 1
     DW_AT_byte_size   : 4
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 1
 <3><60>: Abbrev Number: 4 (DW_TAG_enumerator)
     DW_AT_name        : i
     DW_AT_const_value : 1
 <3><64>: Abbrev Number: 4 (DW_TAG_enumerator)
     DW_AT_name        : i
     DW_AT_const_value : 1

where we see the same duplication.

This is not a visible problem when using the debugger, because the duplicate
information just tells it the same information it already has.  But it probably
makes the debugger a bit slower.  And it definitely makes object files larger
than they need to be, which wastes time creating them and space storing them.

I believe the problem arises like this:
  gen_type_die calls
    declare_in_namespace calls
      gen_type_die
        emits die via gen_enumeration_type_die
        returns
      returns
   emits die via gen_enumeration_type_die

I don't have a patch for this.  I want to record it before I forget about it.


-- 
           Summary: Duplicate debug info for enums in namespaces
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26964

Reply via email to