aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/ada-lang.c12
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp72
4 files changed, 93 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 67f631d..4601ae7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2014-09-10 Joel Brobecker <brobecker@adacore.com>
+ * ada-lang.c (ada_array_bound): If ARR is a TYPE_CODE_PTR,
+ dereference it first. Use value_enclosing_type instead of
+ value_type.
+ (ada_array_length): Likewise.
+
+2014-09-10 Joel Brobecker <brobecker@adacore.com>
+
* ada-lang.c (ada_value_ptr_subscript): Remove parameter "type".
Adjust function implementation and documentation accordingly.
(ada_evaluate_subexp) <OP_FUNCALL>: Only assign "type" if
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 4c6d039..c7e50e2 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2942,7 +2942,11 @@ ada_array_bound_from_type (struct type *arr_type, int n, int which)
static LONGEST
ada_array_bound (struct value *arr, int n, int which)
{
- struct type *arr_type = value_type (arr);
+ struct type *arr_type;
+
+ if (TYPE_CODE (check_typedef (value_type (arr))) == TYPE_CODE_PTR)
+ arr = value_ind (arr);
+ arr_type = value_enclosing_type (arr);
if (ada_is_constrained_packed_array_type (arr_type))
return ada_array_bound (decode_constrained_packed_array (arr), n, which);
@@ -2961,7 +2965,11 @@ ada_array_bound (struct value *arr, int n, int which)
static LONGEST
ada_array_length (struct value *arr, int n)
{
- struct type *arr_type = ada_check_typedef (value_type (arr));
+ struct type *arr_type;
+
+ if (TYPE_CODE (check_typedef (value_type (arr))) == TYPE_CODE_PTR)
+ arr = value_ind (arr);
+ arr_type = value_enclosing_type (arr);
if (ada_is_constrained_packed_array_type (arr_type))
return ada_array_length (decode_constrained_packed_array (arr), n);
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ebb7e6a..66b50a9 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2014-09-10 Joel Brobecker <brobecker@adacore.com>
+ * gdb.dwarf2/dynarr-ptr.exp: Add 'first, 'last and 'length tests.
+
+2014-09-10 Joel Brobecker <brobecker@adacore.com>
+
* gdb.dwarf2/dynarr-ptr.exp: Add subscripting tests.
2014-09-10 Joel Brobecker <brobecker@adacore.com>
diff --git a/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp b/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
index 1df5e3c..696c765 100644
--- a/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
@@ -146,6 +146,15 @@ gdb_test "print foo.three_ptr.all(2)" \
gdb_test "print foo.three_ptr.all(3)" \
" = 3"
+gdb_test "print foo.three_ptr.all'first" \
+ " = 1"
+
+gdb_test "print foo.three_ptr.all'last" \
+ " = 3"
+
+gdb_test "print foo.three_ptr.all'length" \
+ " = 3"
+
# foo.three_ptr
gdb_test "print foo.three_ptr(1)" \
@@ -157,6 +166,15 @@ gdb_test "print foo.three_ptr(2)" \
gdb_test "print foo.three_ptr(3)" \
" = 3"
+gdb_test "print foo.three_ptr'first" \
+ " = 1"
+
+gdb_test "print foo.three_ptr'last" \
+ " = 3"
+
+gdb_test "print foo.three_ptr'length" \
+ " = 3"
+
# foo.three_ptr_tdef.all
gdb_test "print foo.three_ptr_tdef.all" \
@@ -171,6 +189,15 @@ gdb_test "print foo.three_ptr_tdef.all(2)" \
gdb_test "print foo.three_ptr_tdef.all(3)" \
" = 3"
+gdb_test "print foo.three_ptr_tdef.all'first" \
+ " = 1"
+
+gdb_test "print foo.three_ptr_tdef.all'last" \
+ " = 3"
+
+gdb_test "print foo.three_ptr_tdef.all'length" \
+ " = 3"
+
# foo.three_ptr_tdef
gdb_test "print foo.three_ptr_tdef(1)" \
@@ -182,6 +209,15 @@ gdb_test "print foo.three_ptr_tdef(2)" \
gdb_test "print foo.three_ptr_tdef(3)" \
" = 3"
+gdb_test "print foo.three_ptr_tdef'first" \
+ " = 1"
+
+gdb_test "print foo.three_ptr_tdef'last" \
+ " = 3"
+
+gdb_test "print foo.three_ptr_tdef'length" \
+ " = 3"
+
# foo.five_ptr.all
gdb_test "print foo.five_ptr.all" \
@@ -202,6 +238,15 @@ gdb_test "print foo.five_ptr.all(5)" \
gdb_test "print foo.five_ptr.all(6)" \
" = 34"
+gdb_test "print foo.five_ptr.all'first" \
+ " = 2"
+
+gdb_test "print foo.five_ptr.all'last" \
+ " = 6"
+
+gdb_test "print foo.five_ptr.all'length" \
+ " = 5"
+
# foo.five_ptr
gdb_test "print foo.five_ptr(2)" \
@@ -219,6 +264,15 @@ gdb_test "print foo.five_ptr(5)" \
gdb_test "print foo.five_ptr(6)" \
" = 34"
+gdb_test "print foo.five_ptr'first" \
+ " = 2"
+
+gdb_test "print foo.five_ptr'last" \
+ " = 6"
+
+gdb_test "print foo.five_ptr'length" \
+ " = 5"
+
# foo.five_ptr_tdef.all
gdb_test "print foo.five_ptr_tdef.all" \
@@ -239,6 +293,15 @@ gdb_test "print foo.five_ptr_tdef.all(5)" \
gdb_test "print foo.five_ptr_tdef.all(6)" \
" = 34"
+gdb_test "print foo.five_ptr_tdef.all'first" \
+ " = 2"
+
+gdb_test "print foo.five_ptr_tdef.all'last" \
+ " = 6"
+
+gdb_test "print foo.five_ptr_tdef.all'length" \
+ " = 5"
+
# foo.five_ptr_tdef
gdb_test "print foo.five_ptr_tdef(2)" \
@@ -255,3 +318,12 @@ gdb_test "print foo.five_ptr_tdef(5)" \
gdb_test "print foo.five_ptr_tdef(6)" \
" = 34"
+
+gdb_test "print foo.five_ptr_tdef'first" \
+ " = 2"
+
+gdb_test "print foo.five_ptr_tdef'last" \
+ " = 6"
+
+gdb_test "print foo.five_ptr_tdef'length" \
+ " = 5"