* dwarf2read.c (struct attribute): Increase sizes of unsnd and snd

fields to allow larger integer sizes.
(read_subrange_type): Increase size of bound values.
Add logic to determine signedness based on base-type size, signedness.
(read_attribute_value): Change format for bad byte size in message.
(read_8_bytes): Increase size of result type.
(dump_die_shallow): Change format for value.
(dwarf2_get_attr_constant_value): Increase size of return type.
Correct comment.
* gdbtypes.c (create_range_type): Change API to increase size of
bounds. struct field -> union field.
Always take signedness from base type.
(check_typedef): Use new API for TYPE_LOW_BOUND, TYPE_HIGH_BOUND.
(recursive_dump_type, copy_type_recursive): Adjust to new
representation of range types.
* gdbtypes.h (fields_or_bounds): New union containing struct field and
new struct range_bounds, used for range types.
(TYPE_RANGE_DATA): New macro to access range_bounds member.
(TYPE_LOW_BOUND, TYPE_HIGH_BOUND): Represent with new TYPE_RANGE_DATA.
(TYPE_LOW_BOUND_UNDEFINED, TYPE_HIGH_BOUND_UNDEFINED): New macros,
taking over the job of TYPE_FIELD_ARTIFICIAL for range bounds.
(SET_TYPE_LOW_BOUND, SET_TYPE_HIGH_BOUND, SET_TYPE_LOW_BOUND_DEFINED)
(SET_TYPE_HIGH_BOUND_DEFINED): New macros.
(TYPE_FIELDS, TYPE_BASECLASS, TYPE_BASECLASS_NAME, TYPE_FIELD)
(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED)
(TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED, TYPE_ARRAY_UPPER_BOUND_VALUE)
(TYPE_ARRAY_LOWER_BOUND_VALUE):	Adjust to new representation.
(create_range_type): Adjust API.
* ada-lang.c (ada_modulus): Use new extended bound values.
(discrete_type_low_bound): Rename to...
(ada_discrete_type_low_bound): ... and make external.
(discrete_type_high_bound): Rename to...
(ada_discrete_type_high_bound): ... and make external.
(ada_value_slice_from_ptr, ada_array_bound_from_type)
(ada_evaluate_subexp, to_fixed_range_type):
Use ada_discrete_type_low_bound, ada_discrete_type_high_bound.
* ada-typeprint.c (print_range): Use ada_discrete_type_low_bound,
ada_discrete_type_high_bound.  Don't look at field count, which
is no longer meaningful.  Print bounds whenever argument is a range
or enumeration.
* ada-lang.h (ada_discrete_type_low_bound,ada_discrete_type_high_bound):
Declare.
* varobj.c (c_describe_child): Adjust to render larger values.
* mdebugread.c (parse_type): Use proper abstractions for range types:
TYPE_RANGE_DATA, SET_TYPE_LOW_BOUND_DEFINED,
SET_TYPE_HIGH_BOUND_DEFINED.
* p-typeprint.c (pascal_type_print_varspec_prefix): Use larger format
for bounds.
This commit is contained in:
Paul N. Hilfinger
2009-12-14 06:19:13 +00:00
parent d48d911fbf
commit 43bbcdc2bc
10 changed files with 246 additions and 168 deletions

View File

@@ -711,7 +711,7 @@ allocate_stub_method (struct type *type)
struct type *
create_range_type (struct type *result_type, struct type *index_type,
int low_bound, int high_bound)
LONGEST low_bound, LONGEST high_bound)
{
if (result_type == NULL)
result_type = alloc_type_copy (index_type);
@@ -721,10 +721,8 @@ create_range_type (struct type *result_type, struct type *index_type,
TYPE_TARGET_STUB (result_type) = 1;
else
TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
TYPE_NFIELDS (result_type) = 2;
TYPE_FIELDS (result_type) = TYPE_ZALLOC (result_type,
TYPE_NFIELDS (result_type)
* sizeof (struct field));
TYPE_RANGE_DATA (result_type) = (struct range_bounds *)
TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
TYPE_LOW_BOUND (result_type) = low_bound;
TYPE_HIGH_BOUND (result_type) = high_bound;
@@ -1475,17 +1473,34 @@ check_typedef (struct type *type)
/* Now recompute the length of the array type, based on its
number of elements and the target type's length.
Watch out for Ada null Ada arrays where the high bound
is smaller than the low bound. */
const int low_bound = TYPE_LOW_BOUND (range_type);
const int high_bound = TYPE_HIGH_BOUND (range_type);
int nb_elements;
is smaller than the low bound. */
const LONGEST low_bound = TYPE_LOW_BOUND (range_type);
const LONGEST high_bound = TYPE_HIGH_BOUND (range_type);
ULONGEST len;
if (high_bound < low_bound)
nb_elements = 0;
else
nb_elements = high_bound - low_bound + 1;
TYPE_LENGTH (type) = nb_elements * TYPE_LENGTH (target_type);
len = 0;
else {
/* For now, we conservatively take the array length to be 0
if its length exceeds UINT_MAX. The code below assumes
that for x < 0, (ULONGEST) x == -x + ULONGEST_MAX + 1,
which is technically not guaranteed by C, but is usually true
(because it would be true if x were unsigned with its
high-order bit on). It uses the fact that
high_bound-low_bound is always representable in
ULONGEST and that if high_bound-low_bound+1 overflows,
it overflows to 0. We must change these tests if we
decide to increase the representation of TYPE_LENGTH
from unsigned int to ULONGEST. */
ULONGEST ulow = low_bound, uhigh = high_bound;
ULONGEST tlen = TYPE_LENGTH (target_type);
len = tlen * (uhigh - ulow + 1);
if (tlen == 0 || (len / tlen - 1 + ulow) != uhigh
|| len > UINT_MAX)
len = 0;
}
TYPE_LENGTH (type) = len;
TYPE_TARGET_STUB (type) = 0;
}
else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
@@ -2737,6 +2752,14 @@ recursive_dump_type (struct type *type, int spaces)
recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
}
}
if (TYPE_CODE (type) == TYPE_CODE_RANGE)
{
printfi_filtered (spaces, "low %s%s high %s%s\n",
plongest (TYPE_LOW_BOUND (type)),
TYPE_LOW_BOUND_UNDEFINED (type) ? " (undefined)" : "",
plongest (TYPE_HIGH_BOUND (type)),
TYPE_HIGH_BOUND_UNDEFINED (type) ? " (undefined)" : "");
}
printfi_filtered (spaces, "vptr_basetype ");
gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
puts_filtered ("\n");
@@ -2925,6 +2948,13 @@ copy_type_recursive (struct objfile *objfile,
}
}
/* For range types, copy the bounds information. */
if (TYPE_CODE (type) == TYPE_CODE_RANGE)
{
TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
*TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
}
/* Copy pointers to other types. */
if (TYPE_TARGET_TYPE (type))
TYPE_TARGET_TYPE (new_type) =