+/* Like cp_print_value_fields, but find the runtime type of the object
+ and pass it as the `real_type' argument to cp_print_value_fields.
+ This function is a hack to work around the fact that
+ common_val_print passes the embedded offset to val_print, but not
+ the enclosing type. */
+
+void
+cp_print_value_fields_rtti (struct type *type,
+ const gdb_byte *valaddr, int offset,
+ CORE_ADDR address,
+ struct ui_file *stream, int recurse,
+ const struct value *val,
+ const struct value_print_options *options,
+ struct type **dont_print_vb,
+ int dont_print_statmem)
+{
+ struct type *real_type = NULL;
+
+ /* We require all bits to be valid in order to attempt a
+ conversion. */
+ if (value_bits_valid (val, TARGET_CHAR_BIT * offset,
+ TARGET_CHAR_BIT * TYPE_LENGTH (type)))
+ {
+ struct value *value;
+ int full, top, using_enc;
+
+ /* Ugh, we have to convert back to a value here. */
+ value = value_from_contents_and_address (type, valaddr + offset,
+ address + offset);
+ /* We don't actually care about most of the result here -- just
+ the type. We already have the correct offset, due to how
+ val_print was initially called. */
+ real_type = value_rtti_type (value, &full, &top, &using_enc);
+ }
+
+ if (!real_type)
+ real_type = type;
+
+ cp_print_value_fields (type, real_type, valaddr, offset,
+ address, stream, recurse, val, options,
+ dont_print_vb, dont_print_statmem);
+}
+
+/* Special val_print routine to avoid printing multiple copies of
+ virtual baseclasses. */