aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorJerome Guitton <guitton@adacore.com>2018-01-05 03:03:59 -0500
committerJoel Brobecker <brobecker@adacore.com>2018-01-05 03:14:19 -0500
commit7150d33cda60fd543e9d9d68eb58d4e6155fb878 (patch)
tree7c477193d908664414cd91e9fa3136d9a4f2da50 /gdb/ada-lang.c
parentcc0e770c0d00acececc43826f4673896d09b3dff (diff)
downloadgdb-7150d33cda60fd543e9d9d68eb58d4e6155fb878.zip
gdb-7150d33cda60fd543e9d9d68eb58d4e6155fb878.tar.gz
gdb-7150d33cda60fd543e9d9d68eb58d4e6155fb878.tar.bz2
(Ada) Fix Length attribute on array access
Consider the following variable "Indexed_By_Enum", declared as an access to an array whose index type is an enumerated type whose underlying values have "gaps": type Enum_With_Gaps is (LIT0, LIT1, LIT2, LIT3, LIT4); for Enum_With_Gaps use (LIT0 => 3, LIT1 => 5, LIT2 => 8, LIT3 => 13, LIT4 => 21); for Enum_With_Gaps'size use 16; type MyWord is range 0 .. 16#FFFF# ; for MyWord'Size use 16; type AR is array (Enum_With_Gaps range <>) of MyWord; type AR_Access is access AR; Indexed_By_Enum : AR_Access := new AR'(LIT1 => 1, LIT2 => 43, LIT3 => 42, LIT4 => 41); Trying to print the length (number of elements) of this array using the 'Length attribute does not work: (gdb) print indexed_by_enum'length 'POS only defined on discrete types The problem occurs while trying to get the array's index type. It was using TYPE_INDEX_TYPE for that. It does not work for Ada arrays in general; use ada_index_type instead. gdb/ChangeLog: * ada-lang.c (ada_array_length): Use ada_index_type instead of TYPE_INDEX_TYPE. gdb/testsuite/ChangeLog: * gdb.ada/arr_acc_idx_w_gap: New testcase. Tested on x86_64-linux.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 85e50cc..846cf8c 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3179,7 +3179,7 @@ ada_array_length (struct value *arr, int n)
}
arr_type = check_typedef (arr_type);
- index_type = TYPE_INDEX_TYPE (arr_type);
+ index_type = ada_index_type (arr_type, n, "length");
if (index_type != NULL)
{
struct type *base_type;