static struct type *to_fixed_array_type (struct type *, struct value *, int);
static struct type *to_fixed_range_type (char *, struct value *,
- struct objfile *);
+ struct type *);
static struct type *to_static_fixed_type (struct type *);
static struct type *static_unwrap_type (struct type *type);
static LONGEST
ada_array_bound_from_type (struct type * arr_type, int n, int which)
{
- struct type *type, *index_type_desc, *index_type;
+ struct type *type, *elt_type, *index_type_desc, *index_type;
LONGEST retval;
+ int i;
gdb_assert (which == 0 || which == 1);
else
type = arr_type;
+ elt_type = type;
+ for (i = n; i > 1; i--)
+ elt_type = TYPE_TARGET_TYPE (type);
+
index_type_desc = ada_find_parallel_type (type, "___XA");
if (index_type_desc != NULL)
index_type = to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1),
- NULL, TYPE_OBJFILE (arr_type));
+ NULL, TYPE_INDEX_TYPE (elt_type));
else
- {
- while (n > 1)
- {
- type = TYPE_TARGET_TYPE (type);
- n -= 1;
- }
-
- index_type = TYPE_INDEX_TYPE (type);
- }
+ index_type = TYPE_INDEX_TYPE (elt_type);
switch (TYPE_CODE (index_type))
{
consult the object tag. */
result =
ada_to_fixed_type (ada_check_typedef (elt_type0), 0, 0, dval, 1);
+
+ elt_type0 = type0;
for (i = TYPE_NFIELDS (index_type_desc) - 1; i >= 0; i -= 1)
{
struct type *range_type =
to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, i),
- dval, TYPE_OBJFILE (type0));
- result = create_array_type (alloc_type (TYPE_OBJFILE (type0)),
+ dval, TYPE_INDEX_TYPE (elt_type0));
+ result = create_array_type (alloc_type (TYPE_OBJFILE (elt_type0)),
result, range_type);
+ elt_type0 = TYPE_TARGET_TYPE (elt_type0);
}
if (!ignore_too_big && TYPE_LENGTH (result) > varsize_limit)
error (_("array type with dynamic size is larger than varsize-limit"));
char *name = ada_type_name (type_arg);
range_type = NULL;
if (name != NULL && TYPE_CODE (type_arg) != TYPE_CODE_ENUM)
- range_type =
- to_fixed_range_type (name, NULL, TYPE_OBJFILE (type_arg));
+ range_type = to_fixed_range_type (name, NULL, type_arg);
if (range_type == NULL)
range_type = type_arg;
switch (op)
/* Return a range type whose base type is that of the range type named
NAME in the current environment, and whose bounds are calculated
from NAME according to the GNAT range encoding conventions.
- Extract discriminant values, if needed, from DVAL. If a new type
- must be created, allocate in OBJFILE's space. The bounds
- information, in general, is encoded in NAME, the base type given in
- the named range type. */
+ Extract discriminant values, if needed, from DVAL. ORIG_TYPE is the
+ corresponding range type from debug information; fall back to using it
+ if symbol lookup fails. If a new type must be created, allocate it
+ like ORIG_TYPE was. The bounds information, in general, is encoded
+ in NAME, the base type given in the named range type. */
static struct type *
-to_fixed_range_type (char *name, struct value *dval, struct objfile *objfile)
+to_fixed_range_type (char *name, struct value *dval, struct type *orig_type)
{
struct type *raw_type = ada_find_any_type (name);
struct type *base_type;
char *subtype_info;
- /* Also search primitive types if type symbol could not be found. */
+ /* Fall back to the original type if symbol lookup failed. */
if (raw_type == NULL)
- raw_type = language_lookup_primitive_type_by_name
- (language_def (language_ada), current_gdbarch, name);
+ raw_type = orig_type;
- if (raw_type == NULL)
- base_type = builtin_type_int32;
- else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
+ if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
base_type = TYPE_TARGET_TYPE (raw_type);
else
base_type = raw_type;
if (L < INT_MIN || U > INT_MAX)
return raw_type;
else
- return create_range_type (alloc_type (objfile), raw_type,
+ return create_range_type (alloc_type (TYPE_OBJFILE (orig_type)),
+ raw_type,
discrete_type_low_bound (raw_type),
discrete_type_high_bound (raw_type));
}
}
}
- if (objfile == NULL)
- objfile = TYPE_OBJFILE (base_type);
- type = create_range_type (alloc_type (objfile), base_type, L, U);
+ type = create_range_type (alloc_type (TYPE_OBJFILE (orig_type)),
+ base_type, L, U);
TYPE_NAME (type) = name;
return type;
}
print_dynamic_range_bound (struct type *, const char *, int,
const char *, struct ui_file *);
-static void print_range_type_named (char *, struct ui_file *);
+static void print_range_type_named (char *, struct type *, struct ui_file *);
\f
fprintf_filtered (stream, "?");
}
-/* Print the range type named NAME. */
+/* Print the range type named NAME. If symbol lookup fails, fall back
+ to ORIG_TYPE as base type. */
static void
-print_range_type_named (char *name, struct ui_file *stream)
+print_range_type_named (char *name, struct type *orig_type,
+ struct ui_file *stream)
{
struct type *raw_type = ada_find_any_type (name);
struct type *base_type;
char *subtype_info;
if (raw_type == NULL)
- base_type = builtin_type_int32;
- else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
+ raw_type = orig_type;
+
+ if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
base_type = TYPE_TARGET_TYPE (raw_type);
else
base_type = raw_type;
subtype_info = strstr (name, "___XD");
- if (subtype_info == NULL && raw_type == NULL)
- fprintf_filtered (stream, "? .. ?");
- else if (subtype_info == NULL)
+ if (subtype_info == NULL)
print_range (raw_type, stream);
else
{
if (k > 0)
fprintf_filtered (stream, ", ");
print_range_type_named (TYPE_FIELD_NAME
- (range_desc_type, k), stream);
+ (range_desc_type, k),
+ TYPE_INDEX_TYPE (arr_type), stream);
if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
}
else
{
fprintf_filtered (stream, "range ");
- print_range_type_named (name, stream);
+ print_range_type_named (name, type, stream);
}
}
break;