aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.rust/simple.exp
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-11 15:28:04 -0600
committerTom Tromey <tom@tromey.com>2018-09-13 10:57:39 -0600
commit098b2108a2b61531c0bc8ea16854f773083a95d7 (patch)
treee339871e7317c64d838590db69d4c429512cee9b /gdb/testsuite/gdb.rust/simple.exp
parent80ca5f98b86c9b209f392cb52dde8b8471856c5a (diff)
downloadgdb-098b2108a2b61531c0bc8ea16854f773083a95d7.zip
gdb-098b2108a2b61531c0bc8ea16854f773083a95d7.tar.gz
gdb-098b2108a2b61531c0bc8ea16854f773083a95d7.tar.bz2
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.
Diffstat (limited to 'gdb/testsuite/gdb.rust/simple.exp')
-rw-r--r--gdb/testsuite/gdb.rust/simple.exp12
1 files changed, 12 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index 20fe8dd..07b2512 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -303,6 +303,18 @@ gdb_test_sequence "ptype/o SimpleLayout" "" {
" }"
}
+# PR rust/23626 - this used to crash. Note that the results are
+# fairly lax because most existing versions of Rust (those before the
+# DW_TAG_variant patches) do not emit what gdb wants here; and there
+# was little point fixing gdb to cope with these cases as the fixed
+# compilers will be available soon
+gdb_test "print empty_enum_value" \
+ " = simple::EmptyEnum.*"
+gdb_test "ptype empty_enum_value" "simple::EmptyEnum.*"
+# Just make sure these don't crash, for the same reason.
+gdb_test "print empty_enum_value.0" ""
+gdb_test "print empty_enum_value.something" ""
+
load_lib gdb-python.exp
if {[skip_python_tests]} {
continue