* 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:
parent
d48d911fbf
commit
43bbcdc2bc
@ -1,3 +1,54 @@
|
||||
2009-12-13 Paul N. Hilfinger <hilfinger@adacore.com>
|
||||
|
||||
* 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.
|
||||
|
||||
2009-12-11 Michael Snyder <msnyder@vmware.com>
|
||||
|
||||
* main.c (captured_main): Indentation.
|
||||
|
@ -597,8 +597,8 @@ min_of_type (struct type *t)
|
||||
}
|
||||
|
||||
/* The largest value in the domain of TYPE, a discrete type, as an integer. */
|
||||
static LONGEST
|
||||
discrete_type_high_bound (struct type *type)
|
||||
LONGEST
|
||||
ada_discrete_type_high_bound (struct type *type)
|
||||
{
|
||||
switch (TYPE_CODE (type))
|
||||
{
|
||||
@ -612,13 +612,13 @@ discrete_type_high_bound (struct type *type)
|
||||
case TYPE_CODE_INT:
|
||||
return max_of_type (type);
|
||||
default:
|
||||
error (_("Unexpected type in discrete_type_high_bound."));
|
||||
error (_("Unexpected type in ada_discrete_type_high_bound."));
|
||||
}
|
||||
}
|
||||
|
||||
/* The largest value in the domain of TYPE, a discrete type, as an integer. */
|
||||
static LONGEST
|
||||
discrete_type_low_bound (struct type *type)
|
||||
LONGEST
|
||||
ada_discrete_type_low_bound (struct type *type)
|
||||
{
|
||||
switch (TYPE_CODE (type))
|
||||
{
|
||||
@ -632,7 +632,7 @@ discrete_type_low_bound (struct type *type)
|
||||
case TYPE_CODE_INT:
|
||||
return min_of_type (type);
|
||||
default:
|
||||
error (_("Unexpected type in discrete_type_low_bound."));
|
||||
error (_("Unexpected type in ada_discrete_type_low_bound."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2399,7 +2399,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
|
||||
int low, int high)
|
||||
{
|
||||
CORE_ADDR base = value_as_address (array_ptr)
|
||||
+ ((low - TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)))
|
||||
+ ((low - ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type)))
|
||||
* TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
|
||||
struct type *index_type =
|
||||
create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type)),
|
||||
@ -2542,7 +2542,6 @@ static LONGEST
|
||||
ada_array_bound_from_type (struct type * arr_type, int n, int which)
|
||||
{
|
||||
struct type *type, *elt_type, *index_type_desc, *index_type;
|
||||
LONGEST retval;
|
||||
int i;
|
||||
|
||||
gdb_assert (which == 0 || which == 1);
|
||||
@ -2569,22 +2568,10 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which)
|
||||
else
|
||||
index_type = TYPE_INDEX_TYPE (elt_type);
|
||||
|
||||
switch (TYPE_CODE (index_type))
|
||||
{
|
||||
case TYPE_CODE_RANGE:
|
||||
retval = which == 0 ? TYPE_LOW_BOUND (index_type)
|
||||
: TYPE_HIGH_BOUND (index_type);
|
||||
break;
|
||||
case TYPE_CODE_ENUM:
|
||||
retval = which == 0 ? TYPE_FIELD_BITPOS (index_type, 0)
|
||||
: TYPE_FIELD_BITPOS (index_type,
|
||||
TYPE_NFIELDS (index_type) - 1);
|
||||
break;
|
||||
default:
|
||||
internal_error (__FILE__, __LINE__, _("invalid type code of index type"));
|
||||
}
|
||||
|
||||
return retval;
|
||||
return
|
||||
(LONGEST) (which == 0
|
||||
? ada_discrete_type_low_bound (index_type)
|
||||
: ada_discrete_type_high_bound (index_type));
|
||||
}
|
||||
|
||||
/* Given that arr is an array value, returns the lower bound of the
|
||||
@ -9262,10 +9249,10 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
|
||||
error (_("unexpected attribute encountered"));
|
||||
case OP_ATR_FIRST:
|
||||
return value_from_longest
|
||||
(range_type, discrete_type_low_bound (range_type));
|
||||
(range_type, ada_discrete_type_low_bound (range_type));
|
||||
case OP_ATR_LAST:
|
||||
return value_from_longest
|
||||
(range_type, discrete_type_high_bound (range_type));
|
||||
(range_type, ada_discrete_type_high_bound (range_type));
|
||||
case OP_ATR_LENGTH:
|
||||
error (_("the 'length attribute applies only to array types"));
|
||||
}
|
||||
@ -9839,14 +9826,14 @@ to_fixed_range_type (char *name, struct value *dval, struct type *orig_type)
|
||||
subtype_info = strstr (name, "___XD");
|
||||
if (subtype_info == NULL)
|
||||
{
|
||||
LONGEST L = discrete_type_low_bound (raw_type);
|
||||
LONGEST U = discrete_type_high_bound (raw_type);
|
||||
LONGEST L = ada_discrete_type_low_bound (raw_type);
|
||||
LONGEST U = ada_discrete_type_high_bound (raw_type);
|
||||
if (L < INT_MIN || U > INT_MAX)
|
||||
return raw_type;
|
||||
else
|
||||
return create_range_type (alloc_type_copy (orig_type), raw_type,
|
||||
discrete_type_low_bound (raw_type),
|
||||
discrete_type_high_bound (raw_type));
|
||||
ada_discrete_type_low_bound (raw_type),
|
||||
ada_discrete_type_high_bound (raw_type));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -9972,20 +9959,7 @@ ada_modulus_from_name (struct type *type, ULONGEST *modulus)
|
||||
ULONGEST
|
||||
ada_modulus (struct type *type)
|
||||
{
|
||||
ULONGEST modulus;
|
||||
|
||||
/* Normally, the modulus of a modular type is equal to the value of
|
||||
its upper bound + 1. However, the upper bound is currently stored
|
||||
as an int, which is not always big enough to hold the actual bound
|
||||
value. To workaround this, try to take advantage of the encoding
|
||||
that GNAT uses with with discrete types. To avoid some unnecessary
|
||||
parsing, we do this only when the size of TYPE is greater than
|
||||
the size of the field holding the bound. */
|
||||
if (TYPE_LENGTH (type) > sizeof (TYPE_HIGH_BOUND (type))
|
||||
&& ada_modulus_from_name (type, &modulus))
|
||||
return modulus;
|
||||
|
||||
return (ULONGEST) (unsigned int) TYPE_HIGH_BOUND (type) + 1;
|
||||
return (ULONGEST) TYPE_HIGH_BOUND (type) + 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,6 +199,10 @@ extern int ada_is_array_descriptor_type (struct type *);
|
||||
|
||||
extern int ada_is_bogus_array_descriptor (struct type *);
|
||||
|
||||
extern LONGEST ada_discrete_type_low_bound (struct type *);
|
||||
|
||||
extern LONGEST ada_discrete_type_high_bound (struct type *);
|
||||
|
||||
extern char *ada_decode_symbol (const struct general_symbol_info*);
|
||||
|
||||
extern const char *ada_decode (const char*);
|
||||
|
@ -114,53 +114,32 @@ decoded_type_name (struct type *type)
|
||||
}
|
||||
}
|
||||
|
||||
/* Print range type TYPE on STREAM. */
|
||||
/* Print TYPE on STREAM, preferably as a range. */
|
||||
|
||||
static void
|
||||
print_range (struct type *type, struct ui_file *stream)
|
||||
{
|
||||
switch (TYPE_CODE (type))
|
||||
{
|
||||
case TYPE_CODE_RANGE:
|
||||
case TYPE_CODE_ENUM:
|
||||
{
|
||||
struct type *target_type;
|
||||
target_type = TYPE_TARGET_TYPE (type);
|
||||
if (target_type == NULL)
|
||||
target_type = type;
|
||||
|
||||
switch (TYPE_CODE (target_type))
|
||||
{
|
||||
case TYPE_CODE_RANGE:
|
||||
case TYPE_CODE_INT:
|
||||
case TYPE_CODE_BOOL:
|
||||
case TYPE_CODE_CHAR:
|
||||
case TYPE_CODE_ENUM:
|
||||
ada_print_scalar (target_type, ada_discrete_type_low_bound (type),
|
||||
stream);
|
||||
fprintf_filtered (stream, " .. ");
|
||||
ada_print_scalar (target_type, ada_discrete_type_high_bound (type),
|
||||
stream);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
target_type = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (TYPE_NFIELDS (type) < 2)
|
||||
{
|
||||
/* A range needs at least 2 bounds to be printed. If there are less
|
||||
than 2, just print the type name instead of the range itself.
|
||||
This check handles cases such as characters, for example.
|
||||
|
||||
If the name is not defined, then we don't print anything.
|
||||
*/
|
||||
fprintf_filtered (stream, "%.*s",
|
||||
ada_name_prefix_len (TYPE_NAME (type)),
|
||||
TYPE_NAME (type));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We extract the range type bounds respectively from the first element
|
||||
and the last element of the type->fields array */
|
||||
const LONGEST lower_bound = (LONGEST) TYPE_LOW_BOUND (type);
|
||||
const LONGEST upper_bound = (TYPE_CODE (type) == TYPE_CODE_RANGE
|
||||
? (LONGEST) TYPE_HIGH_BOUND (type)
|
||||
: (LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1));
|
||||
|
||||
ada_print_scalar (target_type, lower_bound, stream);
|
||||
fprintf_filtered (stream, " .. ");
|
||||
ada_print_scalar (target_type, upper_bound, stream);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -549,8 +549,8 @@ struct attribute
|
||||
{
|
||||
char *str;
|
||||
struct dwarf_block *blk;
|
||||
unsigned long unsnd;
|
||||
long int snd;
|
||||
ULONGEST unsnd;
|
||||
LONGEST snd;
|
||||
CORE_ADDR addr;
|
||||
struct signatured_type *signatured_type;
|
||||
}
|
||||
@ -1065,7 +1065,7 @@ static int is_ref_attr (struct attribute *);
|
||||
|
||||
static unsigned int dwarf2_get_ref_die_offset (struct attribute *);
|
||||
|
||||
static int dwarf2_get_attr_constant_value (struct attribute *, int);
|
||||
static LONGEST dwarf2_get_attr_constant_value (struct attribute *, int);
|
||||
|
||||
static struct die_info *follow_die_ref_or_sig (struct die_info *,
|
||||
struct attribute *,
|
||||
@ -6041,9 +6041,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
struct type *base_type;
|
||||
struct type *range_type;
|
||||
struct attribute *attr;
|
||||
int low = 0;
|
||||
int high = -1;
|
||||
LONGEST low = 0;
|
||||
LONGEST high = -1;
|
||||
char *name;
|
||||
LONGEST negative_mask;
|
||||
|
||||
base_type = die_type (die, cu);
|
||||
if (TYPE_CODE (base_type) == TYPE_CODE_VOID)
|
||||
@ -6090,6 +6091,13 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||
high = dwarf2_get_attr_constant_value (attr, 1);
|
||||
}
|
||||
|
||||
negative_mask =
|
||||
(LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
|
||||
if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
|
||||
low |= negative_mask;
|
||||
if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
|
||||
high |= negative_mask;
|
||||
|
||||
range_type = create_range_type (NULL, base_type, low, high);
|
||||
|
||||
name = dwarf2_name (die, cu);
|
||||
@ -7127,8 +7135,8 @@ read_attribute_value (struct attribute *attr, unsigned form,
|
||||
{
|
||||
complaint
|
||||
(&symfile_complaints,
|
||||
_("Suspicious DW_AT_byte_size value treated as zero instead of 0x%lx"),
|
||||
DW_UNSND (attr));
|
||||
_("Suspicious DW_AT_byte_size value treated as zero instead of %s"),
|
||||
hex_string (DW_UNSND (attr)));
|
||||
DW_UNSND (attr) = 0;
|
||||
}
|
||||
|
||||
@ -10107,7 +10115,8 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
|
||||
case DW_FORM_data8:
|
||||
case DW_FORM_udata:
|
||||
case DW_FORM_sdata:
|
||||
fprintf_unfiltered (f, "constant: %ld", DW_UNSND (&die->attrs[i]));
|
||||
fprintf_unfiltered (f, "constant: %s",
|
||||
pulongest (DW_UNSND (&die->attrs[i])));
|
||||
break;
|
||||
case DW_FORM_sig8:
|
||||
if (DW_SIGNATURED_TYPE (&die->attrs[i]) != NULL)
|
||||
@ -10230,10 +10239,10 @@ dwarf2_get_ref_die_offset (struct attribute *attr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the constant value held by the given attribute. Return -1
|
||||
if the value held by the attribute is not constant. */
|
||||
/* Return the constant value held by ATTR. Return DEFAULT_VALUE if
|
||||
* the value held by the attribute is not constant. */
|
||||
|
||||
static int
|
||||
static LONGEST
|
||||
dwarf2_get_attr_constant_value (struct attribute *attr, int default_value)
|
||||
{
|
||||
if (attr->form == DW_FORM_sdata)
|
||||
|
@ -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;
|
||||
|
||||
@ -1476,16 +1474,33 @@ check_typedef (struct type *type)
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
|
||||
TYPE_LENGTH (type) = nb_elements * 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) =
|
||||
|
@ -447,6 +447,8 @@ struct main_type
|
||||
because we can allocate the space for a type before
|
||||
we know what to put in it. */
|
||||
|
||||
union
|
||||
{
|
||||
struct field
|
||||
{
|
||||
union field_location
|
||||
@ -484,6 +486,8 @@ struct main_type
|
||||
ENUM_BITFIELD(field_loc_kind) loc_kind : 2;
|
||||
|
||||
/* Size of this field, in bits, or zero if not packed.
|
||||
If non-zero in an array type, indicates the element size in
|
||||
bits (used only in Ada at the moment).
|
||||
For an unpacked field, the field's type's length
|
||||
says how many bytes the field occupies. */
|
||||
|
||||
@ -500,9 +504,31 @@ struct main_type
|
||||
arguments. */
|
||||
|
||||
char *name;
|
||||
|
||||
} *fields;
|
||||
|
||||
/* Union member used for range types. */
|
||||
|
||||
struct range_bounds
|
||||
{
|
||||
/* Low bound of range. */
|
||||
|
||||
LONGEST low;
|
||||
|
||||
/* High bound of range. */
|
||||
|
||||
LONGEST high;
|
||||
|
||||
/* Flags indicating whether the values of low and high are
|
||||
valid. When true, the respective range value is
|
||||
undefined. Currently used only for FORTRAN arrays. */
|
||||
|
||||
char low_undefined;
|
||||
char high_undefined;
|
||||
|
||||
} *bounds;
|
||||
|
||||
} flds_bnds;
|
||||
|
||||
/* For types with virtual functions (TYPE_CODE_STRUCT), VPTR_BASETYPE
|
||||
is the base class which defined the virtual function table pointer.
|
||||
|
||||
@ -828,19 +854,24 @@ extern void allocate_cplus_struct_type (struct type *);
|
||||
type, you need to do TYPE_CODE (check_type (this_type)). */
|
||||
#define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code
|
||||
#define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
|
||||
#define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->fields
|
||||
#define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields
|
||||
#define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args
|
||||
|
||||
#define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
|
||||
#define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0)
|
||||
#define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1)
|
||||
#define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
|
||||
#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low
|
||||
#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high
|
||||
#define TYPE_LOW_BOUND_UNDEFINED(range_type) \
|
||||
TYPE_RANGE_DATA(range_type)->low_undefined
|
||||
#define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
|
||||
TYPE_RANGE_DATA(range_type)->high_undefined
|
||||
|
||||
/* Moto-specific stuff for FORTRAN arrays */
|
||||
|
||||
#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
|
||||
(TYPE_FIELD_ARTIFICIAL(TYPE_INDEX_TYPE((arraytype)),1))
|
||||
TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
|
||||
#define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
|
||||
(TYPE_FIELD_ARTIFICIAL(TYPE_INDEX_TYPE((arraytype)),0))
|
||||
TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
|
||||
|
||||
#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
|
||||
(TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
|
||||
@ -862,9 +893,9 @@ extern void allocate_cplus_struct_type (struct type *);
|
||||
#define TYPE_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
|
||||
#define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
|
||||
#define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.calling_convention
|
||||
#define TYPE_BASECLASS(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].type
|
||||
#define TYPE_BASECLASS(thistype,index) TYPE_FIELD_TYPE(thistype, index)
|
||||
#define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
|
||||
#define TYPE_BASECLASS_NAME(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].name
|
||||
#define TYPE_BASECLASS_NAME(thistype,index) TYPE_FIELD_NAME(thistype, index)
|
||||
#define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
|
||||
#define BASETYPE_VIA_PUBLIC(thistype, index) \
|
||||
((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
|
||||
@ -896,7 +927,7 @@ extern void allocate_cplus_struct_type (struct type *);
|
||||
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
|
||||
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
|
||||
|
||||
#define TYPE_FIELD(thistype, n) TYPE_MAIN_TYPE(thistype)->fields[n]
|
||||
#define TYPE_FIELD(thistype, n) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields[n]
|
||||
#define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
|
||||
#define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
|
||||
#define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
|
||||
@ -1227,8 +1258,8 @@ extern struct type *make_function_type (struct type *, struct type **);
|
||||
|
||||
extern struct type *lookup_function_type (struct type *);
|
||||
|
||||
extern struct type *create_range_type (struct type *, struct type *, int,
|
||||
int);
|
||||
extern struct type *create_range_type (struct type *, struct type *, LONGEST,
|
||||
LONGEST);
|
||||
|
||||
extern struct type *create_array_type (struct type *, struct type *,
|
||||
struct type *);
|
||||
|
@ -1743,13 +1743,11 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs,
|
||||
/* Deal with range types */
|
||||
if (t->bt == btRange)
|
||||
{
|
||||
TYPE_NFIELDS (tp) = 2;
|
||||
TYPE_FIELDS (tp) = ((struct field *)
|
||||
TYPE_ALLOC (tp, 2 * sizeof (struct field)));
|
||||
TYPE_FIELD_NAME (tp, 0) = "Low";
|
||||
TYPE_NFIELDS (tp) = 0;
|
||||
TYPE_RANGE_DATA (tp) = ((struct range_bounds *)
|
||||
TYPE_ZALLOC (tp, sizeof (struct range_bounds)));
|
||||
TYPE_LOW_BOUND (tp) = AUX_GET_DNLOW (bigend, ax);
|
||||
ax++;
|
||||
TYPE_FIELD_NAME (tp, 1) = "High";
|
||||
TYPE_HIGH_BOUND (tp) = AUX_GET_DNHIGH (bigend, ax);
|
||||
ax++;
|
||||
}
|
||||
|
@ -267,10 +267,9 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
|
||||
fprintf_filtered (stream, "array ");
|
||||
if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
|
||||
&& !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
|
||||
fprintf_filtered (stream, "[%d..%d] ",
|
||||
TYPE_ARRAY_LOWER_BOUND_VALUE (type),
|
||||
TYPE_ARRAY_UPPER_BOUND_VALUE (type)
|
||||
);
|
||||
fprintf_filtered (stream, "[%s..%s] ",
|
||||
plongest (TYPE_ARRAY_LOWER_BOUND_VALUE (type)),
|
||||
plongest (TYPE_ARRAY_UPPER_BOUND_VALUE (type)));
|
||||
fprintf_filtered (stream, "of ");
|
||||
break;
|
||||
|
||||
|
13
gdb/varobj.c
13
gdb/varobj.c
@ -2793,8 +2793,9 @@ c_describe_child (struct varobj *parent, int index,
|
||||
{
|
||||
case TYPE_CODE_ARRAY:
|
||||
if (cname)
|
||||
*cname = xstrprintf ("%d", index
|
||||
+ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)));
|
||||
*cname = xstrdup (int_string (index
|
||||
+ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
|
||||
10, 1, 0, 0));
|
||||
|
||||
if (cvalue && value)
|
||||
{
|
||||
@ -2806,9 +2807,11 @@ c_describe_child (struct varobj *parent, int index,
|
||||
*ctype = get_target_type (type);
|
||||
|
||||
if (cfull_expression)
|
||||
*cfull_expression = xstrprintf ("(%s)[%d]", parent_expression,
|
||||
index
|
||||
+ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)));
|
||||
*cfull_expression =
|
||||
xstrprintf ("(%s)[%s]", parent_expression,
|
||||
int_string (index
|
||||
+ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
|
||||
10, 1, 0, 0));
|
||||
|
||||
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user