+ fputs_styled (name, variable_name_style.style (), stream);
+ }
+ else
+ print_longest (stream, 'd', 0, val);
+}
+
+/* Implement Ada val_print'ing for the case where the type is
+ TYPE_CODE_STRUCT or TYPE_CODE_UNION. */
+
+static void
+ada_val_print_struct_union (struct value *value,
+ struct ui_file *stream,
+ int recurse,
+ const struct value_print_options *options)
+{
+ if (ada_is_bogus_array_descriptor (value_type (value)))
+ {
+ fprintf_filtered (stream, "(...?)");
+ return;
+ }
+
+ fprintf_filtered (stream, "(");
+
+ if (print_field_values (value, value, stream, recurse, options,
+ 0, language_def (language_ada)) != 0
+ && options->prettyformat)
+ {
+ fprintf_filtered (stream, "\n");
+ print_spaces_filtered (2 * recurse, stream);
+ }
+
+ fprintf_filtered (stream, ")");
+}
+
+/* Implement Ada value_print'ing for the case where TYPE is a
+ TYPE_CODE_ARRAY. */
+
+static void
+ada_value_print_array (struct value *val, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
+{
+ struct type *type = ada_check_typedef (value_type (val));
+
+ /* For an array of characters, print with string syntax. */
+ if (ada_is_string_type (type)
+ && (options->format == 0 || options->format == 's'))
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+ int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
+
+ ada_val_print_string (type, valaddr, offset_aligned, stream, recurse,
+ options);
+ return;
+ }
+
+ fprintf_filtered (stream, "(");
+ print_optional_low_bound (stream, type, options);
+ if (TYPE_FIELD_BITSIZE (type, 0) > 0)
+ {
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+ int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
+ val_print_packed_array_elements (type, valaddr, offset_aligned,
+ stream, recurse, options);
+ }
+ else
+ value_print_array_elements (val, stream, recurse, options, 0);
+ fprintf_filtered (stream, ")");
+}
+
+/* Implement Ada val_print'ing for the case where TYPE is
+ a TYPE_CODE_REF. */
+
+static void
+ada_val_print_ref (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 references, the debugger is expected to print the value as
+ an address if DEREF_REF is null. But printing an address in place
+ of the object value would be confusing to an Ada programmer.
+ So, for Ada values, we print the actual dereferenced value
+ regardless. */
+ struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
+ struct value *deref_val;
+ CORE_ADDR deref_val_int;
+
+ if (elttype->code () == TYPE_CODE_UNDEF)
+ {
+ fputs_styled ("<ref to undefined type>", metadata_style.style (),
+ stream);
+ return;
+ }
+
+ deref_val = coerce_ref_if_computed (original_value);
+ if (deref_val)
+ {
+ if (ada_is_tagged_type (value_type (deref_val), 1))
+ deref_val = ada_tag_value_at_base_address (deref_val);
+
+ common_val_print (deref_val, stream, recurse + 1, options,
+ language_def (language_ada));
+ return;
+ }
+
+ deref_val_int = unpack_pointer (type, valaddr + offset_aligned);
+ if (deref_val_int == 0)
+ {
+ fputs_filtered ("(null)", stream);
+ return;
+ }
+
+ deref_val
+ = ada_value_ind (value_from_pointer (lookup_pointer_type (elttype),
+ deref_val_int));
+ if (ada_is_tagged_type (value_type (deref_val), 1))
+ deref_val = ada_tag_value_at_base_address (deref_val);
+
+ /* Make sure that the object does not have an unreasonable size
+ before trying to print it. This can happen for instance with
+ references to dynamic objects whose contents is uninitialized
+ (Eg: an array whose bounds are not set yet). */
+ ada_ensure_varsize_limit (value_type (deref_val));
+
+ if (value_lazy (deref_val))
+ value_fetch_lazy (deref_val);
+
+ common_val_print (deref_val, stream, recurse + 1,
+ options, language_def (language_ada));
+}
+
+/* See the comment on ada_value_print. This function differs in that
+ it does not catch evaluation errors (leaving that to
+ ada_value_print). */
+
+static void
+ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
+{
+ struct type *type = ada_check_typedef (value_type (val));
+
+ if (ada_is_array_descriptor_type (type)
+ || (ada_is_constrained_packed_array_type (type)
+ && type->code () != TYPE_CODE_PTR))
+ {
+ ada_val_print_gnat_array (val, stream, recurse, options);
+ return;
+ }
+
+ val = ada_to_fixed_value (val);
+ type = value_type (val);
+ struct type *saved_type = type;
+
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+ CORE_ADDR address = value_address (val);
+ gdb::array_view<const gdb_byte> view
+ = gdb::make_array_view (valaddr, TYPE_LENGTH (type));
+ type = ada_check_typedef (resolve_dynamic_type (type, view, address));
+ if (type != saved_type)
+ {
+ val = value_copy (val);
+ deprecated_set_value_type (val, type);
+ }
+
+ switch (type->code ())
+ {
+ default:
+ common_val_print (val, stream, recurse, options,
+ language_def (language_c));