mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 06:45:56 +08:00
Introduce cp_print_value_fields and c_value_print_struct
This adds cp_print_value_fields and c_value_print_struct, value-based analogues of the corresponding val-printing functions. Note that the Modula-2 printing code also calls cp_print_val_fields, and so is updated to call the function function. gdb/ChangeLog 2020-03-13 Tom Tromey <tom@tromey.com> * m2-valprint.c (m2_value_print_inner): Use cp_print_value_fields. * cp-valprint.c (cp_print_value_fields): New function. * c-valprint.c (c_value_print_struct): New function. (c_value_print_inner): Use c_value_print_struct. * c-lang.h (cp_print_value_fields): Declare.
This commit is contained in:
@ -540,6 +540,34 @@ c_val_print_struct (struct type *type, const gdb_byte *valaddr,
|
||||
NULL, 0);
|
||||
}
|
||||
|
||||
/* c_value_print helper for TYPE_CODE_STRUCT and TYPE_CODE_UNION. */
|
||||
|
||||
static void
|
||||
c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
|
||||
const struct value_print_options *options)
|
||||
{
|
||||
struct type *type = check_typedef (value_type (val));
|
||||
|
||||
if (TYPE_CODE (type) == TYPE_CODE_UNION && recurse && !options->unionprint)
|
||||
fprintf_filtered (stream, "{...}");
|
||||
else if (options->vtblprint && cp_is_vtbl_ptr_type (type))
|
||||
{
|
||||
/* Print the unmangled name if desired. */
|
||||
/* Print vtable entry - we only get here if NOT using
|
||||
-fvtable_thunks. (Otherwise, look under
|
||||
TYPE_CODE_PTR.) */
|
||||
struct gdbarch *gdbarch = get_type_arch (type);
|
||||
int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8;
|
||||
struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET);
|
||||
const gdb_byte *valaddr = value_contents_for_printing (val);
|
||||
CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type);
|
||||
|
||||
print_function_pointer_address (options, gdbarch, addr, stream);
|
||||
}
|
||||
else
|
||||
cp_print_value_fields (val, stream, recurse, options, NULL, 0);
|
||||
}
|
||||
|
||||
/* c_val_print helper for TYPE_CODE_UNION. */
|
||||
|
||||
static void
|
||||
@ -746,7 +774,6 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
|
||||
const struct value_print_options *options)
|
||||
{
|
||||
struct type *type = value_type (val);
|
||||
CORE_ADDR address = value_address (val);
|
||||
const gdb_byte *valaddr = value_contents_for_printing (val);
|
||||
|
||||
type = check_typedef (type);
|
||||
@ -765,13 +792,8 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse,
|
||||
break;
|
||||
|
||||
case TYPE_CODE_UNION:
|
||||
c_val_print_union (type, valaddr, 0, address, stream,
|
||||
recurse, val, options);
|
||||
break;
|
||||
|
||||
case TYPE_CODE_STRUCT:
|
||||
c_val_print_struct (type, valaddr, 0, address, stream,
|
||||
recurse, val, options);
|
||||
c_value_print_struct (val, stream, recurse, options);
|
||||
break;
|
||||
|
||||
case TYPE_CODE_INT:
|
||||
|
Reference in New Issue
Block a user