/* Support for printing Ada values for GDB, the GNU debugger.
- Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1997, 2001, 2002,
- 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 1986, 1988-1989, 1991-1994, 1997, 2001-2012 Free
+ Software Foundation, Inc.
This file is part of GDB.
(i * bitsize) / HOST_CHAR_BIT,
(i * bitsize) % HOST_CHAR_BIT,
bitsize, elttype);
- if (memcmp (value_contents (v0), value_contents (v1), eltlen) != 0)
+ if (!value_available_contents_eq (v0, value_embedded_offset (v0),
+ v1, value_embedded_offset (v1),
+ eltlen))
break;
}
}
-/* Print data of type TYPE located at VALADDR (within GDB), which came from
- the inferior at address ADDRESS, onto stdio stream STREAM according to
- OPTIONS. The data at VALADDR is in target byte order.
-
- If the data is printed as a string, returns the number of string characters
- printed.
-
- RECURSE indicates the amount of indentation to supply before
- continuation lines; this amount is roughly twice the value of RECURSE. */
+/* See val_print for a description of the various parameters of this
+ function; they are identical. The semantics of the return value is
+ also identical to val_print. */
int
ada_val_print (struct type *type, const gdb_byte *valaddr,
}
/* Assuming TYPE is a simple array, print the value of this array located
- at VALADDR. See ada_val_print for a description of the various
+ at VALADDR + OFFSET. See ada_val_print for a description of the various
parameters of this function; they are identical. The semantics
of the return value is also identical to ada_val_print. */
const struct value *val,
const struct value_print_options *options)
{
- enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
- struct type *elttype = TYPE_TARGET_TYPE (type);
int result = 0;
/* For an array of chars, print with string syntax. */
if (ada_is_string_type (type)
&& (options->format == 0 || options->format == 's'))
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
+ struct type *elttype = TYPE_TARGET_TYPE (type);
unsigned int eltlen;
unsigned int len;
- if (elttype == NULL)
- eltlen = 0;
- else
- eltlen = TYPE_LENGTH (elttype);
- if (eltlen == 0)
- len = 0;
- else
- len = TYPE_LENGTH (type) / eltlen;
+ /* We know that ELTTYPE cannot possibly be null, because we found
+ that TYPE is a string-like type. Similarly, the size of ELTTYPE
+ should also be non-null, since it's a character-like type. */
+ gdb_assert (elttype != NULL);
+ gdb_assert (TYPE_LENGTH (elttype) != 0);
+
+ eltlen = TYPE_LENGTH (elttype);
+ len = TYPE_LENGTH (type) / eltlen;
if (options->prettyprint_arrays)
print_spaces_filtered (2 + 2 * recurse, stream);
type = ada_check_typedef (type);
if (ada_is_array_descriptor_type (type)
- || ada_is_constrained_packed_array_type (type))
+ || (ada_is_constrained_packed_array_type (type)
+ && TYPE_CODE (type) != TYPE_CODE_PTR))
{
int retn;
struct value *mark = value_mark ();
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
{
- CORE_ADDR deref_val_int
- = unpack_pointer (type, valaddr + offset_aligned);
+ CORE_ADDR deref_val_int;
+ struct value *deref_val;
+
+ deref_val = coerce_ref_if_computed (original_value);
+ if (deref_val)
+ {
+ common_val_print (deref_val, stream, recurse + 1, options,
+ current_language);
+ break;
+ }
+ deref_val_int = unpack_pointer (type, valaddr + offset_aligned);
if (deref_val_int != 0)
{
struct value *deref_val =
{
struct value *val = ada_to_fixed_value (val0);
CORE_ADDR address = value_address (val);
- struct type *type = value_type (val);
+ struct type *type = ada_check_typedef (value_type (val));
struct value_print_options opts;
/* If it is a pointer, indicate what it points to. */
fprintf_filtered (stream, ")");
}
-/* Print out fields of value at VALADDR having structure type TYPE.
+/* Print out fields of value at VALADDR + OFFSET having structure type TYPE.
- TYPE, VALADDR, STREAM, RECURSE, and OPTIONS have the
- same meanings as in ada_print_value and ada_val_print.
+ TYPE, VALADDR, OFFSET, STREAM, RECURSE, and OPTIONS have the same
+ meanings as in ada_print_value and ada_val_print.
- OUTER_TYPE and OUTER_VALADDR give type and address of enclosing record
- (used to get discriminant values when printing variant parts).
+ OUTER_TYPE and OUTER_OFFSET give type and address of enclosing
+ record (used to get discriminant values when printing variant
+ parts).
COMMA_NEEDED is 1 if fields have been printed at the current recursion
level, so that a comma is needed before any field printed by this