/* generic_val_print helper for TYPE_CODE_ARRAY. */
static void
-generic_val_print_array (struct type *type, const gdb_byte *valaddr,
+generic_val_print_array (struct type *type,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options,
const struct
generic_val_print_decorations *decorations)
}
fputs_filtered (decorations->array_start, stream);
- val_print_array_elements (type, valaddr, embedded_offset,
+ val_print_array_elements (type, embedded_offset,
address, stream,
recurse, original_value, options, 0);
fputs_filtered (decorations->array_end, stream);
/* generic_val_print helper for TYPE_CODE_PTR. */
static void
-generic_val_print_ptr (struct type *type, const gdb_byte *valaddr,
+generic_val_print_ptr (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
if (options->format && options->format != 's')
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
else
{
struct type *unresolved_elttype = TYPE_TARGET_TYPE(type);
struct type *elttype = check_typedef (unresolved_elttype);
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
CORE_ADDR addr = unpack_pointer (type,
valaddr + embedded_offset * unit_size);
/* generic_val_print helper for TYPE_CODE_MEMBERPTR. */
static void
-generic_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
+generic_val_print_memberptr (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
/* generic_val_print helper for TYPE_CODE_REF. */
static void
-generic_val_print_ref (struct type *type, const gdb_byte *valaddr,
+generic_val_print_ref (struct type *type,
int embedded_offset, struct ui_file *stream, int recurse,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
const int must_coerce_ref = ((options->addressprint && value_is_synthetic)
|| options->deref_ref);
const int type_is_defined = TYPE_CODE (elttype) != TYPE_CODE_UNDEF;
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
if (must_coerce_ref && type_is_defined)
{
/* generic_val_print helper for TYPE_CODE_ENUM. */
static void
-generic_val_print_enum (struct type *type, const gdb_byte *valaddr,
+generic_val_print_enum (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
LONGEST val;
if (options->format)
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
- return;
}
- val = unpack_long (type, valaddr + embedded_offset * unit_size);
+ else
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+ val = unpack_long (type, valaddr + embedded_offset * unit_size);
- generic_val_print_enum_1 (type, val, stream);
+ generic_val_print_enum_1 (type, val, stream);
+ }
}
/* generic_val_print helper for TYPE_CODE_FLAGS. */
static void
-generic_val_print_flags (struct type *type, const gdb_byte *valaddr,
+generic_val_print_flags (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
if (options->format)
- val_print_scalar_formatted (type, valaddr, embedded_offset, original_value,
+ val_print_scalar_formatted (type, embedded_offset, original_value,
options, 0, stream);
else
- val_print_type_code_flags (type, valaddr + embedded_offset, stream);
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+ val_print_type_code_flags (type, valaddr + embedded_offset, stream);
+ }
}
/* generic_val_print helper for TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
static void
-generic_val_print_func (struct type *type, const gdb_byte *valaddr,
+generic_val_print_func (struct type *type,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
if (options->format)
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
else
/* generic_val_print helper for TYPE_CODE_BOOL. */
static void
-generic_val_print_bool (struct type *type, const gdb_byte *valaddr,
+generic_val_print_bool (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options,
const struct generic_val_print_decorations *decorations)
{
struct value_print_options opts = *options;
opts.format = (options->format ? options->format
: options->output_format);
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
}
else
{
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
val = unpack_long (type, valaddr + embedded_offset * unit_size);
if (val == 0)
fputs_filtered (decorations->false_name, stream);
/* generic_val_print helper for TYPE_CODE_INT. */
static void
-generic_val_print_int (struct type *type, const gdb_byte *valaddr,
+generic_val_print_int (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
opts.format = (options->format ? options->format
: options->output_format);
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
}
else
- val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
- stream);
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+ val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
+ stream);
+ }
}
/* generic_val_print helper for TYPE_CODE_CHAR. */
static void
generic_val_print_char (struct type *type, struct type *unresolved_type,
- const gdb_byte *valaddr, int embedded_offset,
+ int embedded_offset,
struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
LONGEST val;
opts.format = (options->format ? options->format
: options->output_format);
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, &opts, 0, stream);
}
else
{
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
val = unpack_long (type, valaddr + embedded_offset * unit_size);
if (TYPE_UNSIGNED (type))
fprintf_filtered (stream, "%u", (unsigned int) val);
/* generic_val_print helper for TYPE_CODE_FLT. */
static void
-generic_val_print_float (struct type *type, const gdb_byte *valaddr,
+generic_val_print_float (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
if (options->format)
{
- val_print_scalar_formatted (type, valaddr, embedded_offset,
+ val_print_scalar_formatted (type, embedded_offset,
original_value, options, 0, stream);
}
else
{
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
print_floating (valaddr + embedded_offset * unit_size, type, stream);
}
}
/* generic_val_print helper for TYPE_CODE_DECFLOAT. */
static void
-generic_val_print_decfloat (struct type *type, const gdb_byte *valaddr,
+generic_val_print_decfloat (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
if (options->format)
- val_print_scalar_formatted (type, valaddr, embedded_offset, original_value,
+ val_print_scalar_formatted (type, embedded_offset, original_value,
options, 0, stream);
else
- print_decimal_floating (valaddr + embedded_offset * unit_size, type,
- stream);
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
+
+ print_decimal_floating (valaddr + embedded_offset * unit_size, type,
+ stream);
+ }
}
/* generic_val_print helper for TYPE_CODE_COMPLEX. */
static void
-generic_val_print_complex (struct type *type, const gdb_byte *valaddr,
+generic_val_print_complex (struct type *type,
int embedded_offset, struct ui_file *stream,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options,
const struct generic_val_print_decorations
*decorations)
{
struct gdbarch *gdbarch = get_type_arch (type);
int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+ const gdb_byte *valaddr = value_contents_for_printing (original_value);
fprintf_filtered (stream, "%s", decorations->complex_prefix);
if (options->format)
- val_print_scalar_formatted (TYPE_TARGET_TYPE (type), valaddr,
+ val_print_scalar_formatted (TYPE_TARGET_TYPE (type),
embedded_offset, original_value, options, 0,
stream);
else
TYPE_TARGET_TYPE (type), stream);
fprintf_filtered (stream, "%s", decorations->complex_infix);
if (options->format)
- val_print_scalar_formatted (TYPE_TARGET_TYPE (type), valaddr,
+ val_print_scalar_formatted (TYPE_TARGET_TYPE (type),
embedded_offset
+ type_length_units (TYPE_TARGET_TYPE (type)),
original_value, options, 0, stream);
output in some small, language-specific ways. */
void
-generic_val_print (struct type *type, const gdb_byte *valaddr,
+generic_val_print (struct type *type,
int embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *original_value,
+ struct value *original_value,
const struct value_print_options *options,
const struct generic_val_print_decorations *decorations)
{
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
- generic_val_print_array (type, valaddr, embedded_offset, address, stream,
+ generic_val_print_array (type, embedded_offset, address, stream,
recurse, original_value, options, decorations);
break;
case TYPE_CODE_MEMBERPTR:
- generic_val_print_memberptr (type, valaddr, embedded_offset, stream,
+ generic_val_print_memberptr (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_PTR:
- generic_val_print_ptr (type, valaddr, embedded_offset, stream,
+ generic_val_print_ptr (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_REF:
- generic_val_print_ref (type, valaddr, embedded_offset, stream, recurse,
+ generic_val_print_ref (type, embedded_offset, stream, recurse,
original_value, options);
break;
case TYPE_CODE_ENUM:
- generic_val_print_enum (type, valaddr, embedded_offset, stream,
+ generic_val_print_enum (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_FLAGS:
- generic_val_print_flags (type, valaddr, embedded_offset, stream,
+ generic_val_print_flags (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD:
- generic_val_print_func (type, valaddr, embedded_offset, address, stream,
+ generic_val_print_func (type, embedded_offset, address, stream,
original_value, options);
break;
case TYPE_CODE_BOOL:
- generic_val_print_bool (type, valaddr, embedded_offset, stream,
+ generic_val_print_bool (type, embedded_offset, stream,
original_value, options, decorations);
break;
/* FALLTHROUGH */
case TYPE_CODE_INT:
- generic_val_print_int (type, valaddr, embedded_offset, stream,
+ generic_val_print_int (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_CHAR:
- generic_val_print_char (type, unresolved_type, valaddr, embedded_offset,
+ generic_val_print_char (type, unresolved_type, embedded_offset,
stream, original_value, options);
break;
case TYPE_CODE_FLT:
- generic_val_print_float (type, valaddr, embedded_offset, stream,
+ generic_val_print_float (type, embedded_offset, stream,
original_value, options);
break;
case TYPE_CODE_DECFLOAT:
- generic_val_print_decfloat (type, valaddr, embedded_offset, stream,
+ generic_val_print_decfloat (type, embedded_offset, stream,
original_value, options);
break;
break;
case TYPE_CODE_COMPLEX:
- generic_val_print_complex (type, valaddr, embedded_offset, stream,
+ generic_val_print_complex (type, embedded_offset, stream,
original_value, options, decorations);
break;
}
/* 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
- STREAM according to OPTIONS. VAL is the whole object that came
- from ADDRESS. VALADDR must point to the head of VAL's contents
- buffer.
+ VAL's contents buffer + EMBEDDED_OFFSET (within GDB), which came
+ from the inferior at address ADDRESS + EMBEDDED_OFFSET, onto
+ stdio stream STREAM according to OPTIONS. VAL is the whole object
+ that came from ADDRESS.
The language printers will pass down an adjusted EMBEDDED_OFFSET to
further helper subroutines as subfields of TYPE are printed. In
- such cases, VALADDR is passed down unadjusted, as well as VAL, so
+ such cases, VAL is passed down unadjusted, so
that VAL can be queried for metadata about the contents data being
printed, using EMBEDDED_OFFSET as an offset into VAL's contents
buffer. For example: "has this field been optimized out", or "I'm
RECURSE. */
void
-val_print (struct type *type, const gdb_byte *valaddr, LONGEST embedded_offset,
+val_print (struct type *type, LONGEST embedded_offset,
CORE_ADDR address, struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
const struct language_defn *language)
{
if (!options->raw)
{
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+
ret = apply_ext_lang_val_pretty_printer (type, valaddr, embedded_offset,
address, stream, recurse,
val, options, language);
TRY
{
- language->la_val_print (type, valaddr, embedded_offset, address,
+ language->la_val_print (type, embedded_offset, address,
stream, recurse, val,
&local_opts);
}
get a fixed representation of our value. */
val = ada_to_fixed_value (val);
- val_print (value_type (val), value_contents_for_printing (val),
+ val_print (value_type (val),
value_embedded_offset (val), value_address (val),
stream, recurse,
val, options, language);
void
val_print_scalar_formatted (struct type *type,
- const gdb_byte *valaddr, LONGEST embedded_offset,
- const struct value *val,
+ LONGEST embedded_offset,
+ struct value *val,
const struct value_print_options *options,
int size,
struct ui_file *stream)
int unit_size = gdbarch_addressable_memory_unit_size (arch);
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
struct value_print_options opts = *options;
opts.format = 0;
opts.deref_ref = 0;
- val_print (type, valaddr, embedded_offset, 0, stream, 0, val, &opts,
+ val_print (type, embedded_offset, 0, stream, 0, val, &opts,
current_language);
return;
}
+ /* value_contents_for_printing fetches all VAL's contents. They are
+ needed to check whether VAL is optimized-out or unavailable
+ below. */
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+
/* A scalar object that does not have all bits available can't be
printed, because all bits contribute to its representation. */
if (value_bits_any_optimized_out (val,
void
val_print_array_elements (struct type *type,
- const gdb_byte *valaddr, LONGEST embedded_offset,
+ LONGEST embedded_offset,
CORE_ADDR address, struct ui_file *stream,
int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
unsigned int i)
{
if (reps > options->repeat_count_threshold)
{
- val_print (elttype, valaddr, embedded_offset + i * eltlen,
+ val_print (elttype, embedded_offset + i * eltlen,
address, stream, recurse + 1, val, options,
current_language);
annotate_elt_rep (reps);
}
else
{
- val_print (elttype, valaddr, embedded_offset + i * eltlen,
+ val_print (elttype, embedded_offset + i * eltlen,
address,
stream, recurse + 1, val, options, current_language);
annotate_elt ();