aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-11-04 08:49:16 -0700
committerTom Tromey <tromey@adacore.com>2020-11-04 08:49:19 -0700
commit7ff5b9370f4f7c0c75d734aa19b8f020429d4bb5 (patch)
tree477e1f023488cb143b18423a4aa49e6e5d5e5a7c /gdb/ada-lang.c
parent10f6a3add6b4bdd1c83494cad9e9497271fe0922 (diff)
downloadgdb-7ff5b9370f4f7c0c75d734aa19b8f020429d4bb5.zip
gdb-7ff5b9370f4f7c0c75d734aa19b8f020429d4bb5.tar.gz
gdb-7ff5b9370f4f7c0c75d734aa19b8f020429d4bb5.tar.bz2
Use bit stride when taking slice of array
Testing with -fgnat-encodings=minimal showed that the Ada code failed to use the bit stride of an array when taking a slice. This patch fixes the oversight. gdb/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * ada-lang.c (ada_value_slice_from_ptr): Use bit size. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey <tromey@adacore.com> * gdb.ada/array_of_variant.exp: New file. * gdb.ada/array_of_variant/p.adb: New file. * gdb.ada/array_of_variant/pck.ads: New file. * gdb.ada/array_of_variant/pck.adb: New file.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7613e19..fe3ea70 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -2828,9 +2828,11 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
base_low_pos = base_low;
}
- base = value_as_address (array_ptr)
- + ((low_pos - base_low_pos)
- * TYPE_LENGTH (TYPE_TARGET_TYPE (type0)));
+ ULONGEST stride = TYPE_FIELD_BITSIZE (slice_type, 0) / 8;
+ if (stride == 0)
+ stride = TYPE_LENGTH (TYPE_TARGET_TYPE (type0));
+
+ base = value_as_address (array_ptr) + (low_pos - base_low_pos) * stride;
return value_at_lazy (slice_type, base);
}