Skip to content

[DebugInfo] Declarations show up in debug-names when TUs are used #78367

Closed as not planned
@felipepiovezan

Description

@felipepiovezan

We are adding declarations of types to debug-names when type units are involved:
For example:

namespace MyNamespace {
struct MyStruct1 {
  char c1;
};
struct MyStruct2 {
  char c2;
};
}

MyNamespace::MyStruct1 gv1;
MyNamespace::MyStruct2 gv2;

Compiling with:

clang++ -target x86_64 -c two_tus.cpp -g2 -gpubnames -fdebug-types-section -o - | \
llvm-dwarfdump - --debug-names | \
grep MyStruct2 -A14

We see:

  Bucket 0 [
    Name 1 {
      Hash: 0xE186C022
      String: 0x00000037 "MyStruct2"
      Entry @ 0xc9 {
        Abbrev: 0x26c
        Tag: DW_TAG_structure_type
        DW_IDX_type_unit: 0x01
        DW_IDX_die_offset: 0x00000025
      }
      Entry @ 0xd0 {
        Abbrev: 0x268
        Tag: DW_TAG_structure_type
        DW_IDX_die_offset: 0x00000034
      }
    }
  ]

I can't explain why this second entry is added. Looking at the debug-info section, the offset 0x34 is an offset to the declaration inside the CU:

0x00000029:   DW_TAG_namespace
                DW_AT_name      ("MyNamespace")

0x0000002b:     DW_TAG_structure_type
                  DW_AT_declaration     (true)
                  DW_AT_signature       (0x8b108ad18e93cb95)

0x00000034:     DW_TAG_structure_type
                  DW_AT_declaration     (true)
                  DW_AT_signature       (0x690ca39e0eeaec8f)

0x0000003d:     NULL

But declarations are not supposed to show up in debug-names...

Originally posted by @felipepiovezan in #77457 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions