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

Rust DWARF debug info creates duplicate DW_TAG_structure_types with the same name #52762

Closed
rocallahan opened this issue Jul 27, 2018 · 2 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@rocallahan
Copy link

Given this pretty common pattern

enum Foo { Bar(Bar) }
struct Bar { ... }

rustc generates two DW_TAG_structure_type entries in the same namespace both called Bar, one for the Rust struct, the other for the Foo::Bar variant. This is a problem for tools that want to refer to DWARF structure types by name (e.g. when trying to guess type identities across compilation unit boundaries). It would also be a problem if a user tries to refer to the type Bar in the user interface of a debugger (without additional hacks like ignoring types containing RUST$ENUM$DISR).

@sfackler sfackler added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Jul 27, 2018
@tromey
Copy link
Contributor

tromey commented Aug 1, 2018

Somewhat related to bug #32924. I suspect this will be fixed by my patch for #32920, but I haven't verified it yet.

@tromey
Copy link
Contributor

tromey commented Aug 2, 2018

Yes, with my patch, the structure type that is generated for the enum variant is nested in the enum:

 <2><394>: Abbrev Number: 7 (DW_TAG_structure_type)
    <395>   DW_AT_name        : (indirect string, offset: 0x2cc): Foo
    <399>   DW_AT_byte_size   : 0
    <39a>   DW_AT_alignment   : 1
 <3><39b>: Abbrev Number: 8 (DW_TAG_variant_part)
 <4><39c>: Abbrev Number: 9 (DW_TAG_variant)
 <5><39d>: Abbrev Number: 10 (DW_TAG_member)
    <39e>   DW_AT_type        : <0x3a6>
    <3a2>   DW_AT_alignment   : 1
    <3a3>   DW_AT_data_member_location: 0
 <5><3a4>: Abbrev Number: 0
 <4><3a5>: Abbrev Number: 0
 <3><3a6>: Abbrev Number: 7 (DW_TAG_structure_type)
    <3a7>   DW_AT_name        : (indirect string, offset: 0x2c8): Bar
    <3ab>   DW_AT_byte_size   : 0
    <3ac>   DW_AT_alignment   : 1

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.)
Projects
None yet
Development

No branches or pull requests

3 participants