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.