aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorJerome Guitton <guitton@adacore.com>2015-03-26 16:19:27 +0100
committerJoel Brobecker <brobecker@adacore.com>2015-05-15 14:00:57 -0700
commit931e5bc3e19d1e279fc28c5cf5571f812c79b8d3 (patch)
tree48194de8ebbed604f308183f4207630d7f2ebe4b /gdb/ada-lang.c
parentfd8008d83ce379a8d3f3bb9c3b1a723e16c401d4 (diff)
downloadgdb-931e5bc3e19d1e279fc28c5cf5571f812c79b8d3.zip
gdb-931e5bc3e19d1e279fc28c5cf5571f812c79b8d3.tar.gz
gdb-931e5bc3e19d1e279fc28c5cf5571f812c79b8d3.tar.bz2
Non bit-packed packed arrays as variable-length fields
In the case of non bit-packed arrays, GNAT does not generate its traditional XP encoding; it is not needed. However, it still generates the so-called "implementation type" with a P suffix. This implementation type shall be skipped when looking for other descriptive types such as XA encodings for variable-length fields. Note also that there may be an intermediate typedef between the implementation type and its XA description. It shall be skipped as well. gdb/ChangeLog: Jerome Guitton <guitton@adacore.com> * ada-lang.c (find_parallel_type_by_descriptive_type): Go through typedefs during lookup. (to_fixed_array_type): Add support for non-bit packed arrays as variable-length fields. gdb/testsuite/ChangeLog: * gdb.ada/byte_packed_arr: New testcase.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index e3fa363..02d82ef 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7762,7 +7762,7 @@ ada_type_name (struct type *type)
static struct type *
find_parallel_type_by_descriptive_type (struct type *type, const char *name)
{
- struct type *result;
+ struct type *result, *tmp;
if (ada_ignore_descriptive_types_p)
return NULL;
@@ -7789,9 +7789,21 @@ find_parallel_type_by_descriptive_type (struct type *type, const char *name)
/* Otherwise, look at the next item on the list, if any. */
if (HAVE_GNAT_AUX_INFO (result))
- result = TYPE_DESCRIPTIVE_TYPE (result);
+ tmp = TYPE_DESCRIPTIVE_TYPE (result);
else
- result = NULL;
+ tmp = NULL;
+
+ /* If not found either, try after having resolved the typedef. */
+ if (tmp != NULL)
+ result = tmp;
+ else
+ {
+ CHECK_TYPEDEF (result);
+ if (HAVE_GNAT_AUX_INFO (result))
+ result = TYPE_DESCRIPTIVE_TYPE (result);
+ else
+ result = NULL;
+ }
}
/* If we didn't find a match, see whether this is a packed array. With
@@ -8509,6 +8521,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
struct type *index_type_desc;
struct type *result;
int constrained_packed_array_p;
+ static const char *xa_suffix = "___XA";
type0 = ada_check_typedef (type0);
if (TYPE_FIXED_INSTANCE (type0))
@@ -8518,7 +8531,30 @@ to_fixed_array_type (struct type *type0, struct value *dval,
if (constrained_packed_array_p)
type0 = decode_constrained_packed_array_type (type0);
- index_type_desc = ada_find_parallel_type (type0, "___XA");
+ index_type_desc = ada_find_parallel_type (type0, xa_suffix);
+
+ /* As mentioned in exp_dbug.ads, for non bit-packed arrays an
+ encoding suffixed with 'P' may still be generated. If so,
+ it should be used to find the XA type. */
+
+ if (index_type_desc == NULL)
+ {
+ const char *typename = ada_type_name (type0);
+
+ if (typename != NULL)
+ {
+ const int len = strlen (typename);
+ char *name = (char *) alloca (len + strlen (xa_suffix));
+
+ if (typename[len - 1] == 'P')
+ {
+ strcpy (name, typename);
+ strcpy (name + len - 1, xa_suffix);
+ index_type_desc = ada_find_parallel_type_with_name (type0, name);
+ }
+ }
+ }
+
ada_fixup_array_indexes_type (index_type_desc);
if (index_type_desc != NULL
&& ada_is_redundant_index_type_desc (type0, index_type_desc))