/* Support for printing Ada values for GDB, the GNU debugger.
- Copyright (C) 1986-2014 Free Software Foundation, Inc.
+ Copyright (C) 1986-2015 Free Software Foundation, Inc.
This file is part of GDB.
#include "defs.h"
#include <ctype.h>
-#include <string.h>
#include "symtab.h"
#include "gdbtypes.h"
#include "expression.h"
#include "ada-lang.h"
#include "c-lang.h"
#include "infcall.h"
-#include "exceptions.h"
#include "objfiles.h"
static int print_field_values (struct type *, const gdb_byte *,
struct ui_file *, int,
const struct value *,
const struct value_print_options *,
- int, struct type *, int);
+ int, struct type *, int,
+ const struct language_defn *);
\f
/* Make TYPE unsigned if its range of values includes no negatives. */
index_type = TYPE_INDEX_TYPE (type);
- if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
+ while (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
{
/* We need to know what the base type is, in order to do the
appropriate check below. Otherwise, if this is a subrange
unsigned int things_printed = 0;
unsigned len;
struct type *elttype, *index_type;
- unsigned eltlen;
unsigned long bitsize = TYPE_FIELD_BITSIZE (type, 0);
struct value *mark = value_mark ();
LONGEST low = 0;
elttype = TYPE_TARGET_TYPE (type);
- eltlen = TYPE_LENGTH (check_typedef (elttype));
index_type = TYPE_INDEX_TYPE (type);
{
(i * bitsize) / HOST_CHAR_BIT,
(i * bitsize) % HOST_CHAR_BIT,
bitsize, elttype);
- if (!value_available_contents_eq (v0, value_embedded_offset (v0),
- v1, value_embedded_offset (v1),
- eltlen))
+ if (TYPE_LENGTH (check_typedef (value_type (v0)))
+ != TYPE_LENGTH (check_typedef (value_type (v1))))
+ break;
+ if (!value_contents_eq (v0, value_embedded_offset (v0),
+ v1, value_embedded_offset (v1),
+ TYPE_LENGTH (check_typedef (value_type (v0)))))
break;
}
const struct value *val,
const struct value_print_options *options,
int comma_needed,
- struct type *outer_type, int outer_offset)
+ struct type *outer_type, int outer_offset,
+ const struct language_defn *language)
{
struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
int which = ada_which_variant_applies (var_type, outer_type,
offset + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
+ TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
stream, recurse, val, options,
- comma_needed, outer_type, outer_offset);
+ comma_needed, outer_type, outer_offset, language);
}
/* Print out fields of value at VALADDR + OFFSET having structure type TYPE.
const struct value *val,
const struct value_print_options *options,
int comma_needed,
- struct type *outer_type, int outer_offset)
+ struct type *outer_type, int outer_offset,
+ const struct language_defn *language)
{
int i, len;
(offset
+ TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT),
stream, recurse, val, options,
- comma_needed, type, offset);
+ comma_needed, type, offset, language);
continue;
}
else if (ada_is_variant_part (type, i))
print_variant_part (type, i, valaddr,
offset, stream, recurse, val,
options, comma_needed,
- outer_type, outer_offset);
+ outer_type, outer_offset, language);
continue;
}
value_contents_for_printing (v),
value_embedded_offset (v), 0,
stream, recurse + 1, v,
- &opts, current_language);
+ &opts, language);
}
}
else
struct value_print_options opts = *options;
opts.deref_ref = 0;
- ada_val_print (TYPE_FIELD_TYPE (type, i),
- valaddr,
- (offset
- + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT),
- 0, stream, recurse + 1, val, &opts);
+ val_print (TYPE_FIELD_TYPE (type, i), valaddr,
+ (offset + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT),
+ 0, stream, recurse + 1, val, &opts, language);
}
annotate_field_end ();
}
if (print_field_values (type, valaddr, offset_aligned,
stream, recurse, original_value, options,
- 0, type, offset_aligned) != 0
+ 0, type, offset_aligned, language) != 0
&& options->prettyformat)
{
fprintf_filtered (stream, "\n");
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));
+
val_print (value_type (deref_val),
value_contents_for_printing (deref_val),
value_embedded_offset (deref_val),
offset_aligned = offset + ada_aligned_value_addr (type, valaddr) - valaddr;
type = printable_val_type (type, valaddr + offset_aligned);
+ type = resolve_dynamic_type (type, valaddr + offset_aligned,
+ address + offset_aligned);
switch (TYPE_CODE (type))
{
const struct value *val,
const struct value_print_options *options)
{
- volatile struct gdb_exception except;
/* XXX: this catches QUIT/ctrl-c as well. Isn't that busted? */
- TRY_CATCH (except, RETURN_MASK_ALL)
+ TRY
{
ada_val_print_1 (type, valaddr, embedded_offset, address,
stream, recurse, val, options,
current_language);
}
+ CATCH (except, RETURN_MASK_ALL)
+ {
+ }
+ END_CATCH
}
void
{
struct value *val = ada_to_fixed_value (val0);
CORE_ADDR address = value_address (val);
- struct type *type = ada_check_typedef (value_type (val));
+ struct type *type = ada_check_typedef (value_enclosing_type (val));
struct value_print_options opts;
/* If it is a pointer, indicate what it points to. */