static void ada_val_print_array (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *original_value, const struct value_print_options *options) { /* For an array of characters, print with string syntax. */ if (ada_is_string_type (type) && (options->format == 0 || options->format == 's')) { ada_val_print_string (type, valaddr, offset, offset_aligned, address, stream, recurse, original_value, options); return; } fprintf_filtered (stream, "("); print_optional_low_bound (stream, type, options); if (TYPE_FIELD_BITSIZE (type, 0) > 0) val_print_packed_array_elements (type, valaddr, offset_aligned, 0, stream, recurse, original_value, options); else val_print_array_elements (type, offset_aligned, address, stream, recurse, original_value, options, 0); fprintf_filtered (stream, ")"); }
static void m2_print_array_contents (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *val, const struct value_print_options *options, int len) { type = check_typedef (type); if (TYPE_LENGTH (type) > 0) { if (options->prettyformat_arrays) print_spaces_filtered (2 + 2 * recurse, stream); /* For an array of chars, print with string syntax. */ if (TYPE_LENGTH (type) == 1 && ((TYPE_CODE (type) == TYPE_CODE_INT) || ((current_language->la_language == language_m2) && (TYPE_CODE (type) == TYPE_CODE_CHAR))) && (options->format == 0 || options->format == 's')) val_print_string (type, NULL, address, len+1, stream, options); else { fprintf_filtered (stream, "{"); val_print_array_elements (type, embedded_offset, address, stream, recurse, val, options, 0); fprintf_filtered (stream, "}"); } } }
int c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int format, int deref_ref, int recurse, enum val_prettyprint pretty) { unsigned int i = 0; /* Number of characters printed */ unsigned len; struct type *elttype; unsigned eltlen; LONGEST val; CORE_ADDR addr; int vector_int8s = 0; int vector_floats = 0; CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) { eltlen = TYPE_LENGTH (elttype); len = TYPE_LENGTH (type) / eltlen; if (prettyprint_arrays) { print_spaces_filtered (2 + 2 * recurse, stream); } /* APPLE LOCAL: gdb will print the int8_t elements of a vector register as a string or as characters -- neither of which is what the user expects 99% of the time. Instead, detect that we're looking at a vector's int8_t array and treat it specially. */ if (eltlen == 1 && TYPE_VECTOR (type) && TYPE_CODE (elttype) == TYPE_CODE_INT && format == 0) { vector_int8s = 1; } /* APPLE LOCAL: Detect if we're about to print an array of v4_float or v2_doubles in a vector register */ if ((eltlen == 4 || eltlen == 8) && TYPE_VECTOR (type) && TYPE_CODE (elttype) == TYPE_CODE_FLT) { vector_floats = 1; } /* For an array of chars, print with string syntax. */ if (eltlen == 1 && ((TYPE_CODE (elttype) == TYPE_CODE_INT) || ((current_language->la_language == language_m2) && (TYPE_CODE (elttype) == TYPE_CODE_CHAR))) && (format == 0 || format == 's') && vector_int8s == 0) { /* If requested, look for the first null char and only print elements up to it. */ if (stop_print_at_null) { unsigned int temp_len; /* Look for a NULL char. */ for (temp_len = 0; (valaddr + embedded_offset)[temp_len] && temp_len < len && temp_len < print_max; temp_len++); len = temp_len; } LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0); i = len; } else { fprintf_filtered (stream, "{"); /* If this is a virtual function table, print the 0th entry specially, and the rest of the members normally. */ if (cp_is_vtbl_ptr_type (elttype)) { i = 1; fprintf_filtered (stream, _("%d vtable entries"), len - 1); } else { i = 0; } /* If this is an array of int8_t's in a vector register, force it to print as decimal by default, not as decimal value + octal escaped char. */ if (format == 0 && vector_int8s) format = 'd'; /* If this is an array of v4_float or v2_doubles in a vector register, force it to print with the '%a' floating point hex formatter when "p/x" is used. Default formatter remains the '%g' style. */ if (format == 'x' && vector_floats) format = 'A'; val_print_array_elements (type, valaddr + embedded_offset, address, stream, format, deref_ref, recurse, pretty, i); fprintf_filtered (stream, "}"); } break; } /* Array of unspecified length: treat like pointer to first elt. */ addr = address; goto print_unpacked_pointer; case TYPE_CODE_PTR: if (format && format != 's') { print_scalar_formatted (valaddr + embedded_offset, 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.) */ CORE_ADDR addr = extract_typed_address (valaddr + embedded_offset, type); print_function_pointer_address (addr, stream); break; } elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (TYPE_CODE (elttype) == TYPE_CODE_METHOD) { cp_print_class_method (valaddr + embedded_offset, type, stream); } else if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER) { cp_print_class_member (valaddr + embedded_offset, TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)), stream, "&"); } else { addr = unpack_pointer (type, valaddr + embedded_offset); print_unpacked_pointer: if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) { /* Try to print what function it points to. */ print_function_pointer_address (addr, stream); /* Return value is irrelevant except for string pointers. */ return (0); } if (addressprint && format != 's') { deprecated_print_address_numeric (addr, 1, stream); } /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ /* FIXME: need to handle wchar_t here... */ if (TYPE_LENGTH (elttype) == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT && (format == 0 || format == 's') && addr != 0) { i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream); } else if (cp_is_vtbl_member (type)) { /* print vtbl's nicely */ CORE_ADDR vt_address = unpack_pointer (type, valaddr + embedded_offset); struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (vt_address); if ((msymbol != NULL) && (vt_address == SYMBOL_VALUE_ADDRESS (msymbol))) { fputs_filtered (" <", stream); fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream); fputs_filtered (">", stream); } if (vt_address && vtblprint) { struct value *vt_val; struct symbol *wsym = (struct symbol *) NULL; struct type *wtype; struct block *block = (struct block *) NULL; int is_this_fld; if (msymbol != NULL) wsym = lookup_symbol (DEPRECATED_SYMBOL_NAME (msymbol), block, VAR_DOMAIN, &is_this_fld, NULL); if (wsym) { wtype = SYMBOL_TYPE (wsym); } else { wtype = TYPE_TARGET_TYPE (type); } vt_val = value_at (wtype, vt_address); common_val_print (vt_val, stream, format, deref_ref, recurse + 1, pretty); if (pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); } } } /* Return number of characters printed, including the terminating '\0' if we reached the end. val_print_string takes care including the terminating '\0' if necessary. */ return i; } break; case TYPE_CODE_MEMBER: error (_("not implemented: member type in c_val_print")); break; case TYPE_CODE_REF: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER) { cp_print_class_member (valaddr + embedded_offset, TYPE_DOMAIN_TYPE (elttype), stream, ""); break; } if (addressprint) { CORE_ADDR addr = extract_typed_address (valaddr + embedded_offset, type); fprintf_filtered (stream, "@"); deprecated_print_address_numeric (addr, 1, stream); if (deref_ref) fputs_filtered (": ", stream); } /* De-reference the reference. */ if (deref_ref) { if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) { struct value *deref_val = value_at (TYPE_TARGET_TYPE (type), unpack_pointer (lookup_pointer_type (builtin_type_void), valaddr + embedded_offset)); common_val_print (deref_val, stream, format, deref_ref, recurse, pretty); } else fputs_filtered ("???", stream); } break; case TYPE_CODE_UNION: if (recurse && !unionprint) { fprintf_filtered (stream, "{...}"); break; } /* Fall through. */ case TYPE_CODE_STRUCT: /*FIXME: Abstract this away */ if (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.) */ int offset = (embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8); struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET); CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type); print_function_pointer_address (addr, stream); } else cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format, recurse, pretty, NULL, 0); break; case TYPE_CODE_ENUM: if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); break; } len = TYPE_NFIELDS (type); val = unpack_long (type, valaddr + embedded_offset); for (i = 0; i < len; i++) { QUIT; if (val == TYPE_FIELD_BITPOS (type, i)) { break; } } if (i < len) { fputs_filtered (TYPE_FIELD_NAME (type, i), stream); } else { print_longest (stream, 'd', 0, val); } break; case TYPE_CODE_FUNC: if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); break; } /* FIXME, we should consider, at least for ANSI C language, eliminating the distinction made between FUNCs and POINTERs to FUNCs. */ fprintf_filtered (stream, "{"); type_print (type, "", stream, -1); fprintf_filtered (stream, "} "); /* Try to print what function it points to, and its address. */ print_address_demangle (address, stream, demangle); break; case TYPE_CODE_BOOL: format = format ? format : output_format; if (format) print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); else { val = unpack_long (type, valaddr + embedded_offset); if (val == 0) fputs_filtered ("false", stream); else if (val == 1) fputs_filtered ("true", stream); else print_longest (stream, 'd', 0, val); } break; case TYPE_CODE_RANGE: /* FIXME: create_range_type does not set the unsigned bit in a range type (I think it probably should copy it from the target type), so we won't print values which are too large to fit in a signed integer correctly. */ /* FIXME: Doesn't handle ranges of enums correctly. (Can't just print with the target type, though, because the size of our type and the target type might differ). */ /* FALLTHROUGH */ case TYPE_CODE_INT: format = format ? format : output_format; if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); } else { val_print_type_code_int (type, valaddr + embedded_offset, stream); /* C and C++ has no single byte int type, char is used instead. Since we don't know whether the value is really intended to be used as an integer or a character, print the character equivalent as well. */ if (TYPE_LENGTH (type) == 1) { fputs_filtered (" ", stream); LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset), stream); } } break; case TYPE_CODE_CHAR: format = format ? format : output_format; if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); } else { val = unpack_long (type, valaddr + embedded_offset); if (TYPE_UNSIGNED (type)) fprintf_filtered (stream, "%u", (unsigned int) val); else fprintf_filtered (stream, "%d", (int) val); fputs_filtered (" ", stream); LA_PRINT_CHAR ((unsigned char) val, stream); } break; case TYPE_CODE_FLT: if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); } else { print_floating (valaddr + embedded_offset, type, stream); } break; case TYPE_CODE_METHOD: { struct value *v = value_at (type, address); cp_print_class_method (value_contents (value_addr (v)), lookup_pointer_type (type), stream); break; } case TYPE_CODE_VOID: fprintf_filtered (stream, "void"); break; case TYPE_CODE_ERROR: /* APPLE LOCAL display error as unknown type */ fprintf_filtered (stream, _("<unknown type>")); break; case TYPE_CODE_UNDEF: /* This happens (without TYPE_FLAG_STUB set) on systems which don't use dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" and no complete type for struct foo in that file. */ fprintf_filtered (stream, _("<incomplete type>")); break; case TYPE_CODE_COMPLEX: if (format) print_scalar_formatted (valaddr + embedded_offset, TYPE_TARGET_TYPE (type), format, 0, stream); else print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type), stream); fprintf_filtered (stream, " + "); if (format) print_scalar_formatted (valaddr + embedded_offset + TYPE_LENGTH (TYPE_TARGET_TYPE (type)), TYPE_TARGET_TYPE (type), format, 0, stream); else print_floating (valaddr + embedded_offset + TYPE_LENGTH (TYPE_TARGET_TYPE (type)), TYPE_TARGET_TYPE (type), stream); fprintf_filtered (stream, " * I"); break; default: error (_("Invalid C/C++ type code %d in symbol table."), TYPE_CODE (type)); } gdb_flush (stream); return (0); }
void c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *original_value, const struct value_print_options *options) { struct gdbarch *gdbarch = get_type_arch (type); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); unsigned int i = 0; /* Number of characters printed. */ unsigned len; struct type *elttype, *unresolved_elttype; struct type *unresolved_type = type; unsigned eltlen; CORE_ADDR addr; CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: unresolved_elttype = TYPE_TARGET_TYPE (type); elttype = check_typedef (unresolved_elttype); if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0) { LONGEST low_bound, high_bound; if (!get_array_bounds (type, &low_bound, &high_bound)) error (_("Could not determine the array high bound")); eltlen = TYPE_LENGTH (elttype); len = high_bound - low_bound + 1; if (options->prettyformat_arrays) { print_spaces_filtered (2 + 2 * recurse, stream); } /* Print arrays of textual chars with a string syntax, as long as the entire array is valid. */ if (c_textual_element_type (unresolved_elttype, options->format) && value_bytes_available (original_value, embedded_offset, TYPE_LENGTH (type)) && value_bits_valid (original_value, TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * TYPE_LENGTH (type))) { int force_ellipses = 0; /* If requested, look for the first null char and only print elements up to it. */ if (options->stop_print_at_null) { unsigned int temp_len; for (temp_len = 0; (temp_len < len && temp_len < options->print_max && extract_unsigned_integer (valaddr + embedded_offset + temp_len * eltlen, eltlen, byte_order) != 0); ++temp_len) ; /* Force LA_PRINT_STRING to print ellipses if we've printed the maximum characters and the next character is not \000. */ if (temp_len == options->print_max && temp_len < len) { ULONGEST val = extract_unsigned_integer (valaddr + embedded_offset + temp_len * eltlen, eltlen, byte_order); if (val != 0) force_ellipses = 1; } len = temp_len; } LA_PRINT_STRING (stream, unresolved_elttype, valaddr + embedded_offset, len, NULL, force_ellipses, options); i = len; } else { fprintf_filtered (stream, "{"); /* If this is a virtual function table, print the 0th entry specially, and the rest of the members normally. */ if (cp_is_vtbl_ptr_type (elttype)) { i = 1; fprintf_filtered (stream, _("%d vtable entries"), len - 1); } else { i = 0; } val_print_array_elements (type, valaddr, embedded_offset, address, stream, recurse, original_value, options, i); fprintf_filtered (stream, "}"); } break; } /* Array of unspecified length: treat like pointer to first elt. */ addr = address + embedded_offset; goto print_unpacked_pointer; case TYPE_CODE_METHODPTR: cplus_print_method_ptr (valaddr + embedded_offset, type, stream); break; case TYPE_CODE_PTR: if (options->format && options->format != 's') { val_print_scalar_formatted (type, valaddr, embedded_offset, original_value, options, 0, stream); break; } if (options->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.) */ CORE_ADDR addr = extract_typed_address (valaddr + embedded_offset, type); print_function_pointer_address (options, gdbarch, addr, stream); break; } unresolved_elttype = TYPE_TARGET_TYPE (type); elttype = check_typedef (unresolved_elttype); { int want_space; addr = unpack_pointer (type, valaddr + embedded_offset); print_unpacked_pointer: want_space = 0; if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) { /* Try to print what function it points to. */ print_function_pointer_address (options, gdbarch, addr, stream); return; } if (options->symbol_print) want_space = print_address_demangle (options, gdbarch, addr, stream, demangle); else if (options->addressprint) { fputs_filtered (paddress (gdbarch, addr), 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) && addr != 0) { if (want_space) fputs_filtered (" ", stream); i = val_print_string (unresolved_elttype, NULL, addr, -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 == SYMBOL_VALUE_ADDRESS (msymbol.minsym))) { if (want_space) fputs_filtered (" ", stream); fputs_filtered (" <", stream); fputs_filtered (SYMBOL_PRINT_NAME (msymbol.minsym), stream); fputs_filtered (">", stream); want_space = 1; } if (vt_address && options->vtblprint) { struct value *vt_val; struct symbol *wsym = (struct symbol *) NULL; struct type *wtype; struct block *block = (struct block *) NULL; struct field_of_this_result is_this_fld; if (want_space) fputs_filtered (" ", stream); if (msymbol.minsym != NULL) wsym = lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol.minsym), block, VAR_DOMAIN, &is_this_fld); if (wsym) { wtype = SYMBOL_TYPE (wsym); } else { wtype = unresolved_elttype; } vt_val = value_at (wtype, vt_address); common_val_print (vt_val, stream, recurse + 1, options, current_language); if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); } } } return; } break; case TYPE_CODE_UNION: if (recurse && !options->unionprint) { fprintf_filtered (stream, "{...}"); break; } /* Fall through. */ case TYPE_CODE_STRUCT: /*FIXME: Abstract this away. */ 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.) */ int offset = (embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8); struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET); CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type); print_function_pointer_address (options, gdbarch, addr, stream); } else cp_print_value_fields_rtti (type, valaddr, embedded_offset, address, stream, recurse, original_value, options, NULL, 0); break; case TYPE_CODE_INT: if (options->format || options->output_format) { struct value_print_options opts = *options; opts.format = (options->format ? options->format : options->output_format); val_print_scalar_formatted (type, valaddr, embedded_offset, original_value, &opts, 0, stream); } else { val_print_type_code_int (type, valaddr + embedded_offset, stream); /* C and C++ has no single byte int type, char is used instead. Since we don't know whether the value is really intended to be used as an integer or a character, print the character equivalent as well. */ if (c_textual_element_type (unresolved_type, options->format)) { fputs_filtered (" ", stream); LA_PRINT_CHAR (unpack_long (type, valaddr + embedded_offset), unresolved_type, stream); } } break; case TYPE_CODE_MEMBERPTR: if (!options->format) { cp_print_class_member (valaddr + embedded_offset, type, stream, "&"); break; } /* FALLTHROUGH */ case TYPE_CODE_REF: case TYPE_CODE_ENUM: case TYPE_CODE_FLAGS: case TYPE_CODE_FUNC: case TYPE_CODE_METHOD: case TYPE_CODE_BOOL: case TYPE_CODE_RANGE: case TYPE_CODE_FLT: case TYPE_CODE_DECFLOAT: case TYPE_CODE_VOID: case TYPE_CODE_ERROR: case TYPE_CODE_UNDEF: case TYPE_CODE_COMPLEX: case TYPE_CODE_CHAR: default: generic_val_print (type, valaddr, embedded_offset, address, stream, recurse, original_value, options, &c_decorations); break; } gdb_flush (stream); }
void pascal_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *original_value, const struct value_print_options *options) { struct gdbarch *gdbarch = get_type_arch (type); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); unsigned int i = 0; /* Number of characters printed */ unsigned len; LONGEST low_bound, high_bound; struct type *elttype; unsigned eltlen; int length_pos, length_size, string_pos; struct type *char_type; CORE_ADDR addr; int want_space = 0; type = check_typedef (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: if (get_array_bounds (type, &low_bound, &high_bound)) { len = high_bound - low_bound + 1; elttype = check_typedef (TYPE_TARGET_TYPE (type)); eltlen = TYPE_LENGTH (elttype); if (options->prettyformat_arrays) { print_spaces_filtered (2 + 2 * recurse, stream); } /* If 's' format is used, try to print out as string. If no format is given, print as string if element type is of TYPE_CODE_CHAR and element size is 1,2 or 4. */ if (options->format == 's' || ((eltlen == 1 || eltlen == 2 || eltlen == 4) && TYPE_CODE (elttype) == TYPE_CODE_CHAR && options->format == 0)) { /* If requested, look for the first null char and only print elements up to it. */ if (options->stop_print_at_null) { unsigned int temp_len; /* Look for a NULL char. */ for (temp_len = 0; extract_unsigned_integer (valaddr + embedded_offset + temp_len * eltlen, eltlen, byte_order) && temp_len < len && temp_len < options->print_max; temp_len++); len = temp_len; } LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type), valaddr + embedded_offset, len, NULL, 0, options); i = len; } else { fprintf_filtered (stream, "{"); /* If this is a virtual function table, print the 0th entry specially, and the rest of the members normally. */ if (pascal_object_is_vtbl_ptr_type (elttype)) { i = 1; fprintf_filtered (stream, "%d vtable entries", len - 1); } else { i = 0; } val_print_array_elements (type, valaddr, embedded_offset, address, stream, recurse, original_value, options, i); fprintf_filtered (stream, "}"); } break; } /* Array of unspecified length: treat like pointer to first elt. */ addr = address + embedded_offset; goto print_unpacked_pointer; case TYPE_CODE_PTR: if (options->format && options->format != 's') { val_print_scalar_formatted (type, valaddr, embedded_offset, original_value, options, 0, stream); break; } if (options->vtblprint && pascal_object_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.) */ /* Extract the address, assume that it is unsigned. */ addr = extract_unsigned_integer (valaddr + embedded_offset, TYPE_LENGTH (type), byte_order); print_address_demangle (options, gdbarch, addr, stream, demangle); break; } check_typedef (TYPE_TARGET_TYPE (type)); addr = unpack_pointer (type, valaddr + embedded_offset); print_unpacked_pointer: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) { /* Try to print what function it points to. */ print_address_demangle (options, gdbarch, addr, stream, demangle); return; } if (options->addressprint && options->format != 's') { fputs_filtered (paddress (gdbarch, addr), stream); want_space = 1; } /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ if (((TYPE_LENGTH (elttype) == 1 && (TYPE_CODE (elttype) == TYPE_CODE_INT || TYPE_CODE (elttype) == TYPE_CODE_CHAR)) || ((TYPE_LENGTH (elttype) == 2 || TYPE_LENGTH (elttype) == 4) && TYPE_CODE (elttype) == TYPE_CODE_CHAR)) && (options->format == 0 || options->format == 's') && addr != 0) { if (want_space) fputs_filtered (" ", stream); /* No wide string yet. */ i = val_print_string (elttype, NULL, addr, -1, stream, options); } /* Also for pointers to pascal strings. */ /* Note: this is Free Pascal specific: as GDB does not recognize stabs pascal strings Pascal strings are mapped to records with lowercase names PM. */ if (is_pascal_string_type (elttype, &length_pos, &length_size, &string_pos, &char_type, NULL) && addr != 0) { ULONGEST string_length; gdb_byte *buffer; if (want_space) fputs_filtered (" ", stream); buffer = (gdb_byte *) xmalloc (length_size); read_memory (addr + length_pos, buffer, length_size); string_length = extract_unsigned_integer (buffer, length_size, byte_order); xfree (buffer); i = val_print_string (char_type, NULL, addr + string_pos, string_length, stream, options); } else if (pascal_object_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))) { if (want_space) fputs_filtered (" ", stream); fputs_filtered ("<", stream); fputs_filtered (MSYMBOL_PRINT_NAME (msymbol.minsym), stream); fputs_filtered (">", stream); want_space = 1; } if (vt_address && options->vtblprint) { struct value *vt_val; struct symbol *wsym = NULL; struct type *wtype; struct block *block = NULL; struct field_of_this_result is_this_fld; if (want_space) fputs_filtered (" ", stream); if (msymbol.minsym != NULL) wsym = lookup_symbol (MSYMBOL_LINKAGE_NAME (msymbol.minsym), block, VAR_DOMAIN, &is_this_fld).symbol; if (wsym) { wtype = SYMBOL_TYPE (wsym); } else { wtype = TYPE_TARGET_TYPE (type); } vt_val = value_at (wtype, vt_address); common_val_print (vt_val, stream, recurse + 1, options, current_language); if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); } } } return; case TYPE_CODE_REF: case TYPE_CODE_ENUM: case TYPE_CODE_FLAGS: case TYPE_CODE_FUNC: case TYPE_CODE_RANGE: case TYPE_CODE_INT: case TYPE_CODE_FLT: case TYPE_CODE_VOID: case TYPE_CODE_ERROR: case TYPE_CODE_UNDEF: case TYPE_CODE_BOOL: case TYPE_CODE_CHAR: generic_val_print (type, valaddr, embedded_offset, address, stream, recurse, original_value, options, &p_decorations); break; case TYPE_CODE_UNION: if (recurse && !options->unionprint) { fprintf_filtered (stream, "{...}"); break; } /* Fall through. */ case TYPE_CODE_STRUCT: if (options->vtblprint && pascal_object_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.) */ /* Extract the address, assume that it is unsigned. */ print_address_demangle (options, gdbarch, extract_unsigned_integer (valaddr + embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8, TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET)), byte_order), stream, demangle); } else { if (is_pascal_string_type (type, &length_pos, &length_size, &string_pos, &char_type, NULL)) { len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size, byte_order); LA_PRINT_STRING (stream, char_type, valaddr + embedded_offset + string_pos, len, NULL, 0, options); } else pascal_object_print_value_fields (type, valaddr, embedded_offset, address, stream, recurse, original_value, options, NULL, 0); } break; case TYPE_CODE_SET: elttype = TYPE_INDEX_TYPE (type); elttype = check_typedef (elttype); if (TYPE_STUB (elttype)) { fprintf_filtered (stream, "<incomplete type>"); gdb_flush (stream); break; } else { struct type *range = elttype; LONGEST low_bound, high_bound; int i; int need_comma = 0; fputs_filtered ("[", stream); i = get_discrete_bounds (range, &low_bound, &high_bound); if (low_bound == 0 && high_bound == -1 && TYPE_LENGTH (type) > 0) { /* If we know the size of the set type, we can figure out the maximum value. */ i = 0; high_bound = TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1; TYPE_HIGH_BOUND (range) = high_bound; } maybe_bad_bstring: if (i < 0) { fputs_filtered ("<error value>", stream); goto done; } for (i = low_bound; i <= high_bound; i++) { int element = value_bit_index (type, valaddr + embedded_offset, i); if (element < 0) { i = element; goto maybe_bad_bstring; } if (element) { if (need_comma) fputs_filtered (", ", stream); print_type_scalar (range, i, stream); need_comma = 1; if (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i)) { int j = i; fputs_filtered ("..", stream); while (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i)) j = i; print_type_scalar (range, j, stream); } } } done: fputs_filtered ("]", stream); } break; default: error (_("Invalid pascal type code %d in symbol table."), TYPE_CODE (type)); } gdb_flush (stream); }
int pascal_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int format, int deref_ref, int recurse, enum val_prettyprint pretty) { unsigned int i = 0; /* Number of characters printed */ unsigned len; struct type *elttype; unsigned eltlen; int length_pos, length_size, string_pos; int char_size; LONGEST val; CORE_ADDR addr; CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) { elttype = check_typedef (TYPE_TARGET_TYPE (type)); eltlen = TYPE_LENGTH (elttype); len = TYPE_LENGTH (type) / eltlen; if (prettyprint_arrays) { print_spaces_filtered (2 + 2 * recurse, stream); } /* For an array of chars, print with string syntax. */ if (eltlen == 1 && ((TYPE_CODE (elttype) == TYPE_CODE_INT) || ((current_language->la_language == language_pascal) && (TYPE_CODE (elttype) == TYPE_CODE_CHAR))) && (format == 0 || format == 's')) { /* If requested, look for the first null char and only print elements up to it. */ if (stop_print_at_null) { unsigned int temp_len; /* Look for a NULL char. */ for (temp_len = 0; (valaddr + embedded_offset)[temp_len] && temp_len < len && temp_len < print_max; temp_len++); len = temp_len; } LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0); i = len; } else { fprintf_filtered (stream, "{"); /* If this is a virtual function table, print the 0th entry specially, and the rest of the members normally. */ if (pascal_object_is_vtbl_ptr_type (elttype)) { i = 1; fprintf_filtered (stream, "%d vtable entries", len - 1); } else { i = 0; } val_print_array_elements (type, valaddr + embedded_offset, address, stream, format, deref_ref, recurse, pretty, i); fprintf_filtered (stream, "}"); } break; } /* Array of unspecified length: treat like pointer to first elt. */ addr = address; goto print_unpacked_pointer; case TYPE_CODE_PTR: if (format && format != 's') { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); break; } if (vtblprint && pascal_object_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.) */ /* Extract the address, assume that it is unsigned. */ print_address_demangle (extract_unsigned_integer (valaddr + embedded_offset, TYPE_LENGTH (type)), stream, demangle); break; } elttype = check_typedef (TYPE_TARGET_TYPE (type)); { addr = unpack_pointer (type, valaddr + embedded_offset); print_unpacked_pointer: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) { /* Try to print what function it points to. */ print_address_demangle (addr, stream, demangle); /* Return value is irrelevant except for string pointers. */ return (0); } if (addressprint && format != 's') { fputs_filtered (paddress (addr), stream); } /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ if (TYPE_LENGTH (elttype) == 1 && (TYPE_CODE (elttype) == TYPE_CODE_INT || TYPE_CODE(elttype) == TYPE_CODE_CHAR) && (format == 0 || format == 's') && addr != 0) { /* no wide string yet */ i = val_print_string (addr, -1, 1, stream); } /* also for pointers to pascal strings */ /* Note: this is Free Pascal specific: as GDB does not recognize stabs pascal strings Pascal strings are mapped to records with lowercase names PM */ if (is_pascal_string_type (elttype, &length_pos, &length_size, &string_pos, &char_size, NULL) && addr != 0) { ULONGEST string_length; void *buffer; buffer = xmalloc (length_size); read_memory (addr + length_pos, buffer, length_size); string_length = extract_unsigned_integer (buffer, length_size); xfree (buffer); i = val_print_string (addr + string_pos, string_length, char_size, stream); } else if (pascal_object_is_vtbl_member (type)) { /* print vtbl's nicely */ CORE_ADDR vt_address = unpack_pointer (type, valaddr + embedded_offset); struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (vt_address); if ((msymbol != NULL) && (vt_address == SYMBOL_VALUE_ADDRESS (msymbol))) { fputs_filtered (" <", stream); fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream); fputs_filtered (">", stream); } if (vt_address && vtblprint) { struct value *vt_val; struct symbol *wsym = (struct symbol *) NULL; struct type *wtype; struct block *block = (struct block *) NULL; int is_this_fld; if (msymbol != NULL) wsym = lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol), block, VAR_DOMAIN, &is_this_fld, NULL); if (wsym) { wtype = SYMBOL_TYPE (wsym); } else { wtype = TYPE_TARGET_TYPE (type); } vt_val = value_at (wtype, vt_address); common_val_print (vt_val, stream, format, deref_ref, recurse + 1, pretty); if (pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); } } } /* Return number of characters printed, including the terminating '\0' if we reached the end. val_print_string takes care including the terminating '\0' if necessary. */ return i; } break; case TYPE_CODE_REF: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (addressprint) { fprintf_filtered (stream, "@"); /* Extract the address, assume that it is unsigned. */ fputs_filtered (paddress ( extract_unsigned_integer (valaddr + embedded_offset, gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT)), stream); if (deref_ref) fputs_filtered (": ", stream); } /* De-reference the reference. */ if (deref_ref) { if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) { struct value *deref_val = value_at (TYPE_TARGET_TYPE (type), unpack_pointer (lookup_pointer_type (builtin_type_void), valaddr + embedded_offset)); common_val_print (deref_val, stream, format, deref_ref, recurse + 1, pretty); } else fputs_filtered ("???", stream); } break; case TYPE_CODE_UNION: if (recurse && !unionprint) { fprintf_filtered (stream, "{...}"); break; } /* Fall through. */ case TYPE_CODE_STRUCT: if (vtblprint && pascal_object_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.) */ /* Extract the address, assume that it is unsigned. */ print_address_demangle (extract_unsigned_integer (valaddr + embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8, TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET))), stream, demangle); } else { if (is_pascal_string_type (type, &length_pos, &length_size, &string_pos, &char_size, NULL)) { len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size); LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0); } else pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream, format, recurse, pretty, NULL, 0); } break; case TYPE_CODE_ENUM: if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); break; } len = TYPE_NFIELDS (type); val = unpack_long (type, valaddr + embedded_offset); for (i = 0; i < len; i++) { QUIT; if (val == TYPE_FIELD_BITPOS (type, i)) { break; } } if (i < len) { fputs_filtered (TYPE_FIELD_NAME (type, i), stream); } else { print_longest (stream, 'd', 0, val); } break; case TYPE_CODE_FLAGS: if (format) print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); else val_print_type_code_flags (type, valaddr + embedded_offset, stream); break; case TYPE_CODE_FUNC: if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); break; } /* FIXME, we should consider, at least for ANSI C language, eliminating the distinction made between FUNCs and POINTERs to FUNCs. */ fprintf_filtered (stream, "{"); type_print (type, "", stream, -1); fprintf_filtered (stream, "} "); /* Try to print what function it points to, and its address. */ print_address_demangle (address, stream, demangle); break; case TYPE_CODE_BOOL: format = format ? format : output_format; if (format) print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); else { val = unpack_long (type, valaddr + embedded_offset); if (val == 0) fputs_filtered ("false", stream); else if (val == 1) fputs_filtered ("true", stream); else { fputs_filtered ("true (", stream); fprintf_filtered (stream, "%ld)", (long int) val); } } break; case TYPE_CODE_RANGE: /* FIXME: create_range_type does not set the unsigned bit in a range type (I think it probably should copy it from the target type), so we won't print values which are too large to fit in a signed integer correctly. */ /* FIXME: Doesn't handle ranges of enums correctly. (Can't just print with the target type, though, because the size of our type and the target type might differ). */ /* FALLTHROUGH */ case TYPE_CODE_INT: format = format ? format : output_format; if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); } else { val_print_type_code_int (type, valaddr + embedded_offset, stream); } break; case TYPE_CODE_CHAR: format = format ? format : output_format; if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); } else { val = unpack_long (type, valaddr + embedded_offset); if (TYPE_UNSIGNED (type)) fprintf_filtered (stream, "%u", (unsigned int) val); else fprintf_filtered (stream, "%d", (int) val); fputs_filtered (" ", stream); LA_PRINT_CHAR ((unsigned char) val, stream); } break; case TYPE_CODE_FLT: if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); } else { print_floating (valaddr + embedded_offset, type, stream); } break; case TYPE_CODE_BITSTRING: case TYPE_CODE_SET: elttype = TYPE_INDEX_TYPE (type); CHECK_TYPEDEF (elttype); if (TYPE_STUB (elttype)) { fprintf_filtered (stream, "<incomplete type>"); gdb_flush (stream); break; } else { struct type *range = elttype; LONGEST low_bound, high_bound; int i; int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING; int need_comma = 0; if (is_bitstring) fputs_filtered ("B'", stream); else fputs_filtered ("[", stream); i = get_discrete_bounds (range, &low_bound, &high_bound); maybe_bad_bstring: if (i < 0) { fputs_filtered ("<error value>", stream); goto done; } for (i = low_bound; i <= high_bound; i++) { int element = value_bit_index (type, valaddr + embedded_offset, i); if (element < 0) { i = element; goto maybe_bad_bstring; } if (is_bitstring) fprintf_filtered (stream, "%d", element); else if (element) { if (need_comma) fputs_filtered (", ", stream); print_type_scalar (range, i, stream); need_comma = 1; if (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i)) { int j = i; fputs_filtered ("..", stream); while (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i)) j = i; print_type_scalar (range, j, stream); } } } done: if (is_bitstring) fputs_filtered ("'", stream); else fputs_filtered ("]", stream); } break; case TYPE_CODE_VOID: fprintf_filtered (stream, "void"); break; case TYPE_CODE_ERROR: fprintf_filtered (stream, "<error type>"); break; case TYPE_CODE_UNDEF: /* This happens (without TYPE_FLAG_STUB set) on systems which don't use dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" and no complete type for struct foo in that file. */ fprintf_filtered (stream, "<incomplete type>"); break; default: error (_("Invalid pascal type code %d in symbol table."), TYPE_CODE (type)); } gdb_flush (stream); return (0); }
int m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int format, int deref_ref, int recurse, enum val_prettyprint pretty) { unsigned int i = 0; /* Number of characters printed */ unsigned len; struct type *elttype; unsigned eltlen; int length_pos, length_size, string_pos; int char_size; LONGEST val; CORE_ADDR addr; CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) { elttype = check_typedef (TYPE_TARGET_TYPE (type)); eltlen = TYPE_LENGTH (elttype); len = TYPE_LENGTH (type) / eltlen; if (prettyprint_arrays) print_spaces_filtered (2 + 2 * recurse, stream); /* For an array of chars, print with string syntax. */ if (eltlen == 1 && ((TYPE_CODE (elttype) == TYPE_CODE_INT) || ((current_language->la_language == language_m2) && (TYPE_CODE (elttype) == TYPE_CODE_CHAR))) && (format == 0 || format == 's')) { /* If requested, look for the first null char and only print elements up to it. */ if (stop_print_at_null) { unsigned int temp_len; /* Look for a NULL char. */ for (temp_len = 0; (valaddr + embedded_offset)[temp_len] && temp_len < len && temp_len < print_max; temp_len++); len = temp_len; } LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0); i = len; } else { fprintf_filtered (stream, "{"); val_print_array_elements (type, valaddr + embedded_offset, address, stream, format, deref_ref, recurse, pretty, 0); fprintf_filtered (stream, "}"); } break; } /* Array of unspecified length: treat like pointer to first elt. */ print_unpacked_pointer (type, address, address, format, stream); break; case TYPE_CODE_PTR: if (TYPE_CONST (type)) print_variable_at_address (type, valaddr + embedded_offset, stream, format, deref_ref, recurse, pretty); else if (format && format != 's') print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); else { addr = unpack_pointer (type, valaddr + embedded_offset); print_unpacked_pointer (type, addr, address, format, stream); } break; case TYPE_CODE_MEMBER: error (_("not implemented: member type in m2_val_print")); break; case TYPE_CODE_REF: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (addressprint) { CORE_ADDR addr = extract_typed_address (valaddr + embedded_offset, type); fprintf_filtered (stream, "@"); fputs_filtered (paddress (addr), stream); if (deref_ref) fputs_filtered (": ", stream); } /* De-reference the reference. */ if (deref_ref) { if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) { struct value *deref_val = value_at (TYPE_TARGET_TYPE (type), unpack_pointer (lookup_pointer_type (builtin_type_void), valaddr + embedded_offset)); common_val_print (deref_val, stream, format, deref_ref, recurse, pretty); } else fputs_filtered ("???", stream); } break; case TYPE_CODE_UNION: if (recurse && !unionprint) { fprintf_filtered (stream, "{...}"); break; } /* Fall through. */ case TYPE_CODE_STRUCT: if (m2_is_long_set (type)) m2_print_long_set (type, valaddr, embedded_offset, address, stream, format, pretty); else cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format, recurse, pretty, NULL, 0); break; case TYPE_CODE_ENUM: if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); break; } len = TYPE_NFIELDS (type); val = unpack_long (type, valaddr + embedded_offset); for (i = 0; i < len; i++) { QUIT; if (val == TYPE_FIELD_BITPOS (type, i)) { break; } } if (i < len) { fputs_filtered (TYPE_FIELD_NAME (type, i), stream); } else { print_longest (stream, 'd', 0, val); } break; case TYPE_CODE_FUNC: if (format) { print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); break; } /* FIXME, we should consider, at least for ANSI C language, eliminating the distinction made between FUNCs and POINTERs to FUNCs. */ fprintf_filtered (stream, "{"); type_print (type, "", stream, -1); fprintf_filtered (stream, "} "); /* Try to print what function it points to, and its address. */ print_address_demangle (address, stream, demangle); break; case TYPE_CODE_BOOL: format = format ? format : output_format; if (format) print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); else { val = unpack_long (type, valaddr + embedded_offset); if (val == 0) fputs_filtered ("FALSE", stream); else if (val == 1) fputs_filtered ("TRUE", stream); else fprintf_filtered (stream, "%ld)", (long int) val); } break; case TYPE_CODE_RANGE: if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type))) { m2_val_print (TYPE_TARGET_TYPE (type), valaddr, embedded_offset, address, stream, format, deref_ref, recurse, pretty); break; } /* FIXME: create_range_type does not set the unsigned bit in a range type (I think it probably should copy it from the target type), so we won't print values which are too large to fit in a signed integer correctly. */ /* FIXME: Doesn't handle ranges of enums correctly. (Can't just print with the target type, though, because the size of our type and the target type might differ). */ /* FALLTHROUGH */ case TYPE_CODE_INT: format = format ? format : output_format; if (format) print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); else val_print_type_code_int (type, valaddr + embedded_offset, stream); break; case TYPE_CODE_CHAR: format = format ? format : output_format; if (format) print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); else { val = unpack_long (type, valaddr + embedded_offset); if (TYPE_UNSIGNED (type)) fprintf_filtered (stream, "%u", (unsigned int) val); else fprintf_filtered (stream, "%d", (int) val); fputs_filtered (" ", stream); LA_PRINT_CHAR ((unsigned char) val, stream); } break; case TYPE_CODE_FLT: if (format) print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream); else print_floating (valaddr + embedded_offset, type, stream); break; case TYPE_CODE_METHOD: break; case TYPE_CODE_BITSTRING: case TYPE_CODE_SET: elttype = TYPE_INDEX_TYPE (type); CHECK_TYPEDEF (elttype); if (TYPE_STUB (elttype)) { fprintf_filtered (stream, _("<incomplete type>")); gdb_flush (stream); break; } else { struct type *range = elttype; LONGEST low_bound, high_bound; int i; int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING; int need_comma = 0; if (is_bitstring) fputs_filtered ("B'", stream); else fputs_filtered ("{", stream); i = get_discrete_bounds (range, &low_bound, &high_bound); maybe_bad_bstring: if (i < 0) { fputs_filtered (_("<error value>"), stream); goto done; } for (i = low_bound; i <= high_bound; i++) { int element = value_bit_index (type, valaddr + embedded_offset, i); if (element < 0) { i = element; goto maybe_bad_bstring; } if (is_bitstring) fprintf_filtered (stream, "%d", element); else if (element) { if (need_comma) fputs_filtered (", ", stream); print_type_scalar (range, i, stream); need_comma = 1; if (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i)) { int j = i; fputs_filtered ("..", stream); while (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i)) j = i; print_type_scalar (range, j, stream); } } } done: if (is_bitstring) fputs_filtered ("'", stream); else fputs_filtered ("}", stream); } break; case TYPE_CODE_VOID: fprintf_filtered (stream, "void"); break; case TYPE_CODE_ERROR: fprintf_filtered (stream, _("<error type>")); break; case TYPE_CODE_UNDEF: /* This happens (without TYPE_FLAG_STUB set) on systems which don't use dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" and no complete type for struct foo in that file. */ fprintf_filtered (stream, _("<incomplete type>")); break; default: error (_("Invalid m2 type code %d in symbol table."), TYPE_CODE (type)); } gdb_flush (stream); return (0); }
static int ada_val_print_1 (struct type *type, char *valaddr0, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int format, int deref_ref, int recurse, enum val_prettyprint pretty) { unsigned int len; int i; struct type *elttype; unsigned int eltlen; LONGEST val; char *valaddr = valaddr0 + embedded_offset; CHECK_TYPEDEF (type); if (ada_is_array_descriptor_type (type) || ada_is_packed_array_type (type)) { int retn; struct value *mark = value_mark (); struct value *val; val = value_from_contents_and_address (type, valaddr, address); val = ada_coerce_to_simple_array_ptr (val); if (val == NULL) { fprintf_filtered (stream, "(null)"); retn = 0; } else retn = ada_val_print_1 (VALUE_TYPE (val), VALUE_CONTENTS (val), 0, VALUE_ADDRESS (val), stream, format, deref_ref, recurse, pretty); value_free_to_mark (mark); return retn; } valaddr = ada_aligned_value_addr (type, valaddr); embedded_offset -= valaddr - valaddr0 - embedded_offset; type = printable_val_type (type, valaddr); switch (TYPE_CODE (type)) { default: return c_val_print (type, valaddr0, embedded_offset, address, stream, format, deref_ref, recurse, pretty); case TYPE_CODE_PTR: { int ret = c_val_print (type, valaddr0, embedded_offset, address, stream, format, deref_ref, recurse, pretty); if (ada_is_tag_type (type)) { struct value *val = value_from_contents_and_address (type, valaddr, address); const char *name = ada_tag_name (val); if (name != NULL) fprintf_filtered (stream, " (%s)", name); return 0; } return ret; } case TYPE_CODE_INT: case TYPE_CODE_RANGE: if (ada_is_fixed_point_type (type)) { LONGEST v = unpack_long (type, valaddr); int len = TYPE_LENGTH (type); fprintf_filtered (stream, len < 4 ? "%.11g" : "%.17g", (double) ada_fixed_to_float (type, v)); return 0; } else if (ada_is_vax_floating_type (type)) { struct value *val = value_from_contents_and_address (type, valaddr, address); struct value *func = ada_vax_float_print_function (type); if (func != 0) { static struct type *parray_of_char = NULL; struct value *printable_val; if (parray_of_char == NULL) parray_of_char = make_pointer_type (create_array_type (NULL, builtin_type_char, create_range_type (NULL, builtin_type_int, 0, 32)), NULL); printable_val = value_ind (value_cast (parray_of_char, call_function_by_hand (func, 1, &val))); fprintf_filtered (stream, "%s", VALUE_CONTENTS (printable_val)); return 0; } /* No special printing function. Do as best we can. */ } else if (TYPE_CODE (type) == TYPE_CODE_RANGE) { struct type *target_type = TYPE_TARGET_TYPE (type); if (TYPE_LENGTH (type) != TYPE_LENGTH (target_type)) { /* Obscure case of range type that has different length from its base type. Perform a conversion, or we will get a nonsense value. Actually, we could use the same code regardless of lengths; I'm just avoiding a cast. */ struct value *v = value_cast (target_type, value_from_contents_and_address (type, valaddr, 0)); return ada_val_print_1 (target_type, VALUE_CONTENTS (v), 0, 0, stream, format, 0, recurse + 1, pretty); } else return ada_val_print_1 (TYPE_TARGET_TYPE (type), valaddr0, embedded_offset, address, stream, format, deref_ref, recurse, pretty); } else { format = format ? format : output_format; if (format) { print_scalar_formatted (valaddr, type, format, 0, stream); } else if (ada_is_system_address_type (type)) { /* FIXME: We want to print System.Address variables using the same format as for any access type. But for some reason GNAT encodes the System.Address type as an int, so we have to work-around this deficiency by handling System.Address values as a special case. */ fprintf_filtered (stream, "("); type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); print_address_numeric (extract_typed_address (valaddr, builtin_type_void_data_ptr), 1, stream); } else { val_print_type_code_int (type, valaddr, stream); if (ada_is_character_type (type)) { fputs_filtered (" ", stream); ada_printchar ((unsigned char) unpack_long (type, valaddr), stream); } } return 0; } case TYPE_CODE_ENUM: if (format) { print_scalar_formatted (valaddr, type, format, 0, stream); break; } len = TYPE_NFIELDS (type); val = unpack_long (type, valaddr); for (i = 0; i < len; i++) { QUIT; if (val == TYPE_FIELD_BITPOS (type, i)) { break; } } if (i < len) { const char *name = ada_enum_name (TYPE_FIELD_NAME (type, i)); if (name[0] == '\'') fprintf_filtered (stream, "%ld %s", (long) val, name); else fputs_filtered (name, stream); } else { print_longest (stream, 'd', 0, val); } break; case TYPE_CODE_FLT: if (format) return c_val_print (type, valaddr0, embedded_offset, address, stream, format, deref_ref, recurse, pretty); else ada_print_floating (valaddr0 + embedded_offset, type, stream); break; case TYPE_CODE_UNION: case TYPE_CODE_STRUCT: if (ada_is_bogus_array_descriptor (type)) { fprintf_filtered (stream, "(...?)"); return 0; } else { print_record (type, valaddr, stream, format, recurse, pretty); return 0; } case TYPE_CODE_ARRAY: elttype = TYPE_TARGET_TYPE (type); if (elttype == NULL) eltlen = 0; else eltlen = TYPE_LENGTH (elttype); /* FIXME: This doesn't deal with non-empty arrays of 0-length items (not a typical case!) */ if (eltlen == 0) len = 0; else len = TYPE_LENGTH (type) / eltlen; /* For an array of chars, print with string syntax. */ if (ada_is_string_type (type) && (format == 0 || format == 's')) { if (prettyprint_arrays) { print_spaces_filtered (2 + 2 * recurse, stream); } /* If requested, look for the first null char and only print elements up to it. */ if (stop_print_at_null) { int temp_len; /* Look for a NULL char. */ for (temp_len = 0; temp_len < len && temp_len < print_max && char_at (valaddr, temp_len, eltlen) != 0; temp_len += 1); len = temp_len; } printstr (stream, valaddr, len, 0, eltlen); } else { len = 0; fprintf_filtered (stream, "("); print_optional_low_bound (stream, type); if (TYPE_FIELD_BITSIZE (type, 0) > 0) val_print_packed_array_elements (type, valaddr, 0, stream, format, recurse, pretty); else val_print_array_elements (type, valaddr, address, stream, format, deref_ref, recurse, pretty, 0); fprintf_filtered (stream, ")"); } gdb_flush (stream); return len; case TYPE_CODE_REF: elttype = check_typedef (TYPE_TARGET_TYPE (type)); /* De-reference the reference */ if (deref_ref) { if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) { LONGEST deref_val_int = (LONGEST) unpack_pointer (lookup_pointer_type (builtin_type_void), valaddr); if (deref_val_int != 0) { struct value *deref_val = ada_value_ind (value_from_longest (lookup_pointer_type (elttype), deref_val_int)); val_print (VALUE_TYPE (deref_val), VALUE_CONTENTS (deref_val), 0, VALUE_ADDRESS (deref_val), stream, format, deref_ref, recurse + 1, pretty); } else fputs_filtered ("(null)", stream); } else fputs_filtered ("???", stream); } break; } gdb_flush (stream); return 0; }
int c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value_print_options *options) { struct gdbarch *gdbarch = get_type_arch (type); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); unsigned int i = 0; /* Number of characters printed */ unsigned len; struct type *elttype, *unresolved_elttype; struct type *unresolved_type = type; unsigned eltlen; LONGEST val; CORE_ADDR addr; CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: unresolved_elttype = TYPE_TARGET_TYPE (type); elttype = check_typedef (unresolved_elttype); if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0) { eltlen = TYPE_LENGTH (elttype); len = TYPE_LENGTH (type) / eltlen; if (options->prettyprint_arrays) { print_spaces_filtered (2 + 2 * recurse, stream); } /* Print arrays of textual chars with a string syntax. */ if (c_textual_element_type (unresolved_elttype, options->format)) { /* If requested, look for the first null char and only print elements up to it. */ if (options->stop_print_at_null) { unsigned int temp_len; for (temp_len = 0; (temp_len < len && temp_len < options->print_max && extract_unsigned_integer (valaddr + embedded_offset + temp_len * eltlen, eltlen, byte_order) != 0); ++temp_len) ; len = temp_len; } LA_PRINT_STRING (stream, unresolved_elttype, valaddr + embedded_offset, len, NULL, 0, options); i = len; } else { fprintf_filtered (stream, "{"); /* If this is a virtual function table, print the 0th entry specially, and the rest of the members normally. */ if (cp_is_vtbl_ptr_type (elttype)) { i = 1; fprintf_filtered (stream, _("%d vtable entries"), len - 1); } else { i = 0; } val_print_array_elements (type, valaddr + embedded_offset, address, stream, recurse, options, i); fprintf_filtered (stream, "}"); } break; } /* Array of unspecified length: treat like pointer to first elt. */ addr = address; goto print_unpacked_pointer; case TYPE_CODE_MEMBERPTR: if (options->format) { print_scalar_formatted (valaddr + embedded_offset, type, options, 0, stream); break; } cp_print_class_member (valaddr + embedded_offset, type, stream, "&"); break; case TYPE_CODE_METHODPTR: cplus_print_method_ptr (valaddr + embedded_offset, type, stream); break; case TYPE_CODE_PTR: if (options->format && options->format != 's') { print_scalar_formatted (valaddr + embedded_offset, type, options, 0, stream); break; } if (options->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.) */ CORE_ADDR addr = extract_typed_address (valaddr + embedded_offset, type); print_function_pointer_address (gdbarch, addr, stream, options->addressprint); break; } unresolved_elttype = TYPE_TARGET_TYPE (type); elttype = check_typedef (unresolved_elttype); { addr = unpack_pointer (type, valaddr + embedded_offset); print_unpacked_pointer: if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) { /* Try to print what function it points to. */ print_function_pointer_address (gdbarch, addr, stream, options->addressprint); /* Return value is irrelevant except for string pointers. */ return (0); } if (options->addressprint) fputs_filtered (paddress (gdbarch, addr), stream); /* 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) && addr != 0) { i = val_print_string (unresolved_elttype, addr, -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 minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (vt_address); if ((msymbol != NULL) && (vt_address == SYMBOL_VALUE_ADDRESS (msymbol))) { fputs_filtered (" <", stream); fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream); fputs_filtered (">", stream); } if (vt_address && options->vtblprint) { struct value *vt_val; struct symbol *wsym = (struct symbol *) NULL; struct type *wtype; struct block *block = (struct block *) NULL; int is_this_fld; if (msymbol != NULL) wsym = lookup_symbol (SYMBOL_LINKAGE_NAME (msymbol), block, VAR_DOMAIN, &is_this_fld); if (wsym) { wtype = SYMBOL_TYPE (wsym); } else { wtype = unresolved_elttype; } vt_val = value_at (wtype, vt_address); common_val_print (vt_val, stream, recurse + 1, options, current_language); if (options->pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); } } } /* Return number of characters printed, including the terminating '\0' if we reached the end. val_print_string takes care including the terminating '\0' if necessary. */ return i; } break; case TYPE_CODE_REF: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (options->addressprint) { CORE_ADDR addr = extract_typed_address (valaddr + embedded_offset, type); fprintf_filtered (stream, "@"); fputs_filtered (paddress (gdbarch, addr), stream); if (options->deref_ref) fputs_filtered (": ", stream); } /* De-reference the reference. */ if (options->deref_ref) { if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) { struct value *deref_val = value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr + embedded_offset)); common_val_print (deref_val, stream, recurse, options, current_language); } else fputs_filtered ("???", stream); } break; case TYPE_CODE_UNION: if (recurse && !options->unionprint) { fprintf_filtered (stream, "{...}"); break; } /* Fall through. */ case TYPE_CODE_STRUCT: /*FIXME: Abstract this away */ 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.) */ int offset = (embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8); struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET); CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type); print_function_pointer_address (gdbarch, addr, stream, options->addressprint); } else cp_print_value_fields_rtti (type, valaddr, embedded_offset, address, stream, recurse, options, NULL, 0); break; case TYPE_CODE_ENUM: if (options->format) { print_scalar_formatted (valaddr + embedded_offset, type, options, 0, stream); break; } len = TYPE_NFIELDS (type); val = unpack_long (type, valaddr + embedded_offset); for (i = 0; i < len; i++) { QUIT; if (val == TYPE_FIELD_BITPOS (type, i)) { break; } } if (i < len) { fputs_filtered (TYPE_FIELD_NAME (type, i), stream); } else { print_longest (stream, 'd', 0, val); } break; case TYPE_CODE_FLAGS: if (options->format) print_scalar_formatted (valaddr + embedded_offset, type, options, 0, stream); else val_print_type_code_flags (type, valaddr + embedded_offset, stream); break; case TYPE_CODE_FUNC: case TYPE_CODE_METHOD: if (options->format) { print_scalar_formatted (valaddr + embedded_offset, type, options, 0, stream); break; } /* FIXME, we should consider, at least for ANSI C language, eliminating the distinction made between FUNCs and POINTERs to FUNCs. */ fprintf_filtered (stream, "{"); type_print (type, "", stream, -1); fprintf_filtered (stream, "} "); /* Try to print what function it points to, and its address. */ print_address_demangle (gdbarch, address, stream, demangle); break; case TYPE_CODE_BOOL: if (options->format || options->output_format) { struct value_print_options opts = *options; opts.format = (options->format ? options->format : options->output_format); print_scalar_formatted (valaddr + embedded_offset, type, &opts, 0, stream); } else { val = unpack_long (type, valaddr + embedded_offset); if (val == 0) fputs_filtered ("false", stream); else if (val == 1) fputs_filtered ("true", stream); else print_longest (stream, 'd', 0, val); } break; case TYPE_CODE_RANGE: /* FIXME: create_range_type does not set the unsigned bit in a range type (I think it probably should copy it from the target type), so we won't print values which are too large to fit in a signed integer correctly. */ /* FIXME: Doesn't handle ranges of enums correctly. (Can't just print with the target type, though, because the size of our type and the target type might differ). */ /* FALLTHROUGH */ case TYPE_CODE_INT: if (options->format || options->output_format) { struct value_print_options opts = *options; opts.format = (options->format ? options->format : options->output_format); print_scalar_formatted (valaddr + embedded_offset, type, &opts, 0, stream); } else { val_print_type_code_int (type, valaddr + embedded_offset, stream); /* C and C++ has no single byte int type, char is used instead. Since we don't know whether the value is really intended to be used as an integer or a character, print the character equivalent as well. */ if (c_textual_element_type (unresolved_type, options->format)) { fputs_filtered (" ", stream); LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset), unresolved_type, stream); } } break; case TYPE_CODE_CHAR: if (options->format || options->output_format) { struct value_print_options opts = *options; opts.format = (options->format ? options->format : options->output_format); print_scalar_formatted (valaddr + embedded_offset, type, &opts, 0, stream); } else { val = unpack_long (type, valaddr + embedded_offset); if (TYPE_UNSIGNED (type)) fprintf_filtered (stream, "%u", (unsigned int) val); else fprintf_filtered (stream, "%d", (int) val); fputs_filtered (" ", stream); LA_PRINT_CHAR ((unsigned char) val, unresolved_type, stream); } break; case TYPE_CODE_FLT: if (options->format) { print_scalar_formatted (valaddr + embedded_offset, type, options, 0, stream); } else { print_floating (valaddr + embedded_offset, type, stream); } break; case TYPE_CODE_DECFLOAT: if (options->format) print_scalar_formatted (valaddr + embedded_offset, type, options, 0, stream); else print_decimal_floating (valaddr + embedded_offset, type, stream); break; case TYPE_CODE_VOID: fprintf_filtered (stream, "void"); break; case TYPE_CODE_ERROR: fprintf_filtered (stream, _("<error type>")); break; case TYPE_CODE_UNDEF: /* This happens (without TYPE_FLAG_STUB set) on systems which don't use dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" and no complete type for struct foo in that file. */ fprintf_filtered (stream, _("<incomplete type>")); break; case TYPE_CODE_COMPLEX: if (options->format) print_scalar_formatted (valaddr + embedded_offset, TYPE_TARGET_TYPE (type), options, 0, stream); else print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type), stream); fprintf_filtered (stream, " + "); if (options->format) print_scalar_formatted (valaddr + embedded_offset + TYPE_LENGTH (TYPE_TARGET_TYPE (type)), TYPE_TARGET_TYPE (type), options, 0, stream); else print_floating (valaddr + embedded_offset + TYPE_LENGTH (TYPE_TARGET_TYPE (type)), TYPE_TARGET_TYPE (type), stream); fprintf_filtered (stream, " * I"); break; default: error (_("Invalid C/C++ type code %d in symbol table."), TYPE_CODE (type)); } gdb_flush (stream); return (0); }
void m2_val_print (struct type *type, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *original_value, const struct value_print_options *options) { struct gdbarch *gdbarch = get_type_arch (type); unsigned len; struct type *elttype; CORE_ADDR addr; const gdb_byte *valaddr = value_contents_for_printing (original_value); type = check_typedef (type); switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) { elttype = check_typedef (TYPE_TARGET_TYPE (type)); len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype); if (options->prettyformat_arrays) print_spaces_filtered (2 + 2 * recurse, stream); /* For an array of chars, print with string syntax. */ if (TYPE_LENGTH (elttype) == 1 && ((TYPE_CODE (elttype) == TYPE_CODE_INT) || ((current_language->la_language == language_m2) && (TYPE_CODE (elttype) == TYPE_CODE_CHAR))) && (options->format == 0 || options->format == 's')) { /* If requested, look for the first null char and only print elements up to it. */ if (options->stop_print_at_null) { unsigned int temp_len; /* Look for a NULL char. */ for (temp_len = 0; (valaddr + embedded_offset)[temp_len] && temp_len < len && temp_len < options->print_max; temp_len++); len = temp_len; } LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type), valaddr + embedded_offset, len, NULL, 0, options); } else { fprintf_filtered (stream, "{"); val_print_array_elements (type, embedded_offset, address, stream, recurse, original_value, options, 0); fprintf_filtered (stream, "}"); } break; } /* Array of unspecified length: treat like pointer to first elt. */ print_unpacked_pointer (type, address, address, options, stream); break; case TYPE_CODE_PTR: if (TYPE_CONST (type)) print_variable_at_address (type, valaddr + embedded_offset, stream, recurse, options); else if (options->format && options->format != 's') val_print_scalar_formatted (type, embedded_offset, original_value, options, 0, stream); else { addr = unpack_pointer (type, valaddr + embedded_offset); print_unpacked_pointer (type, addr, address, options, stream); } break; case TYPE_CODE_UNION: if (recurse && !options->unionprint) { fprintf_filtered (stream, "{...}"); break; } /* Fall through. */ case TYPE_CODE_STRUCT: if (m2_is_long_set (type)) m2_print_long_set (type, valaddr, embedded_offset, address, stream); else if (m2_is_unbounded_array (type)) m2_print_unbounded_array (type, valaddr, embedded_offset, address, stream, recurse, options); else cp_print_value_fields (type, type, embedded_offset, address, stream, recurse, original_value, options, NULL, 0); break; case TYPE_CODE_SET: elttype = TYPE_INDEX_TYPE (type); elttype = check_typedef (elttype); if (TYPE_STUB (elttype)) { fprintf_filtered (stream, _("<incomplete type>")); gdb_flush (stream); break; } else { struct type *range = elttype; LONGEST low_bound, high_bound; int i; int need_comma = 0; fputs_filtered ("{", stream); i = get_discrete_bounds (range, &low_bound, &high_bound); maybe_bad_bstring: if (i < 0) { fputs_filtered (_("<error value>"), stream); goto done; } for (i = low_bound; i <= high_bound; i++) { int element = value_bit_index (type, valaddr + embedded_offset, i); if (element < 0) { i = element; goto maybe_bad_bstring; } if (element) { if (need_comma) fputs_filtered (", ", stream); print_type_scalar (range, i, stream); need_comma = 1; if (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i)) { int j = i; fputs_filtered ("..", stream); while (i + 1 <= high_bound && value_bit_index (type, valaddr + embedded_offset, ++i)) j = i; print_type_scalar (range, j, stream); } } } done: fputs_filtered ("}", stream); } break; case TYPE_CODE_RANGE: if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type))) { m2_val_print (TYPE_TARGET_TYPE (type), embedded_offset, address, stream, recurse, original_value, options); break; } /* FIXME: create_static_range_type does not set the unsigned bit in a range type (I think it probably should copy it from the target type), so we won't print values which are too large to fit in a signed integer correctly. */ /* FIXME: Doesn't handle ranges of enums correctly. (Can't just print with the target type, though, because the size of our type and the target type might differ). */ /* FALLTHROUGH */ case TYPE_CODE_REF: case TYPE_CODE_ENUM: case TYPE_CODE_FUNC: case TYPE_CODE_INT: case TYPE_CODE_FLT: case TYPE_CODE_METHOD: case TYPE_CODE_VOID: case TYPE_CODE_ERROR: case TYPE_CODE_UNDEF: case TYPE_CODE_BOOL: case TYPE_CODE_CHAR: default: generic_val_print (type, embedded_offset, address, stream, recurse, original_value, options, &m2_decorations); break; } gdb_flush (stream); }