Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tromey opened this issue Apr 13, 2016 · 2 comments
Closed

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

tromey opened this issue Apr 13, 2016 · 2 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.

Comments

@tromey
Copy link
Contributor

tromey commented Apr 13, 2016

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.

@Aatch Aatch added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Apr 13, 2016
@michaelwoerister
Copy link
Member

We should be able to set the name of the DW_TAG_enumeration_type entry to something like __<enum-name>_discriminant. I'll need to look up though how we represent C-like enums (probably just the DW_TAG_enumeration_type without the ``DW_TAG_union_type`) and if that needs special attention then.

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 25, 2017
@tromey
Copy link
Contributor Author

tromey commented Dec 1, 2017

I may be fixing this as a side effect of work on #32920

tromey added a commit to tromey/rust that referenced this issue Sep 21, 2018
The DWARF generated for Rust enums was always somewhat unusual.
Rather than using DWARF constructs directly, it would emit magic field
names like "RUST$ENCODED$ENUM$0$Name" and "RUST$ENUM$DISR".  Since
PR rust-lang#45225, though, even this has not worked -- the ad hoc scheme was
not updated to handle the wider variety of niche-filling layout
optimizations now available.

This patch changes the generated DWARF to use the standard tags meant
for this purpose; namely, DW_TAG_variant and DW_TAG_variant_part.

The patch to implement this went in to LLVM 7.  In order to work with
older versions of LLVM, and because LLVM doesn't do anything here for
PDB, the existing code is kept as a fallback mode.

Support for this DWARF is in the Rust lldb and in gdb 8.2.

Closes rust-lang#32920
Closes rust-lang#32924
Closes rust-lang#52762
Closes rust-lang#53153
bors added a commit that referenced this issue Sep 23, 2018
Fix DWARF generation for enums

The DWARF generated for Rust enums was always somewhat unusual.
Rather than using DWARF constructs directly, it would emit magic field
names like "RUST$ENCODED$ENUM$0$Name" and "RUST$ENUM$DISR".  Since
PR #45225, though, even this has not worked -- the ad hoc scheme was
not updated to handle the wider variety of niche-filling layout
optimizations now available.

This patch changes the generated DWARF to use the standard tags meant
for this purpose; namely, DW_TAG_variant and DW_TAG_variant_part.

The patch to implement this went in to LLVM 7.  In order to work with
older versions of LLVM, and because LLVM doesn't do anything here for
PDB, the existing code is kept as a fallback mode.

Support for this DWARF is in the Rust lldb and in gdb 8.2.

Closes #32920
Closes #32924
Closes #52762
Closes #53153
tromey added a commit to tromey/rust that referenced this issue Oct 1, 2018
The DWARF generated for Rust enums was always somewhat unusual.
Rather than using DWARF constructs directly, it would emit magic field
names like "RUST$ENCODED$ENUM$0$Name" and "RUST$ENUM$DISR".  Since
PR rust-lang#45225, though, even this has not worked -- the ad hoc scheme was
not updated to handle the wider variety of niche-filling layout
optimizations now available.

This patch changes the generated DWARF to use the standard tags meant
for this purpose; namely, DW_TAG_variant and DW_TAG_variant_part.

The patch to implement this went in to LLVM 7.  In order to work with
older versions of LLVM, and because LLVM doesn't do anything here for
PDB, the existing code is kept as a fallback mode.

Support for this DWARF is in the Rust lldb and in gdb 8.2.

Closes rust-lang#32920
Closes rust-lang#32924
Closes rust-lang#52762
Closes rust-lang#53153
bors added a commit that referenced this issue Oct 1, 2018
Fix DWARF generation for enums

The DWARF generated for Rust enums was always somewhat unusual.
Rather than using DWARF constructs directly, it would emit magic field
names like "RUST$ENCODED$ENUM$0$Name" and "RUST$ENUM$DISR".  Since
PR #45225, though, even this has not worked -- the ad hoc scheme was
not updated to handle the wider variety of niche-filling layout
optimizations now available.

This patch changes the generated DWARF to use the standard tags meant
for this purpose; namely, DW_TAG_variant and DW_TAG_variant_part.

The patch to implement this went in to LLVM 7.  In order to work with
older versions of LLVM, and because LLVM doesn't do anything here for
PDB, the existing code is kept as a fallback mode.

Support for this DWARF is in the Rust lldb and in gdb 8.2.

Closes #32920
Closes #32924
Closes #52762
Closes #53153
tromey added a commit to tromey/rust that referenced this issue Oct 30, 2018
The DWARF generated for Rust enums was always somewhat unusual.
Rather than using DWARF constructs directly, it would emit magic field
names like "RUST$ENCODED$ENUM$0$Name" and "RUST$ENUM$DISR".  Since
PR rust-lang#45225, though, even this has not worked -- the ad hoc scheme was
not updated to handle the wider variety of niche-filling layout
optimizations now available.

This patch changes the generated DWARF to use the standard tags meant
for this purpose; namely, DW_TAG_variant and DW_TAG_variant_part.

The patch to implement this went in to LLVM 7.  In order to work with
older versions of LLVM, and because LLVM doesn't do anything here for
PDB, the existing code is kept as a fallback mode.

Support for this DWARF is in the Rust lldb and in gdb 8.2.

Closes rust-lang#32920
Closes rust-lang#32924
Closes rust-lang#52762
Closes rust-lang#53153
bors added a commit that referenced this issue Oct 30, 2018
Fix DWARF generation for enums

The DWARF generated for Rust enums was always somewhat unusual.
Rather than using DWARF constructs directly, it would emit magic field
names like "RUST$ENCODED$ENUM$0$Name" and "RUST$ENUM$DISR".  Since
PR #45225, though, even this has not worked -- the ad hoc scheme was
not updated to handle the wider variety of niche-filling layout
optimizations now available.

This patch changes the generated DWARF to use the standard tags meant
for this purpose; namely, DW_TAG_variant and DW_TAG_variant_part.

The patch to implement this went in to LLVM 7.  In order to work with
older versions of LLVM, and because LLVM doesn't do anything here for
PDB, the existing code is kept as a fallback mode.

Support for this DWARF is in the Rust lldb and in gdb 8.2.

Closes #32920
Closes #32924
Closes #52762
Closes #53153
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants