[Ada] array and bounds in fat pointer can be a stub

This patch adds handling of the case when a fat pointer has the
P_ARRAY and/or P_BOUNDS fields defined as a stub.  In that case,
this stub needs to be resolved.

There are two issues:

  . First, making sure that the resolution takes place itself.
    That's the change to ada_check_typedef.

  . Make sure that the type returned after resolution is not itself
    a typedef.  This is the change to ada_check_typedef.

gdb/ChangeLog (Jerome Guitton, Joel Brobecker):

        * ada-lang.c (desc_bounds): Add handling of the case where
        the P_BOUNDS field is a pointer to a stub.
        (desc_data_target_type): Same for P_ARRAY field.
        (ada_check_typedef): Strip the typedef layers from the type
        found by ada_find_any_type.
This commit is contained in:
Joel Brobecker 2010-10-01 16:25:00 +00:00
parent 49a45ecfd2
commit 05e522ef51
2 changed files with 38 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2010-10-01 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (desc_bounds): Add handling of the case where
the P_BOUNDS field is a pointer to a stub.
(desc_data_target_type): Same for P_ARRAY field.
(ada_check_typedef): Strip the typedef layers from the type
found by ada_find_any_type.
2010-10-01 Joel Brobecker <brobecker@adacore.com>
* sparc-tdep.c (sparc32_frame_align): New function.

View file

@ -1491,8 +1491,26 @@ desc_bounds (struct value *arr)
}
else if (is_thick_pntr (type))
return value_struct_elt (&arr, NULL, "P_BOUNDS", NULL,
_("Bad GNAT array descriptor"));
{
struct value *p_bounds = value_struct_elt (&arr, NULL, "P_BOUNDS", NULL,
_("Bad GNAT array descriptor"));
struct type *p_bounds_type = value_type (p_bounds);
if (p_bounds_type
&& TYPE_CODE (p_bounds_type) == TYPE_CODE_PTR)
{
struct type *target_type = TYPE_TARGET_TYPE (p_bounds_type);
if (TYPE_STUB (target_type))
p_bounds = value_cast (lookup_pointer_type
(ada_check_typedef (target_type)),
p_bounds);
}
else
error (_("Bad GNAT array descriptor"));
return p_bounds;
}
else
return NULL;
}
@ -1539,7 +1557,7 @@ desc_data_target_type (struct type *type)
if (data_type
&& TYPE_CODE (ada_check_typedef (data_type)) == TYPE_CODE_PTR)
return TYPE_TARGET_TYPE (data_type);
return ada_check_typedef (TYPE_TARGET_TYPE (data_type));
}
return NULL;
@ -7636,7 +7654,15 @@ ada_check_typedef (struct type *type)
char *name = TYPE_TAG_NAME (type);
struct type *type1 = ada_find_any_type (name);
return (type1 == NULL) ? type : type1;
if (type1 == NULL)
return type;
/* TYPE1 might itself be a TYPE_CODE_TYPEDEF (this can happen with
stubs pointing to arrays, as we don't create symbols for array
types, only for the typedef-to-array types). This is why
we process TYPE1 with ada_check_typedef before returning
the result. */
return ada_check_typedef (type1);
}
}