aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.rust
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-02-09 13:31:51 -0700
committerTom Tromey <tom@tromey.com>2018-02-26 09:21:08 -0700
commitc9317f214b274b805190b8e878c79f4181d93bb4 (patch)
tree5951977ca7528f2fd938aae44205255c31e3c8dc /gdb/testsuite/gdb.rust
parent7c22600aabfd10e190e98fff0b7c2d69cd191325 (diff)
downloadgdb-c9317f214b274b805190b8e878c79f4181d93bb4.zip
gdb-c9317f214b274b805190b8e878c79f4181d93bb4.tar.gz
gdb-c9317f214b274b805190b8e878c79f4181d93bb4.tar.bz2
Convert Rust to use discriminated unions
A Rust enum is, essentially, a discriminated union. Currently the Rust language support handles Rust enums locally, in rust-lang.c. However, because I am changing the Rust compiler to use DW_TAG_variant* to represent enums, it seemed better to have a single internal representation for Rust enums in gdb. This patch implements this idea by moving the current Rust enum handling code to dwarf2read. This allows the simplification of some parts of rust-lang.c as well. 2018-02-26 Tom Tromey <tom@tromey.com> * rust-lang.h (rust_last_path_segment): Declare. * rust-lang.c (rust_last_path_segment): Now public. Change contract. (struct disr_info): Remove. (RUST_ENUM_PREFIX, RUST_ENCODED_ENUM_REAL) (RUST_ENCODED_ENUM_HIDDEN, rust_union_is_untagged) (rust_get_disr_info, rust_tuple_variant_type_p): Remove. (rust_enum_p, rust_enum_variant): New function. (rust_underscore_fields): Remove "offset" parameter. (rust_print_enum): New function. (rust_val_print) <TYPE_CODE_UNION>: Remove enum code. <TYPE_CODE_STRUCT>: Call rust_print_enum when appropriate. (rust_print_struct_def): Add "for_rust_enum" parameter. Handle enums. (rust_internal_print_type): New function, from rust_print_type. Remove enum code. (rust_print_type): Call rust_internal_print_type. (rust_evaluate_subexp) <STRUCTOP_ANONYMOUS, STRUCTOP_STRUCT>: Update enum handling. * dwarf2read.c (struct dwarf2_cu) <rust_unions>: New field. (rust_fully_qualify, alloc_discriminant_info, quirk_rust_enum) (rust_union_quirks): New functions. (process_full_comp_unit, process_full_type_unit): Call rust_union_quirks. (process_structure_scope): Update rust_unions if necessary. 2018-02-26 Tom Tromey <tom@tromey.com> * gdb.rust/simple.exp: Accept more possible results in enum test.
Diffstat (limited to 'gdb/testsuite/gdb.rust')
-rw-r--r--gdb/testsuite/gdb.rust/simple.exp4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index 04750d9..230e6a7 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -220,8 +220,8 @@ gdb_test "print .." " = .*::ops::RangeFull"
gdb_test "print str_some" \
" = core::option::Option<\[a-z\]+::string::String>::Some\\(\[a-z\]+::string::String .*"
gdb_test "print str_none" " = core::option::Option<\[a-z\]+::string::String>::None"
-gdb_test "print int_some" " = core::option::Option::Some\\(1\\)"
-gdb_test "print int_none" " = core::option::Option::None"
+gdb_test "print int_some" " = core::option::Option<u8>::Some\\(1\\)"
+gdb_test "print int_none" " = core::option::Option<u8>::None"
gdb_test "print box_some" " = core::option::Option<\[a-z:\]*Box<u8>>::Some\\(.*\\)"
gdb_test "print box_none" " = core::option::Option<\[a-z:\]*Box<u8>>::None"
gdb_test "print custom_some" \