From ab2188aa2a7958d3954f98229002036867278636 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 25 Jan 2011 17:59:00 +0000 Subject: * printcmd.c (print_formatted): Use val_print_scalar_formatted instead of print_scalar_formatted. (print_scalar_formatted): Don't handle 's' format strings here, and add an assertion that we never see such format here. * valprint.h (val_print_scalar_formatted): Declare. * valprint.c (val_print_scalar_formatted): New. * c-valprint.c (c_val_print): Use val_print_scalar_formatted instead of print_scalar_formatted. * jv-valprint.c (java_val_print): Ditto. * p-valprint.c (pascal_val_print): Ditto. * ada-valprint.c (ada_val_print_1): Ditto. * f-valprint.c (f_val_print): Ditto. * infcmd.c (registers_info): Ditto. * m2-valprint.c (m2_val_print): Ditto. --- gdb/valprint.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'gdb/valprint.c') diff --git a/gdb/valprint.c b/gdb/valprint.c index 6ddbed83ebf..b6b96d4ec4f 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -514,6 +514,47 @@ val_print_type_code_flags (struct type *type, const gdb_byte *valaddr, } } fputs_filtered ("]", stream); + +/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR, + according to OPTIONS and SIZE on STREAM. Format i is not supported + at this level. + + This is how the elements of an array or structure are printed + with a format. */ +} + +void +val_print_scalar_formatted (struct type *type, + const gdb_byte *valaddr, int embedded_offset, + const struct value *val, + const struct value_print_options *options, + int size, + struct ui_file *stream) +{ + gdb_assert (val != NULL); + gdb_assert (valaddr == value_contents_for_printing_const (val)); + + /* If we get here with a string format, try again without it. Go + all the way back to the language printers, which may call us + again. */ + if (options->format == 's') + { + struct value_print_options opts = *options; + opts.format = 0; + opts.deref_ref = 0; + val_print (type, valaddr, embedded_offset, 0, stream, 0, val, &opts, + current_language); + return; + } + + /* A scalar object that does not have all bits available can't be + printed, because all bits contribute to its representation. */ + if (!value_bits_valid (val, TARGET_CHAR_BIT * embedded_offset, + TARGET_CHAR_BIT * TYPE_LENGTH (type))) + val_print_optimized_out (stream); + else + print_scalar_formatted (valaddr + embedded_offset, type, + options, size, stream); } /* Print a number according to FORMAT which is one of d,u,x,o,b,h,w,g. -- cgit v1.2.1