aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-valprint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/c-valprint.c')
-rw-r--r--gdb/c-valprint.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 9d2da35..e2a5b95 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -150,6 +150,7 @@ c_textual_element_type (struct type *type, char format)
int
c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int recurse,
+ const struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
@@ -177,8 +178,12 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
print_spaces_filtered (2 + 2 * recurse, stream);
}
- /* Print arrays of textual chars with a string syntax. */
- if (c_textual_element_type (unresolved_elttype, options->format))
+ /* Print arrays of textual chars with a string syntax, as
+ long as the entire array is valid. */
+ if (c_textual_element_type (unresolved_elttype, options->format)
+ && value_bits_valid (original_value,
+ TARGET_CHAR_BIT * embedded_offset,
+ TARGET_CHAR_BIT * TYPE_LENGTH (type)))
{
/* If requested, look for the first null char and only print
elements up to it. */
@@ -217,7 +222,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
i = 0;
}
val_print_array_elements (type, valaddr + embedded_offset, address, stream,
- recurse, options, i);
+ recurse, original_value, options, i);
fprintf_filtered (stream, "}");
}
break;
@@ -394,7 +399,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
else
cp_print_value_fields_rtti (type, valaddr,
embedded_offset, address, stream,
- recurse, options, NULL, 0);
+ recurse, original_value, options, NULL, 0);
break;
case TYPE_CODE_ENUM:
@@ -695,9 +700,9 @@ c_value_print (struct value *val, struct ui_file *stream,
full ? "" : _(" [incomplete object]"));
/* Print out object: enclosing type is same as real_type if full */
return val_print (value_enclosing_type (val),
- value_contents_all (val), 0,
+ value_contents_for_printing (val), 0,
value_address (val), stream, 0,
- &opts, current_language);
+ val, &opts, current_language);
/* Note: When we look up RTTI entries, we don't get any information on
const or volatile attributes */
}
@@ -707,15 +712,16 @@ c_value_print (struct value *val, struct ui_file *stream,
fprintf_filtered (stream, "(%s ?) ",
TYPE_NAME (value_enclosing_type (val)));
return val_print (value_enclosing_type (val),
- value_contents_all (val), 0,
+ value_contents_for_printing (val), 0,
value_address (val), stream, 0,
- &opts, current_language);
+ val, &opts, current_language);
}
/* Otherwise, we end up at the return outside this "if" */
}
- return val_print (val_type, value_contents_all (val),
+ return val_print (val_type, value_contents_for_printing (val),
value_embedded_offset (val),
value_address (val),
- stream, 0, &opts, current_language);
+ stream, 0,
+ val, &opts, current_language);
}