- fprintf_filtered (stream, " (%s)", name);
- }
-}
-
-/* Implement Ada val_print'ing for the case where TYPE is
- a TYPE_CODE_INT or TYPE_CODE_RANGE. */
-
-static void
-ada_val_print_num (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)
-{
- if (ada_is_fixed_point_type (type))
- {
- struct value *scale = ada_scaling_factor (type);
- struct value *v = value_from_contents (type, valaddr + offset_aligned);
- v = value_cast (value_type (scale), v);
- v = value_binop (v, scale, BINOP_MUL);
-
- const char *fmt = TYPE_LENGTH (type) < 4 ? "%.11g" : "%.17g";
- std::string str
- = target_float_to_string (value_contents (v), value_type (v), fmt);
- fputs_filtered (str.c_str (), stream);
- return;
- }
- else if (TYPE_CODE (type) == TYPE_CODE_RANGE
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ENUM
- || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_BOOL
- || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CHAR))
- {
- /* For enum-valued ranges, we want to recurse, because we'll end
- up printing the constant's name rather than its numeric
- value. Character and fixed-point types are also printed
- differently, so recuse for those as well. */
- 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 *v1
- = value_from_contents_and_address (type, valaddr + offset, 0);
- struct value *v = value_cast (target_type, v1);
-
- val_print (target_type,
- value_embedded_offset (v), 0, stream,
- recurse + 1, v, options,
- language_def (language_ada));
- }
- else
- val_print (TYPE_TARGET_TYPE (type), offset,
- address, stream, recurse, original_value,
- options, language_def (language_ada));
- return;
- }
- else
- {
- int format = (options->format ? options->format
- : options->output_format);
-
- if (format)
- {
- struct value_print_options opts = *options;
-
- opts.format = format;
- val_print_scalar_formatted (type, offset_aligned,
- original_value, &opts, 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. */
-
- struct gdbarch *gdbarch = get_type_arch (type);
- struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
- CORE_ADDR addr = extract_typed_address (valaddr + offset_aligned,
- ptr_type);
-
- fprintf_filtered (stream, "(");
- type_print (type, "", stream, -1);
- fprintf_filtered (stream, ") ");
- fputs_filtered (paddress (gdbarch, addr), stream);
- }
- else
- {
- val_print_scalar_formatted (type, offset_aligned,
- original_value, options, 0, stream);
- if (ada_is_character_type (type))
- {
- LONGEST c;
-
- fputs_filtered (" ", stream);
- c = unpack_long (type, valaddr + offset_aligned);
- ada_printchar (c, type, stream);
- }
- }
- return;