aboutsummaryrefslogtreecommitdiff
path: root/gdb/rust-lang.c
diff options
context:
space:
mode:
authorManish Goregaokar <manish@mozilla.com>2016-10-27 16:46:34 -0700
committerManish Goregaokar <manish@mozilla.com>2016-11-03 15:45:05 -0700
commit51a789c3bf3d9b04d3d81493fda7f2514ae43add (patch)
treeffb87d61643983177391b967ebf543796383d50f /gdb/rust-lang.c
parent98d0e90ccafe18d0b6392fa891e4b3d77299ae95 (diff)
downloadgdb-51a789c3bf3d9b04d3d81493fda7f2514ae43add.zip
gdb-51a789c3bf3d9b04d3d81493fda7f2514ae43add.tar.gz
gdb-51a789c3bf3d9b04d3d81493fda7f2514ae43add.tar.bz2
Fix handling of discriminantless univariant enums in Rust; fix bug with encoded enums
2016-10-27 Manish Goregaokar <manish@mozilla.com> gdb/ChangeLog: * rust-lang.c (rust_get_disr_info): Treat univariant enums without discriminants as encoded enums with a real field * rust-lang.c (rust_evaluate_subexp): Handle field access on encoded struct-like enums gdb/testsuite/ChangeLog: * simple.rs: Add test for univariant enums without discriminants and for encoded struct-like enums * simple.exp: Add test expectations
Diffstat (limited to 'gdb/rust-lang.c')
-rw-r--r--gdb/rust-lang.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 82cd3f9..774eed9 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -194,6 +194,18 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
has changed its debuginfo format. */
error (_("Could not find enum discriminant field"));
}
+ else if (TYPE_NFIELDS (type) == 1)
+ {
+ /* Sometimes univariant enums are encoded without a
+ discriminant. In that case, treating it as an encoded enum
+ with the first field being the actual type works. */
+ const char *field_name = TYPE_NAME (TYPE_FIELD_TYPE (type, 0));
+ const char *last = rust_last_path_segment (field_name);
+ ret.name = concat (TYPE_NAME (type), "::", last, (char *) NULL);
+ ret.field_no = RUST_ENCODED_ENUM_REAL;
+ ret.is_encoded = 1;
+ return ret;
+ }
if (strcmp (TYPE_FIELD_NAME (disr_type, 0), "RUST$ENUM$DISR") != 0)
error (_("Rust debug format has changed"));
@@ -1725,7 +1737,9 @@ tuple structs, and tuple-like enum variants"));
variant_type = TYPE_FIELD_TYPE (type, disr.field_no);
if (variant_type == NULL
- || rust_tuple_variant_type_p (variant_type))
+ || (disr.is_encoded
+ ? rust_tuple_struct_type_p (variant_type)
+ : rust_tuple_variant_type_p (variant_type)))
error(_("Attempting to access named field %s of tuple variant %s, \
which has only anonymous fields"),
field_name, disr.name);