- case TYPE_CODE_PTR:
- if (format && format != 's')
- {
- print_scalar_formatted (valaddr, type, format, 0, stream);
- break;
- }
- if (vtblprint && cp_is_vtbl_ptr_type(type))
- {
- /* Print the unmangled name if desired. */
- /* Print vtable entry - we only get here if we ARE using
- -fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
- print_address_demangle(extract_address (valaddr, TYPE_LENGTH (type)),
- stream, demangle);
- break;
- }
- elttype = check_typedef (TYPE_TARGET_TYPE (type));
- if (TYPE_CODE (elttype) == TYPE_CODE_METHOD)
- {
- cp_print_class_method (valaddr, type, stream);
- }
- else if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER)
+ if (format == 's')
+ {
+ /* Print this as a string if we can manage it. For now, no wide
+ character support. */
+ if (true_type->code () == TYPE_CODE_INT
+ && TYPE_LENGTH (true_type) == 1)
+ return 1;
+ }
+ else
+ {
+ /* If a one-byte TYPE_CODE_INT is missing the not-a-character
+ flag, then we treat it as text; otherwise, we assume it's
+ being used as data. */
+ if (true_type->code () == TYPE_CODE_INT
+ && TYPE_LENGTH (true_type) == 1
+ && !TYPE_NOTTEXT (true_type))
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Decorations for C. */
+
+static const struct generic_val_print_decorations c_decorations =
+{
+ "",
+ " + ",
+ "i",
+ "true",
+ "false",
+ "void",
+ "{",
+ "}"
+};
+
+/* Print a pointer based on the type of its target.
+
+ Arguments to this functions are roughly the same as those in c_val_print.
+ A difference is that ADDRESS is the address to print, with embedded_offset
+ already added. UNRESOLVED_ELTTYPE and ELTTYPE represent the pointed type,
+ respectively before and after check_typedef. */
+
+static void
+print_unpacked_pointer (struct type *type, struct type *elttype,
+ struct type *unresolved_elttype,
+ const gdb_byte *valaddr, int embedded_offset,
+ CORE_ADDR address, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
+{
+ int want_space = 0;
+ struct gdbarch *gdbarch = get_type_arch (type);
+
+ if (elttype->code () == TYPE_CODE_FUNC)
+ {
+ /* Try to print what function it points to. */
+ print_function_pointer_address (options, gdbarch, address, stream);
+ return;
+ }
+
+ if (options->symbol_print)
+ want_space = print_address_demangle (options, gdbarch, address, stream,
+ demangle);
+ else if (options->addressprint)
+ {
+ fputs_filtered (paddress (gdbarch, address), stream);
+ want_space = 1;
+ }
+
+ /* For a pointer to a textual type, also print the string
+ pointed to, unless pointer is null. */
+
+ if (c_textual_element_type (unresolved_elttype, options->format)
+ && address != 0)
+ {
+ if (want_space)
+ fputs_filtered (" ", stream);
+ val_print_string (unresolved_elttype, NULL, address, -1, stream, options);
+ }
+ else if (cp_is_vtbl_member (type))
+ {
+ /* Print vtbl's nicely. */
+ CORE_ADDR vt_address = unpack_pointer (type, valaddr + embedded_offset);
+ struct bound_minimal_symbol msymbol =
+ lookup_minimal_symbol_by_pc (vt_address);
+
+ /* If 'symbol_print' is set, we did the work above. */
+ if (!options->symbol_print
+ && (msymbol.minsym != NULL)
+ && (vt_address == BMSYMBOL_VALUE_ADDRESS (msymbol)))