]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2016-2024 Free Software Foundation, Inc. |
5fdf6324 AB |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | standard_testfile | |
17 | ||
5b362f04 | 18 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { |
5fdf6324 AB |
19 | return -1 |
20 | } | |
21 | ||
65a33d75 | 22 | if {![runto_main]} { |
5fdf6324 AB |
23 | return 0 |
24 | } | |
25 | ||
26 | # Run "show max-value-size" and return the interesting bit of the | |
27 | # result. This is either the maximum size in bytes, or the string | |
28 | # "unlimited". | |
29 | proc get_max_value_size {} { | |
30 | global gdb_prompt | |
31 | global decimal | |
32 | ||
33 | gdb_test_multiple "show max-value-size" "" { | |
34 | -re "Maximum value size is ($decimal) bytes.*$gdb_prompt $" { | |
35 | return $expect_out(1,string) | |
36 | } | |
37 | -re "Maximum value size is unlimited.*$gdb_prompt $" { | |
38 | return "unlimited" | |
39 | } | |
40 | } | |
41 | } | |
42 | ||
43 | # Assuming that MAX_VALUE_SIZE is the current value for | |
44 | # max-value-size, print the test values. Use TEST_PREFIX to make the | |
45 | # test names unique. | |
46 | proc do_value_printing { max_value_size test_prefix } { | |
47 | with_test_prefix ${test_prefix} { | |
48 | gdb_test "p/d one" " = 0" | |
65a33d75 | 49 | if {$max_value_size != "unlimited" && $max_value_size < 100} { |
5fdf6324 AB |
50 | gdb_test "p/d one_hundred" \ |
51 | "value requires 100 bytes, which is more than max-value-size" | |
52 | } else { | |
53 | gdb_test "p/d one_hundred" " = \\{0 <repeats 100 times>\\}" | |
54 | } | |
55 | gdb_test "p/d one_hundred \[99\]" " = 0" | |
bae19789 MR |
56 | # Verify that accessing value history is undisturbed. |
57 | gdb_test "p/d \$2" " = \\{0 <repeats 100 times>\\}" | |
58 | gdb_test "p/d \$2 \[99\]" " = 0" | |
5fdf6324 AB |
59 | } |
60 | } | |
61 | ||
62 | # Install SET_VALUE as the value for max-value-size, then print the | |
63 | # test values. | |
64 | proc set_and_check_max_value_size { set_value } { | |
65a33d75 | 65 | if {$set_value == "unlimited"} { |
5fdf6324 AB |
66 | set check_pattern "unlimited" |
67 | } else { | |
68 | set check_pattern "${set_value} bytes" | |
69 | } | |
70 | ||
71 | gdb_test_no_output "set max-value-size ${set_value}" | |
72 | gdb_test "show max-value-size" \ | |
73 | "Maximum value size is ${check_pattern}." \ | |
74 | "check that the value shows as ${check_pattern}" | |
75 | ||
76 | do_value_printing ${set_value} "max-value-size is '${set_value}'" | |
77 | } | |
78 | ||
79 | # Check the default value is sufficient. | |
80 | do_value_printing [get_max_value_size] "using initial max-value-size" | |
81 | ||
82 | # Check some values for max-value-size that should prevent some | |
83 | # allocations. | |
84 | set_and_check_max_value_size 25 | |
85 | set_and_check_max_value_size 99 | |
86 | ||
87 | # Check values for max-value-size that should allow all allocations. | |
88 | set_and_check_max_value_size 100 | |
89 | set_and_check_max_value_size 200 | |
90 | set_and_check_max_value_size "unlimited" | |
91 | ||
92 | # Check that we can't set the maximum size stupidly low. | |
93 | gdb_test "set max-value-size 1" \ | |
94 | "max-value-size set too low, increasing to \[0-9\]+ bytes" | |
95 | gdb_test "set max-value-size 0" \ | |
96 | "max-value-size set too low, increasing to \[0-9\]+ bytes" | |
97 | gdb_test "set max-value-size -5" \ | |
7aeb03e2 | 98 | "integer -5 out of range" |