aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-04-01 17:03:24 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-04-01 17:03:24 +0000
commitb0dd768854fdf8ca67141da5483119a16f1f0ef7 (patch)
tree5ae1b9a9f93eb0700a18621a8148f237c70c65bd /gdb
parent956a9fb9fb6573a18dca4726f8c2ae083bc4a508 (diff)
downloadgdb-b0dd768854fdf8ca67141da5483119a16f1f0ef7.zip
gdb-b0dd768854fdf8ca67141da5483119a16f1f0ef7.tar.gz
gdb-b0dd768854fdf8ca67141da5483119a16f1f0ef7.tar.bz2
[Ada] fix printing slice of array defined as typedef
A change we are making in the compiler to help preserve useful types when using -feliminate-unused-debug-types exposed a small hole in our value-printing code. One example of the problem happens when trying to print a slice of an array pointer. If the variable is defined as a pointer to the typedef of an array, then we fail to print the slice, like so: (gdb) p arr_ptr(1..2) cannot take slice of non-array gdb/ChangeLog: * ada-lang.c (ada_is_simple_array_type, ada_value_slice_from_ptr) (ada_value_slice, empty_array, to_fixed_array_type): Deal with typedefs.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/ada-lang.c20
2 files changed, 18 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bc94029..9b9f431 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2011-04-01 Eric Botcazou <ebotcazou@adacore.com>
+
+ * ada-lang.c (ada_is_simple_array_type, ada_value_slice_from_ptr)
+ (ada_value_slice, empty_array, to_fixed_array_type): Deal with
+ typedefs.
+
2011-04-01 Joel Brobecker <brobecker@adacore.com>
* breakpoint.h (bpdisp_text): Add declaration.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 6b0f510..0a0b09f 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1733,7 +1733,8 @@ ada_is_simple_array_type (struct type *type)
type = ada_check_typedef (type);
return (TYPE_CODE (type) == TYPE_CODE_ARRAY
|| (TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY));
+ && TYPE_CODE (ada_check_typedef (TYPE_TARGET_TYPE (type)))
+ == TYPE_CODE_ARRAY));
}
/* Non-zero iff TYPE belongs to a GNAT array descriptor. */
@@ -2578,14 +2579,15 @@ static struct value *
ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
int low, int high)
{
+ struct type *type0 = ada_check_typedef (type);
CORE_ADDR base = value_as_address (array_ptr)
- + ((low - ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type)))
- * TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
+ + ((low - ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type0)))
+ * TYPE_LENGTH (TYPE_TARGET_TYPE (type0)));
struct type *index_type =
- create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type)),
+ create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type0)),
low, high);
struct type *slice_type =
- create_array_type (NULL, TYPE_TARGET_TYPE (type), index_type);
+ create_array_type (NULL, TYPE_TARGET_TYPE (type0), index_type);
return value_at_lazy (slice_type, base);
}
@@ -2594,7 +2596,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
static struct value *
ada_value_slice (struct value *array, int low, int high)
{
- struct type *type = value_type (array);
+ struct type *type = ada_check_typedef (value_type (array));
struct type *index_type =
create_range_type (NULL, TYPE_INDEX_TYPE (type), low, high);
struct type *slice_type =
@@ -2803,10 +2805,11 @@ ada_array_length (struct value *arr, int n)
static struct value *
empty_array (struct type *arr_type, int low)
{
+ struct type *arr_type0 = ada_check_typedef (arr_type);
struct type *index_type =
- create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (arr_type)),
+ create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (arr_type0)),
low, low - 1);
- struct type *elt_type = ada_array_element_type (arr_type, 1);
+ struct type *elt_type = ada_array_element_type (arr_type0, 1);
return allocate_value (create_array_type (NULL, elt_type, index_type));
}
@@ -7552,6 +7555,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
struct type *result;
int constrained_packed_array_p;
+ type0 = ada_check_typedef (type0);
if (TYPE_FIXED_INSTANCE (type0))
return type0;