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:17 -0700 |
commit | a7400e443cb4c20aea2c1c4641cb56a913ff7235 (patch) | |
tree | 558f8c5a6b7eb54e3182a396ef50a293cf97a5b6 /gdb/testsuite/gdb.ada/enum_idx_packed.exp | |
parent | 75fd6a26f893fbee0ebd665612e115c0735274ab (diff) | |
download | gdb-a7400e443cb4c20aea2c1c4641cb56a913ff7235.zip gdb-a7400e443cb4c20aea2c1c4641cb56a913ff7235.tar.gz gdb-a7400e443cb4c20aea2c1c4641cb56a913ff7235.tar.bz2 |
Fix decoding of multi-dimensional constrained packed arrays
Printing a multi-dimensional constrained packed array in Ada would not
show the correct values. The bug here is that, when decoding the type
of such an array, only the innermost dimension's element bitsize would
be correct. For outer dimensions, the bitsize must account for the
size of each sub-array, but this was not done.
This patch fixes the problem by arranging to compute these sizes after
decoding the array type. I've included a bit more test case than is
strictly necessary -- the current test here was derived from an
internal test, and this patch brings the two into sync.
gdb/ChangeLog
2020-11-04 Tom Tromey <tromey@adacore.com>
* ada-lang.c (recursively_update_array_bitsize): New function.
(decode_constrained_packed_array_type): Call it.
gdb/testsuite/ChangeLog
2020-11-04 Tom Tromey <tromey@adacore.com>
* gdb.ada/enum_idx_packed.exp: Add tests.
* gdb.ada/enum_idx_packed/foo.adb: Add variables.
* gdb.ada/enum_idx_packed/pck.adb: Add functions.
* gdb.ada/enum_idx_packed/pck.ads: Add types, function
declarations.
Diffstat (limited to 'gdb/testsuite/gdb.ada/enum_idx_packed.exp')
-rw-r--r-- | gdb/testsuite/gdb.ada/enum_idx_packed.exp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ada/enum_idx_packed.exp b/gdb/testsuite/gdb.ada/enum_idx_packed.exp index bfa091e..480de71 100644 --- a/gdb/testsuite/gdb.ada/enum_idx_packed.exp +++ b/gdb/testsuite/gdb.ada/enum_idx_packed.exp @@ -28,7 +28,55 @@ clean_restart ${testfile} set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb] runto "foo.adb:$bp_location" +gdb_test "ptype full" \ + "type = array \\(black \\.\\. white\\) of boolean <packed: 1-bit elements>" + gdb_test "print full" " = \\(false, true, false, true, false\\)" gdb_test "print full'first" " = black" +gdb_test "ptype primary" \ + "type = array \\(red \\.\\. blue\\) of boolean <packed: 1-bit elements>" + +gdb_test "print primary" " = \\(red => false, true, false\\)" + +gdb_test "print primary'first" " = red" + +gdb_test "ptype cold" \ + "type = array \\(green \\.\\. blue\\) of boolean <packed: 1-bit elements>" + +gdb_test "print cold" " = \\(green => false, true\\)" + +gdb_test "print cold'first" " = green" + +# Note the bounds values are still not correctly displayed. So we get +# the enum equivalent of "1 .. 0" (empty range) as the array ranges. +# Accept that for now. +gdb_test "ptype small" \ + "array \\(red \\.\\. green\\) of boolean <packed: 1-bit elements>" + +gdb_test "print small" " = \\(red => false, true\\)" + +gdb_test "print small'first" " = red" + +gdb_test "ptype multi" \ + "array \\(red \\.\\. green, low .. medium\\) of boolean <packed: 1-bit elements>" + +gdb_test "print multi" \ + " = \\(red => \\(low => true, false\\), \\(low => true, false\\)\\)" + +gdb_test "print multi'first" " = red" + +set base "\\(true, false, true, false, true, false, true, false, true, false\\)" +set matrix "\\(" +foreach x {1 2 3 4 5 6 7} { + if {$x > 1} { + append matrix ", " + } + append matrix $base +} +append matrix "\\)" + +gdb_test "print multi_multi" " = \\($matrix, $matrix\\)" +gdb_test "print multi_multi(1,3)" " = $base" +gdb_test "print multi_multi(2)" " = $matrix" |