From 10f6a3add6b4bdd1c83494cad9e9497271fe0922 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 4 Nov 2020 08:49:16 -0700 Subject: Only use stride for final element type A DWARF array type may specify a stride. Currently, the DWARF reader applies this stride to every dimension of an array. However, this seems incorrect to me -- only the innermost array ought to use the stride, while outer arrays should compute a stride based on the size of the inner arrays. This patch arranges to apply the stride only to the innermost array type. This fixes a bug noticed when running some Ada tests with -fgnat-encodings=minimal. gdb/ChangeLog 2020-11-04 Tom Tromey * dwarf2/read.c (read_array_type): Only apply stride to innermost array. gdb/testsuite/ChangeLog 2020-11-04 Tom Tromey * gdb.ada/enum_idx_packed.exp: Add test. * gdb.ada/enum_idx_packed/foo.adb (Multi_Access): New variable. * gdb.ada/enum_idx_packed/pck.ads (Short) (Multi_Dimension, Multi_Dimension_Access): New types. --- gdb/dwarf2/read.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'gdb/dwarf2/read.c') diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 364a16d..a417127 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -17097,15 +17097,23 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) int i = 0; while (i < range_types.size ()) - type = create_array_type_with_stride (NULL, type, range_types[i++], - byte_stride_prop, bit_stride); + { + type = create_array_type_with_stride (NULL, type, range_types[i++], + byte_stride_prop, bit_stride); + bit_stride = 0; + byte_stride_prop = nullptr; + } } else { size_t ndim = range_types.size (); while (ndim-- > 0) - type = create_array_type_with_stride (NULL, type, range_types[ndim], - byte_stride_prop, bit_stride); + { + type = create_array_type_with_stride (NULL, type, range_types[ndim], + byte_stride_prop, bit_stride); + bit_stride = 0; + byte_stride_prop = nullptr; + } } /* Understand Dwarf2 support for vector types (like they occur on -- cgit v1.1