DWARF information encodes discriminant values for tagged enums incorrectly #125147
Labels
A-debuginfo
Area: Debugging information in compiled programs (DWARF, PDB, etc.)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
WG-debugging
Working group: Bad Rust debugging experiences
The Rust compiler emits tagged enums and their members as
DW_TAG_variant_part
andDW_TAG_variant
DIEs in DWARF correspondingly. According to the DWARF standard, the discriminant value for each of the variant members should be LEB128 encoded. In practice, the Rust compiler does not encode these values in LEB128 encoding, thereby it is not compliant with the DWARF standard.Furthermore, there seems to be some undefined behavior with negative discriminant values. The following examples show 2 cases of tagged enums with negative discriminants.
Example 1
Discriminant type is 32 bit signed integer.
DWARF:
Example 2
Discriminant type is 64 bit signed integer.
DWARF:
Note that the form for
DW_AT_discr_value
attribute should not beDW_FORM_dataX
, rather it should beDW_FORM_sdata
.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: