aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-09-15 08:59:09 -0600
committerTom Tromey <tromey@adacore.com>2023-10-02 12:37:25 -0600
commit8f11ec2d3c57f3fb41f968e19bec3d4d58359171 (patch)
treefc65c2d4fdeb6a30a64cf370bf31051d35946418 /gdb/testsuite/gdb.ada
parenta97875a518ef5f334e9bd4f1f0426e0eadf387ea (diff)
downloadbinutils-8f11ec2d3c57f3fb41f968e19bec3d4d58359171.zip
binutils-8f11ec2d3c57f3fb41f968e19bec3d4d58359171.tar.gz
binutils-8f11ec2d3c57f3fb41f968e19bec3d4d58359171.tar.bz2
Clean up intermediate values in val_print_packed_array_elements
Following on Tom de Vries' work in the other array-printers, this patch changes val_print_packed_array_elements to also avoid allocating too many values when printing an Ada packed array.
Diffstat (limited to 'gdb/testsuite/gdb.ada')
-rw-r--r--gdb/testsuite/gdb.ada/huge.exp72
-rw-r--r--gdb/testsuite/gdb.ada/huge/pck.adb6
2 files changed, 43 insertions, 35 deletions
diff --git a/gdb/testsuite/gdb.ada/huge.exp b/gdb/testsuite/gdb.ada/huge.exp
index 71b440e..7a2037a 100644
--- a/gdb/testsuite/gdb.ada/huge.exp
+++ b/gdb/testsuite/gdb.ada/huge.exp
@@ -48,45 +48,47 @@ for { set size $max } { $size >= $min } { set size [expr $size / 2] } {
}
require {expr $compilation_succeeded}
-clean_restart ${testfile}
+foreach_with_prefix varname {Arr Packed_Arr} {
+ clean_restart ${testfile}
-save_vars { timeout } {
- set timeout 30
+ save_vars { timeout } {
+ set timeout 30
- if {![runto "foo"]} {
- return
- }
+ if {![runto "foo"]} {
+ return
+ }
- gdb_test_no_output "set max-value-size unlimited"
- gdb_test_no_output "maint set per-command space on"
- set re1 \
- [list \
- [string_to_regexp $] \
- $decimal \
- " = " \
- [string_to_regexp "(0 <repeats "] \
- $decimal \
- [string_to_regexp " times>)"]]
- set re2 \
- [list \
- "Space used: $decimal" \
- [string_to_regexp " (+"] \
- "($decimal) for this command" \
- [string_to_regexp ")"]]
- set re [multi_line [join $re1 ""] [join $re2 ""]]
- set space_used -1
- gdb_test_multiple "print Arr" "print a very large data object" {
- -re -wrap $re {
- set space_used $expect_out(1,string)
- pass $gdb_test_name
+ gdb_test_no_output "set max-value-size unlimited"
+ gdb_test_no_output "maint set per-command space on"
+ set re1 \
+ [list \
+ [string_to_regexp $] \
+ $decimal \
+ " = " \
+ [string_to_regexp "(0 <repeats "] \
+ $decimal \
+ [string_to_regexp " times>)"]]
+ set re2 \
+ [list \
+ "Space used: $decimal" \
+ [string_to_regexp " (+"] \
+ "($decimal) for this command" \
+ [string_to_regexp ")"]]
+ set re [multi_line [join $re1 ""] [join $re2 ""]]
+ set space_used -1
+ gdb_test_multiple "print $varname" "print a very large data object" {
+ -re -wrap $re {
+ set space_used $expect_out(1,string)
+ pass $gdb_test_name
+ }
}
- }
- set test "not too much space used"
- if { $space_used == -1 } {
- unsupported $test
- } else {
- # At 56 passes with and without the fix, so use 55.
- gdb_assert {$space_used < [expr 55 * 4 * $size] } $test
+ set test "not too much space used"
+ if { $space_used == -1 } {
+ unsupported $test
+ } else {
+ # At 56 passes with and without the fix, so use 55.
+ gdb_assert {$space_used < [expr 55 * 4 * $size] } $test
+ }
}
}
diff --git a/gdb/testsuite/gdb.ada/huge/pck.adb b/gdb/testsuite/gdb.ada/huge/pck.adb
index 09988fb..47e6e92 100644
--- a/gdb/testsuite/gdb.ada/huge/pck.adb
+++ b/gdb/testsuite/gdb.ada/huge/pck.adb
@@ -14,6 +14,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
+ subtype Small_Int is Integer range 0 .. 7;
type My_Int is range -2147483648 .. 2147483647;
#if CRASHGDB = 16
@@ -75,6 +76,11 @@ package body Pck is
array (Index) of My_Int;
Arr : My_Int_Array := (others => 0);
+ type My_Packed_Array is array (Index) of Small_Int;
+ pragma Pack (My_Packed_Array);
+
+ Packed_Arr : My_Packed_Array := (others => 0);
+
procedure Foo is
begin
null;