Hopefully straightforward (and I didn't miss anything ...).
gdb/ChangeLog
2020-02-19 Doug Evans <dje@google.com>
PR rust/25535
* rust-lang.c (rust_print_enum): Apply embedded_offset to
rust_enum_variant calculation.
gdb/testsuite/ChangeLog
2020-02-19 Doug Evans <dje@google.com>
PR rust/25535
* gdb.rust/simple.exp: Add test.
* gdb.rust/simple.rs: Add test.
+2020-02-19 Doug Evans <dje@google.com>
+
+ PR rust/25535
+ * rust-lang.c (rust_print_enum): Apply embedded_offset to
+ rust_enum_variant calculation.
+
2020-02-19 Tom Tromey <tromey@adacore.com>
* mips-tdep.h (mips_pc_is_mips): Parameter type is CORE_ADDR.
}
const gdb_byte *valaddr = value_contents_for_printing (val);
- struct field *variant_field = rust_enum_variant (type, valaddr);
+ struct field *variant_field = rust_enum_variant (type,
+ valaddr + embedded_offset);
embedded_offset += FIELD_BITPOS (*variant_field) / 8;
struct type *variant_type = FIELD_TYPE (*variant_field);
+2020-02-19 Doug Evans <dje@google.com>
+
+ PR rust/25535
+ * gdb.rust/simple.exp: Add test.
+ * gdb.rust/simple.rs: Add test.
+
2020-02-19 Tom de Vries <tdevries@suse.de>
* gdb.base/corefile-buildid.exp (check_exec_file): Match info files
gdb_test "print u2" " = simple::Union2 {name: \\\[1\\\]}"
+gdb_test "print nonzero_offset" " = simple::EnumWithNonzeroOffset {a: core::option::Option<u8>::Some\\(1\\), b: core::option::Option<u8>::None}"
+
# 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
enum EmptyEnum {}
+#[derive(Debug)]
+struct EnumWithNonzeroOffset {
+ a: Option<u8>,
+ b: Option<u8>,
+}
+
fn main () {
let a = ();
let b : [i32; 0] = [];
let u2 = Union2 { name: [1] };
+ let nonzero_offset = EnumWithNonzeroOffset { a: Some(1), b: None };
+
println!("{}, {}", x.0, x.1); // set breakpoint here
println!("{}", diff2(92, 45));
empty();