Skip to content

Several bugs related to enum debugging #55586

Closed
@artemmukhin

Description

@artemmukhin

I have found some bugs related to enum debug info.
My LLDB version is lldb-1000.0.37 (MacOS), GDB is 8.1.0.20180409-git (Ubuntu).

Here they are:

Variants with the same names

enum Enum1<T> { A(T), B(T) }
enum Enum2 { A { x: i32, y: i32 } }

fn main() {
    let e1 = Enum1::A(42);
    let e2 = Enum2::A { x: 4, y: 5 };
}

Run LLDB (without pretty-printers):

(lldb) print e2
(test::Enum2) $1 = {
   = (RUST$ENUM$DISR = 4, __0 = 5)
}

RUST$ENUM$DISR = 4?

Variant disappears

enum Enum { A, B(i32, i32), C(i32, i32, i32) }

fn main() {
    let e = Enum::B(1, 2);
}

Run LLDB (without pretty-printers):

(lldb) print e
(test::Enum) $0 = {
   = (RUST$ENUM$DISR = B)
   = (RUST$ENUM$DISR = B, __0 = 1, __1 = 2, __2 = 32766)
}

No second variant?

Probably no discriminant

enum Enum { A(i32, i32), B(String, i32), C { x: i32 } }

fn main() {
    let e = Enum::B(String::from("abc"), 42);
}

Run GDB + default pretty-printers:

(gdb) print e

  File "rustlib/etc/gdb_rust_pretty_printing.py", line 169, in rust_pretty_printer_lookup_function
    discriminant_val = rustpp.get_discriminant_value_as_integer(val)
  File "rustlib/etc/debugger_pretty_printers_common.py", line 340, in get_discriminant_value_as_integer
    variant_val = enum_val.get_child_at_index(0)
  File "rustlib/etc/gdb_rust_pretty_printing.py", line 75, in get_child_at_index
    child = GdbValue(self.gdb_val[gdb_field])
gdb.error: That operation is not available on integers of more than 8 bytes.

Probably e doesn't contain valid discriminant inside the first variant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions