mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-20 06:15:09 +08:00
* ada-lang.c (to_fixed_range_type): Add ORIG_TYPE argument.
Fall back to orig_type as index type if symbol lookup fails. Allocate result types from ORIG_TYPE's objfile. (ada_array_bound_from_type, to_fixed_array_type, ada_evaluate_subexp): Pass original index type to to_fixed_range_type. Do not pass objfile. * ada-typeprint.c (print_range_type_named): Add ORIG_TYPE argument. Fall back to orig_type as index type if symbol lookup fails. (print_array_type, ada_print_type): Pass original index type to print_range_type_named.
This commit is contained in:
@ -1,3 +1,17 @@
|
|||||||
|
2009-06-29 Ulrich Weigand <uweigand@de.ibm.com>
|
||||||
|
|
||||||
|
* ada-lang.c (to_fixed_range_type): Add ORIG_TYPE argument.
|
||||||
|
Fall back to orig_type as index type if symbol lookup fails.
|
||||||
|
Allocate result types from ORIG_TYPE's objfile.
|
||||||
|
(ada_array_bound_from_type, to_fixed_array_type,
|
||||||
|
ada_evaluate_subexp): Pass original index type to
|
||||||
|
to_fixed_range_type. Do not pass objfile.
|
||||||
|
|
||||||
|
* ada-typeprint.c (print_range_type_named): Add ORIG_TYPE argument.
|
||||||
|
Fall back to orig_type as index type if symbol lookup fails.
|
||||||
|
(print_array_type, ada_print_type): Pass original index type
|
||||||
|
to print_range_type_named.
|
||||||
|
|
||||||
2009-06-29 Ulrich Weigand <uweigand@de.ibm.com>
|
2009-06-29 Ulrich Weigand <uweigand@de.ibm.com>
|
||||||
|
|
||||||
* ada-lang.c (ada_index_type): Update comment.
|
* ada-lang.c (ada_index_type): Update comment.
|
||||||
|
@ -168,7 +168,7 @@ static struct type *to_fixed_variant_branch_type (struct type *,
|
|||||||
static struct type *to_fixed_array_type (struct type *, struct value *, int);
|
static struct type *to_fixed_array_type (struct type *, struct value *, int);
|
||||||
|
|
||||||
static struct type *to_fixed_range_type (char *, struct value *,
|
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 *to_static_fixed_type (struct type *);
|
||||||
static struct type *static_unwrap_type (struct type *type);
|
static struct type *static_unwrap_type (struct type *type);
|
||||||
@ -2455,8 +2455,9 @@ ada_index_type (struct type *type, int n, const char *name)
|
|||||||
static LONGEST
|
static LONGEST
|
||||||
ada_array_bound_from_type (struct type * arr_type, int n, int which)
|
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;
|
LONGEST retval;
|
||||||
|
int i;
|
||||||
|
|
||||||
gdb_assert (which == 0 || which == 1);
|
gdb_assert (which == 0 || which == 1);
|
||||||
|
|
||||||
@ -2471,20 +2472,16 @@ ada_array_bound_from_type (struct type * arr_type, int n, int which)
|
|||||||
else
|
else
|
||||||
type = arr_type;
|
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");
|
index_type_desc = ada_find_parallel_type (type, "___XA");
|
||||||
if (index_type_desc != NULL)
|
if (index_type_desc != NULL)
|
||||||
index_type = to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, n - 1),
|
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
|
else
|
||||||
{
|
index_type = TYPE_INDEX_TYPE (elt_type);
|
||||||
while (n > 1)
|
|
||||||
{
|
|
||||||
type = TYPE_TARGET_TYPE (type);
|
|
||||||
n -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
index_type = TYPE_INDEX_TYPE (type);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (TYPE_CODE (index_type))
|
switch (TYPE_CODE (index_type))
|
||||||
{
|
{
|
||||||
@ -7195,13 +7192,16 @@ to_fixed_array_type (struct type *type0, struct value *dval,
|
|||||||
consult the object tag. */
|
consult the object tag. */
|
||||||
result =
|
result =
|
||||||
ada_to_fixed_type (ada_check_typedef (elt_type0), 0, 0, dval, 1);
|
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)
|
for (i = TYPE_NFIELDS (index_type_desc) - 1; i >= 0; i -= 1)
|
||||||
{
|
{
|
||||||
struct type *range_type =
|
struct type *range_type =
|
||||||
to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, i),
|
to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, i),
|
||||||
dval, TYPE_OBJFILE (type0));
|
dval, TYPE_INDEX_TYPE (elt_type0));
|
||||||
result = create_array_type (alloc_type (TYPE_OBJFILE (type0)),
|
result = create_array_type (alloc_type (TYPE_OBJFILE (elt_type0)),
|
||||||
result, range_type);
|
result, range_type);
|
||||||
|
elt_type0 = TYPE_TARGET_TYPE (elt_type0);
|
||||||
}
|
}
|
||||||
if (!ignore_too_big && TYPE_LENGTH (result) > varsize_limit)
|
if (!ignore_too_big && TYPE_LENGTH (result) > varsize_limit)
|
||||||
error (_("array type with dynamic size is larger than varsize-limit"));
|
error (_("array type with dynamic size is larger than varsize-limit"));
|
||||||
@ -9127,8 +9127,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
|
|||||||
char *name = ada_type_name (type_arg);
|
char *name = ada_type_name (type_arg);
|
||||||
range_type = NULL;
|
range_type = NULL;
|
||||||
if (name != NULL && TYPE_CODE (type_arg) != TYPE_CODE_ENUM)
|
if (name != NULL && TYPE_CODE (type_arg) != TYPE_CODE_ENUM)
|
||||||
range_type =
|
range_type = to_fixed_range_type (name, NULL, type_arg);
|
||||||
to_fixed_range_type (name, NULL, TYPE_OBJFILE (type_arg));
|
|
||||||
if (range_type == NULL)
|
if (range_type == NULL)
|
||||||
range_type = type_arg;
|
range_type = type_arg;
|
||||||
switch (op)
|
switch (op)
|
||||||
@ -9688,26 +9687,24 @@ get_int_var_value (char *name, int *flag)
|
|||||||
/* Return a range type whose base type is that of the range type named
|
/* Return a range type whose base type is that of the range type named
|
||||||
NAME in the current environment, and whose bounds are calculated
|
NAME in the current environment, and whose bounds are calculated
|
||||||
from NAME according to the GNAT range encoding conventions.
|
from NAME according to the GNAT range encoding conventions.
|
||||||
Extract discriminant values, if needed, from DVAL. If a new type
|
Extract discriminant values, if needed, from DVAL. ORIG_TYPE is the
|
||||||
must be created, allocate in OBJFILE's space. The bounds
|
corresponding range type from debug information; fall back to using it
|
||||||
information, in general, is encoded in NAME, the base type given in
|
if symbol lookup fails. If a new type must be created, allocate it
|
||||||
the named range type. */
|
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 *
|
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 *raw_type = ada_find_any_type (name);
|
||||||
struct type *base_type;
|
struct type *base_type;
|
||||||
char *subtype_info;
|
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)
|
if (raw_type == NULL)
|
||||||
raw_type = language_lookup_primitive_type_by_name
|
raw_type = orig_type;
|
||||||
(language_def (language_ada), current_gdbarch, name);
|
|
||||||
|
|
||||||
if (raw_type == NULL)
|
if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
|
||||||
base_type = builtin_type_int32;
|
|
||||||
else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
|
|
||||||
base_type = TYPE_TARGET_TYPE (raw_type);
|
base_type = TYPE_TARGET_TYPE (raw_type);
|
||||||
else
|
else
|
||||||
base_type = raw_type;
|
base_type = raw_type;
|
||||||
@ -9720,7 +9717,8 @@ to_fixed_range_type (char *name, struct value *dval, struct objfile *objfile)
|
|||||||
if (L < INT_MIN || U > INT_MAX)
|
if (L < INT_MIN || U > INT_MAX)
|
||||||
return raw_type;
|
return raw_type;
|
||||||
else
|
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_low_bound (raw_type),
|
||||||
discrete_type_high_bound (raw_type));
|
discrete_type_high_bound (raw_type));
|
||||||
}
|
}
|
||||||
@ -9783,9 +9781,8 @@ to_fixed_range_type (char *name, struct value *dval, struct objfile *objfile)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objfile == NULL)
|
type = create_range_type (alloc_type (TYPE_OBJFILE (orig_type)),
|
||||||
objfile = TYPE_OBJFILE (base_type);
|
base_type, L, U);
|
||||||
type = create_range_type (alloc_type (objfile), base_type, L, U);
|
|
||||||
TYPE_NAME (type) = name;
|
TYPE_NAME (type) = name;
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ static void
|
|||||||
print_dynamic_range_bound (struct type *, const char *, int,
|
print_dynamic_range_bound (struct type *, const char *, int,
|
||||||
const char *, struct ui_file *);
|
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 *);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -233,26 +233,27 @@ print_dynamic_range_bound (struct type *type, const char *name, int name_len,
|
|||||||
fprintf_filtered (stream, "?");
|
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
|
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 *raw_type = ada_find_any_type (name);
|
||||||
struct type *base_type;
|
struct type *base_type;
|
||||||
char *subtype_info;
|
char *subtype_info;
|
||||||
|
|
||||||
if (raw_type == NULL)
|
if (raw_type == NULL)
|
||||||
base_type = builtin_type_int32;
|
raw_type = orig_type;
|
||||||
else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
|
|
||||||
|
if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE)
|
||||||
base_type = TYPE_TARGET_TYPE (raw_type);
|
base_type = TYPE_TARGET_TYPE (raw_type);
|
||||||
else
|
else
|
||||||
base_type = raw_type;
|
base_type = raw_type;
|
||||||
|
|
||||||
subtype_info = strstr (name, "___XD");
|
subtype_info = strstr (name, "___XD");
|
||||||
if (subtype_info == NULL && raw_type == NULL)
|
if (subtype_info == NULL)
|
||||||
fprintf_filtered (stream, "? .. ?");
|
|
||||||
else if (subtype_info == NULL)
|
|
||||||
print_range (raw_type, stream);
|
print_range (raw_type, stream);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -398,7 +399,8 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
|
|||||||
if (k > 0)
|
if (k > 0)
|
||||||
fprintf_filtered (stream, ", ");
|
fprintf_filtered (stream, ", ");
|
||||||
print_range_type_named (TYPE_FIELD_NAME
|
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)
|
if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
|
||||||
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
|
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
|
||||||
}
|
}
|
||||||
@ -816,7 +818,7 @@ ada_print_type (struct type *type0, char *varstring, struct ui_file *stream,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf_filtered (stream, "range ");
|
fprintf_filtered (stream, "range ");
|
||||||
print_range_type_named (name, stream);
|
print_range_type_named (name, type, stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user