I built rustc with my patches to fix enum debug info. (See https://github.com/rust-lang/rust/pull/54004) With this patch, the rust "nil-enum.rs" test case causes a gdb internal error: $1 = ../../binutils-gdb/gdb/valops.c:2270: internal-error: int value_union_variant(type*, const gdb_byte*): Assertion `discriminant_prop != nullptr' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) [answered Y; input not from terminal] ../../binutils-gdb/gdb/valops.c:2270: internal-error: int value_union_variant(type*, const gdb_byte*): Assertion `discriminant_prop != nullptr' failed.
The DWARF says: <2><311>: Abbrev Number: 7 (DW_TAG_structure_type) <312> DW_AT_name : (indirect string, offset: 0x2ae): ANilEnum <316> DW_AT_byte_size : 0 <317> DW_AT_alignment : 1 <3><318>: Abbrev Number: 8 (DW_TAG_variant_part) <3><319>: Abbrev Number: 0 The source says: enum ANilEnum {} So basically a pathological case not accounted for at some spot in the gdb variant part code.
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=098b2108a2b61531c0bc8ea16854f773083a95d7 commit 098b2108a2b61531c0bc8ea16854f773083a95d7 Author: Tom Tromey <tom@tromey.com> Date: Tue Sep 11 15:28:04 2018 -0600 Fix crash with empty Rust enum While testing my Rust compiler patch to fix the DWARF representation of Rust enums (https://github.com/rust-lang/rust/pull/54004), I found a gdb crash coming from one of the Rust test cases. The bug here is that the new variant support in gdb does not handle the case where there are no variants in the enum. This patch fixes the problem in a straightforward way. Note that the new tests are somewhat lax because I did not want to try to fully fix this corner case for older compilers. If you think that's unacceptable, let meknow. Tested on x86-64 Fedora 28 using several versions of the Rust compiler. I intend to push this to the 8.2 branch as well. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> PR rust/23626: * rust-lang.c (rust_enum_variant): Now static. (rust_empty_enum_p): New function. (rust_print_enum, rust_evaluate_subexp, rust_print_struct_def): Handle empty enum. gdb/testsuite/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> PR rust/23626: * gdb.rust/simple.rs (EmptyEnum): New type. (main): Use it. * gdb.rust/simple.exp (test_one_slice): Add empty enum test.
The gdb-8.2-branch branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=18a27702320ec98fa79a75acd6365ea2348f8852 commit 18a27702320ec98fa79a75acd6365ea2348f8852 Author: Tom Tromey <tom@tromey.com> Date: Tue Sep 11 15:28:04 2018 -0600 Fix crash with empty Rust enum While testing my Rust compiler patch to fix the DWARF representation of Rust enums (https://github.com/rust-lang/rust/pull/54004), I found a gdb crash coming from one of the Rust test cases. The bug here is that the new variant support in gdb does not handle the case where there are no variants in the enum. This patch fixes the problem in a straightforward way. Note that the new tests are somewhat lax because I did not want to try to fully fix this corner case for older compilers. If you think that's unacceptable, let meknow. Tested on x86-64 Fedora 28 using several versions of the Rust compiler. I intend to push this to the 8.2 branch as well. 2018-09-13 Tom Tromey <tom@tromey.com> PR rust/23626: * rust-lang.c (rust_enum_variant): Now static. (rust_empty_enum_p): New function. (rust_print_enum, rust_evaluate_subexp, rust_print_struct_def): Handle empty enum. gdb/testsuite/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> PR rust/23626: * gdb.rust/simple.rs (EmptyEnum): New type. (main): Use it. * gdb.rust/simple.exp (test_one_slice): Add empty enum test.
Fixed.