From 4e07d55ffbd3d926ab776b2ce3fd13e96d214269 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 14 Feb 2011 11:10:53 +0000 Subject: Base support for value contents. gdb/ * value.h (value_bytes_available): Declare. (mark_value_bytes_unavailable): Declare. * value.c (struct range): New struct. (range_s): New typedef. (ranges_overlap): New function. (range_lessthan): New function. (ranges_contain_p): New function. (struct value) : New field. (value_bytes_available): New function. (mark_value_bytes_unavailable): New function. (require_not_optimized_out): Constify parameter. (require_available): New function. (value_contents_all, value_contents): Require all bytes be available. (value_free): Free `unavailable'. (value_copy): Copy `unavailable'. * valprint.h (val_print_unavailable): Declare. * valprint.c (valprint_check_validity): Rename `offset' parameter to `embedded_offset'. If printing a scalar, check whether the value chunk is available. (val_print_unavailable): New. (val_print_scalar_formatted): Check whether the value is available. * python/py-prettyprint.c (apply_val_pretty_printer): Refuse pretty-printing unavailable values. --- gdb/valprint.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'gdb/valprint.c') diff --git a/gdb/valprint.c b/gdb/valprint.c index b32d6fc..64a4b05 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -260,7 +260,7 @@ scalar_type_p (struct type *type) static int valprint_check_validity (struct ui_file *stream, struct type *type, - int offset, + int embedded_offset, const struct value *val) { CHECK_TYPEDEF (type); @@ -269,19 +269,25 @@ valprint_check_validity (struct ui_file *stream, && TYPE_CODE (type) != TYPE_CODE_STRUCT && TYPE_CODE (type) != TYPE_CODE_ARRAY) { - if (! value_bits_valid (val, TARGET_CHAR_BIT * offset, - TARGET_CHAR_BIT * TYPE_LENGTH (type))) + if (!value_bits_valid (val, TARGET_CHAR_BIT * embedded_offset, + TARGET_CHAR_BIT * TYPE_LENGTH (type))) { val_print_optimized_out (stream); return 0; } - if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * offset, + if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * TYPE_LENGTH (type))) { fputs_filtered (_(""), stream); return 0; } + + if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type))) + { + val_print_unavailable (stream); + return 0; + } } return 1; @@ -293,6 +299,12 @@ val_print_optimized_out (struct ui_file *stream) fprintf_filtered (stream, _("")); } +void +val_print_unavailable (struct ui_file *stream) +{ + fprintf_filtered (stream, _("")); +} + /* Print using the given LANGUAGE the data of type TYPE located at VALADDR + EMBEDDED_OFFSET (within GDB), which came from the inferior at address ADDRESS + EMBEDDED_OFFSET, onto stdio stream @@ -560,6 +572,8 @@ val_print_scalar_formatted (struct type *type, if (!value_bits_valid (val, TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * TYPE_LENGTH (type))) val_print_optimized_out (stream); + else if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type))) + val_print_unavailable (stream); else print_scalar_formatted (valaddr + embedded_offset, type, options, size, stream); -- cgit v1.1