diff options
author | Tom Tromey <tromey@adacore.com> | 2020-11-04 08:49:16 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-11-04 08:49:18 -0700 |
commit | 10f6a3add6b4bdd1c83494cad9e9497271fe0922 (patch) | |
tree | 05a6b642c9632e078286abad56a9b5d731ede1e1 /gdb | |
parent | b72795a8f573c36aaeedd1a64f58ad52b4c72439 (diff) | |
download | binutils-10f6a3add6b4bdd1c83494cad9e9497271fe0922.zip binutils-10f6a3add6b4bdd1c83494cad9e9497271fe0922.tar.gz binutils-10f6a3add6b4bdd1c83494cad9e9497271fe0922.tar.bz2 |
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 <tromey@adacore.com>
* dwarf2/read.c (read_array_type): Only apply stride to innermost
array.
gdb/testsuite/ChangeLog
2020-11-04 Tom Tromey <tromey@adacore.com>
* 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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 16 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/enum_idx_packed.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/enum_idx_packed/foo.adb | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.ada/enum_idx_packed/pck.ads | 5 |
6 files changed, 38 insertions, 4 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0c6d399..a98f89d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2020-11-04 Tom Tromey <tromey@adacore.com> + * dwarf2/read.c (read_array_type): Only apply stride to innermost + array. + +2020-11-04 Tom Tromey <tromey@adacore.com> + * gdbtypes.c (update_static_array_size): Handle bit stride. 2020-11-04 Tom Tromey <tromey@adacore.com> 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 diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 0bdc314..d18d88f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2020-11-04 Tom Tromey <tromey@adacore.com> + * 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. + +2020-11-04 Tom Tromey <tromey@adacore.com> + * gdb.ada/enum_idx_packed.exp: Test two forms of -fgnat-encodings. 2020-11-04 Tom Tromey <tromey@adacore.com> diff --git a/gdb/testsuite/gdb.ada/enum_idx_packed.exp b/gdb/testsuite/gdb.ada/enum_idx_packed.exp index 9185968..2e5a85e 100644 --- a/gdb/testsuite/gdb.ada/enum_idx_packed.exp +++ b/gdb/testsuite/gdb.ada/enum_idx_packed.exp @@ -118,4 +118,7 @@ foreach_with_prefix scenario {all minimal} { setup_kfail "minimal encodings" *-*-* } gdb_test "print multi_multi(2)" " = $matrix" + + gdb_test "print multi_access.all" \ + " = \\(\\(8, 13, 21, 34, 55\\), \\(1, 1, 2, 3, 5\\)\\)" } diff --git a/gdb/testsuite/gdb.ada/enum_idx_packed/foo.adb b/gdb/testsuite/gdb.ada/enum_idx_packed/foo.adb index e9f3074..bc82831 100644 --- a/gdb/testsuite/gdb.ada/enum_idx_packed/foo.adb +++ b/gdb/testsuite/gdb.ada/enum_idx_packed/foo.adb @@ -22,6 +22,10 @@ procedure Foo is Small : Small_Table := New_Small_Table (Low => Red, High => Green); Multi : Multi_Table := New_Multi_Table (Red, Green, Low, Medium); Multi_Multi : Multi_Multi_Table := New_Multi_Multi_Table (1, 2, 1, 7, 1, 10); + Multi_Access : Multi_Dimension_Access + := new Multi_Dimension'(True => (1, 1, 2, 3, 5), + False => (8, 13, 21, 34, 55)); + begin Do_Nothing (Full'Address); -- STOP Do_Nothing (Primary'Address); @@ -29,4 +33,5 @@ begin Do_Nothing (Small'Address); Do_Nothing (Multi'Address); Do_Nothing (Multi_Multi'Address); + Do_Nothing (Multi_Access'Address); end Foo; diff --git a/gdb/testsuite/gdb.ada/enum_idx_packed/pck.ads b/gdb/testsuite/gdb.ada/enum_idx_packed/pck.ads index fdfd8bb..7fe5a9e 100644 --- a/gdb/testsuite/gdb.ada/enum_idx_packed/pck.ads +++ b/gdb/testsuite/gdb.ada/enum_idx_packed/pck.ads @@ -17,6 +17,7 @@ with System; package Pck is type Color is (Black, Red, Green, Blue, White); type Strength is (None, Low, Medium, High); + type Short is new Natural range 0 .. 2 ** 8 - 1; type Full_Table is array (Color) of Boolean; pragma Pack (Full_Table); @@ -43,5 +44,9 @@ package Pck is function New_Multi_Multi_Table (L1, H1, L2, H2, L3, H3: Positive) return Multi_Multi_Table; + type Multi_Dimension is array (Boolean, Color) of Short; + pragma Pack (Multi_Dimension); + type Multi_Dimension_Access is access all Multi_Dimension; + procedure Do_Nothing (A : System.Address); end Pck; |