Skip to content

DWARF puts enum and union with same name into the same scope #32924

Closed
@tromey

Description

@tromey

This is perhaps a bit of a gdb-specific bug. The basic issue is that having multiple entities in the same scope with the same name but different DWARF tags makes it a pain for gdb to sensibly create its symbol table.

I see the issue with a number of constructs. For this example, consider something like:

enum MoreComplicated {
    One,
    Two(i32),
}

The DWARF gets an enum:

 <2><6d>: Abbrev Number: 4 (DW_TAG_enumeration_type)
    <6e>   DW_AT_type        : <0x415>
    <72>   DW_AT_enum_class  : 1
    <72>   DW_AT_name        : (indirect string, offset: 0x16e): MoreComplicated
    <76>   DW_AT_byte_size   : 1

... but also a union:

 <2><a7>: Abbrev Number: 6 (DW_TAG_union_type)
    <a8>   DW_AT_name        : (indirect string, offset: 0x16e): MoreComplicated
    <ac>   DW_AT_byte_size   : 24

It would be better for gdb to unify these two objects into a single representation in DWARF. For gdb's purposes it is fine if this representation requires some special Rust-specific code, for example knowing what names to insert into what scopes.

This is related to issue #32920, in that maybe a tagged variant would also help this situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions