gdb/rust: Handle printing structures containing strings
[deliverable/binutils-gdb.git] / gdb / rust-lang.c
index 2fada465d651527d1c54fc99aa80f15df2063528..79f13311cd8f7f0ce2af55e87de9a83819ee1f30 100644 (file)
@@ -378,6 +378,14 @@ val_print_struct (struct type *type, int embedded_offset,
 
   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;
     }
This page took 0.025102 seconds and 4 git commands to generate.