+2019-05-02 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * rust-lang.c (val_print_struct): Handle printing structures
+ containing strings.
+
2019-05-02 Tom Tromey <tromey@adacore.com>
* valarith.c (_initialize_valarith): Remove.
if (rust_slice_type_p (type) && strcmp (TYPE_NAME (type), "&str") == 0)
{
+ /* If what we are printing here is actually a string within a
+ structure then VAL will be the original parent value, while TYPE
+ will be the type of the structure representing the string we want
+ to print.
+ However, RUST_VAL_PRINT_STR looks up the fields of the string
+ inside VAL, assuming that VAL is the string.
+ So, recreate VAL as a value representing just the string. */
+ val = value_at_lazy (type, value_address (val) + embedded_offset);
rust_val_print_str (stream, val, options);
return;
}
+2019-05-02 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.rust/simple.exp: Add new test case.
+ * gdb.rust/simple.rs (struct StringAtOffset): New struct.
+ (main): Initialise an instance of the new struct.
+
2019-05-01 Tom Tromey <tromey@adacore.com>
* gdb.ada/packed_array_assign/aggregates.ads (Nested_Packed): New
" = simple::NonZeroOptimized::Value\\(\[a-z\]+::string::String .*"
gdb_test "print custom_none" " = simple::NonZeroOptimized::Empty"
+gdb_test "print st" \
+ " = simple::StringAtOffset {field1: \"hello\", field2: 1, field3: \"world\"}"
+
proc test_one_slice {svar length base range} {
global hex
f2: u8,
}
+struct StringAtOffset {
+ pub field1: &'static str,
+ pub field2: i32,
+ pub field3: &'static str,
+}
+
// A simple structure whose layout won't be changed by the compiler,
// so that ptype/o testing will work on any platform.
struct SimpleLayout {
let to1 = &w[..3];
let to2 = &slice[..1];
+ let st = StringAtOffset { field1: "hello", field2: 1, field3: "world" };
+
// tests for enum optimizations
let str_some = Some("hi".to_string());