This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] (Ada) New function ada_is_access_to_unconstrained_array
- From: Joel Brobecker <brobecke at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 10 Sep 2018 15:40:17 -0000
- Subject: [binutils-gdb] (Ada) New function ada_is_access_to_unconstrained_array
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=736ade86ea3dd3df31120b6c617d64c88bcc86c1
commit 736ade86ea3dd3df31120b6c617d64c88bcc86c1
Author: Xavier Roirand <roirand@adacore.com>
Date: Mon Sep 10 10:32:00 2018 -0500
(Ada) New function ada_is_access_to_unconstrained_array
Add a new function to check if a given type is an access to an
unconstrained array. This function contains code that is present only
once in the current sources but will be used in a future patch.
gdb/ChangeLog:
* ada-lang.c (ada_is_access_to_unconstrained_array): New function.
(ada_check_typedef): Use it.
Tested on x86_64-linux.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/ada-lang.c | 15 ++++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ca678dd..5401864 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2018-09-10 Xavier Roirand <roirand@adacore.com>
+ * ada-lang.c (ada_is_access_to_unconstrained_array): New function.
+ (ada_check_typedef): Use it.
+
+2018-09-10 Xavier Roirand <roirand@adacore.com>
+
* ada-varobj.c (ada_varobj_describe_struct_child)
(ada_varobj_describe_child): Handle union case like struct one.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b8a11cd..83421ac 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2832,6 +2832,15 @@ value_assign_to_component (struct value *container, struct value *component,
value_contents (val), 0, bits, 0);
}
+/* Determine if TYPE is an access to an unconstrained array. */
+
+static bool
+ada_is_access_to_unconstrained_array (struct type *type)
+{
+ return (TYPE_CODE (type) == TYPE_CODE_TYPEDEF
+ && is_thick_pntr (ada_typedef_target_type (type)));
+}
+
/* The value of the element of array ARR at the ARITY indices given in IND.
ARR may be either a simple array, GNAT array descriptor, or pointer
thereto. */
@@ -9245,13 +9254,13 @@ ada_check_typedef (struct type *type)
if (type == NULL)
return NULL;
- /* If our type is a typedef type of a fat pointer, then we're done.
+ /* If our type is an access to an unconstrained array, which is encoded
+ as a TYPE_CODE_TYPEDEF of a fat pointer, then we're done.
We don't want to strip the TYPE_CODE_TYPDEF layer, because this is
what allows us to distinguish between fat pointers that represent
array types, and fat pointers that represent array access types
(in both cases, the compiler implements them as fat pointers). */
- if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF
- && is_thick_pntr (ada_typedef_target_type (type)))
+ if (ada_is_access_to_unconstrained_array (type))
return type;
type = check_typedef (type);