]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/limited-length.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / limited-length.exp
CommitLineData
1d506c26 1# Copyright 2023-2024 Free Software Foundation, Inc.
a0c07915
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# Test GDB's limited array printing.
17
18standard_testfile
19
20if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
21 return -1
22}
23
24if {![runto_main]} {
25 perror "couldn't run to breakpoint"
26 continue
27}
28
29with_test_prefix "with standard max-value size" {
30 gdb_test "print large_1d_array" \
31 " = \\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
32 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
33 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
34 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
35 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,\
36 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,\
37 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,\
38 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,\
39 96, 97, 98, 99\\\}"
40 gdb_test -nonl "output large_1d_array" \
41 "\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
42 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
43 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
44 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
45 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,\
46 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,\
47 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,\
48 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,\
49 96, 97, 98, 99\\\}"
50 gdb_test "print large_2d_array" \
51 " = \\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
52 \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
53 \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
54 \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
55 \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
56 \\\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59\\\},\
57 \\\{60, 61, 62, 63, 64, 65, 66, 67, 68, 69\\\},\
58 \\\{70, 71, 72, 73, 74, 75, 76, 77, 78, 79\\\},\
59 \\\{80, 81, 82, 83, 84, 85, 86, 87, 88, 89\\\},\
60 \\\{90, 91, 92, 93, 94, 95, 96, 97, 98, 99\\\}\\\}"
61 gdb_test -nonl "output large_2d_array" \
62 "\\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
63 \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
64 \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
65 \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
66 \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
67 \\\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59\\\},\
68 \\\{60, 61, 62, 63, 64, 65, 66, 67, 68, 69\\\},\
69 \\\{70, 71, 72, 73, 74, 75, 76, 77, 78, 79\\\},\
70 \\\{80, 81, 82, 83, 84, 85, 86, 87, 88, 89\\\},\
71 \\\{90, 91, 92, 93, 94, 95, 96, 97, 98, 99\\\}\\\}"
72}
73
74# Set the max-value-size so we can only print 51 elements.
75set elements 51
76set int_size [get_valueof "/d" "sizeof(large_1d_array\[0\])" "*unknown*"]
77gdb_test_no_output "set max-value-size [expr $int_size * $elements]"
78
79with_test_prefix "with reduced max-value size" {
80 gdb_test "print large_1d_array" \
81 "\r\nvalue requires $decimal bytes, which is more than max-value-size"
82 gdb_test "output large_1d_array" \
83 "\r\nvalue requires $decimal bytes, which is more than max-value-size"
84 gdb_test "print large_2d_array" \
85 "\r\nvalue requires $decimal bytes, which is more than max-value-size"
86 gdb_test "output large_2d_array" \
87 "\r\nvalue requires $decimal bytes, which is more than max-value-size"
88}
89
90gdb_test_no_output "set print elements 3"
91
92with_test_prefix "with reduced print elements" {
93 gdb_test "print large_1d_array" \
94 " = \\\{0, 1, 2\\.\\.\\.\\\}"
95 gdb_test -nonl "output large_1d_array" \
96 "\\\{0, 1, 2\\.\\.\\.\\\}"
97
98 gdb_test "print \$" \
99 " = \\\{0, 1, 2\\.\\.\\.\\\}" \
100 "print large_1d_array from history"
101 gdb_test -nonl "output \$\$" \
102 "\\\{0, 1, 2\\.\\.\\.\\\}" \
103 "output large_1d_array from history"
104
105 gdb_test "print large_2d_array" \
106 " = \\\{\\\{0, 1, 2\\.\\.\\.\\\}, \\\{10, 11, 12\\.\\.\\.\\\},\
107 \\\{20, 21, 22\\.\\.\\.\\\}\\.\\.\\.\\\}"
108 gdb_test -nonl "output large_2d_array" \
109 "\\\{\\\{0, 1, 2\\.\\.\\.\\\}, \\\{10, 11, 12\\.\\.\\.\\\},\
110 \\\{20, 21, 22\\.\\.\\.\\\}\\.\\.\\.\\\}"
111
112 gdb_test "print \$" \
113 " = \\\{\\\{0, 1, 2\\.\\.\\.\\\}, \\\{10, 11, 12\\.\\.\\.\\\},\
114 \\\{20, 21, 22\\.\\.\\.\\\}\\.\\.\\.\\\}" \
115 "print large_2d_array from history"
116 gdb_test -nonl "output \$\$" \
117 "\\\{\\\{0, 1, 2\\.\\.\\.\\\}, \\\{10, 11, 12\\.\\.\\.\\\},\
118 \\\{20, 21, 22\\.\\.\\.\\\}\\.\\.\\.\\\}" \
119 "output large_2d_array from history"
120}
121
122gdb_test_no_output "set print elements $elements"
123
124with_test_prefix "with print elements matching max-value size" {
125 gdb_test "print \$\$2" \
126 " = \\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
127 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
128 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
129 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
130 48, 49, 50\\.\\.\\.\\\}" \
131 "print large_1d_array from history"
132 gdb_test -nonl "output \$\$3" \
133 "\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
134 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
135 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
136 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
137 48, 49, 50\\.\\.\\.\\\}" \
138 "output large_1d_array from history"
139
140 gdb_test "print \$\$2" \
141 " = \\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
142 \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
143 \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
144 \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
145 \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
146 \\\{50(?:, <unavailable>)\{9\}\\\}(?:,\
147 \\\{<unavailable>(?:, <unavailable>)\{9\}\\\})\{4\}\\\}" \
148 "print large_2d_array from history"
149 gdb_test -nonl "output \$\$3" \
150 "\\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
151 \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
152 \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
153 \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
154 \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
155 \\\{50(?:, <unavailable>)\{9\}\\\}(?:,\
156 \\\{<unavailable>(?:, <unavailable>)\{9\}\\\})\{4\}\\\}" \
157 "output large_2d_array from history"
158}
159
160gdb_test_no_output "set max-value-size unlimited"
161gdb_test_no_output "set print elements unlimited"
162gdb_test_no_output "set print repeats 3"
163
164with_test_prefix "with unlimited print elements" {
165 gdb_test "print \$\$" \
166 " = \\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
167 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
168 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
169 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
170 48, 49, 50, <unavailable> <repeats 49 times>\\\}" \
171 "print large_1d_array from history"
172 gdb_test -nonl "output \$\$2" \
173 "\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
174 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
175 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
176 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
177 48, 49, 50, <unavailable> <repeats 49 times>\\\}" \
178 "output large_1d_array from history"
179
180 gdb_test "print \$\$" \
181 " = \\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
182 \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
183 \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
184 \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
185 \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
186 \\\{50, <unavailable> <repeats 9 times>\\\},\
187 \\\{<unavailable> <repeats 10 times>\\\}\
188 <repeats 4 times>\\\}" \
189 "print large_2d_array from history"
190 gdb_test -nonl "output \$\$2" \
191 "\\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
192 \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
193 \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
194 \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
195 \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
196 \\\{50, <unavailable> <repeats 9 times>\\\},\
197 \\\{<unavailable> <repeats 10 times>\\\}\
198 <repeats 4 times>\\\}" \
199 "output large_2d_array from history"
200
201 gdb_test "print \$\[4\]" \
202 " = \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\}" \
203 "print available large_2d_array row from history"
204 gdb_test -nonl "output \$\$\[4\]" \
205 "\\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\}" \
206 "output available large_2d_array row from history"
207
208 gdb_test "print \$\$\[5\]" \
209 " = \\\{50, <unavailable> <repeats 9 times>\\\}" \
210 "print partially available large_2d_array row from history"
211 gdb_test -nonl "output \$\$2\[5\]" \
212 "\\\{50, <unavailable> <repeats 9 times>\\\}" \
213 "output partially available large_2d_array row from history"
214
215 gdb_test "print \$\$2\[6\]" \
216 " = <unavailable>" \
217 "print unavailable large_2d_array row from history"
218 gdb_test -nonl "output \$\$3\[6\]" \
219 "<unavailable>" \
220 "output unavailable large_2d_array row from history"
221
222 gdb_test "print \$\$3\[5\]\[0\]" \
223 " = 50" \
224 "print available large_2d_array element from history"
225 gdb_test -nonl "output \$\$4\[5\]\[0\]" \
226 "50" \
227 "output available large_2d_array element from history"
228
229 gdb_test "print \$\$4\[5\]\[1\]" \
230 " = <unavailable>" \
231 "print unavailable large_2d_array element from history"
232 gdb_test -nonl "output \$\$5\[5\]\[1\]" \
233 "<unavailable>" \
234 "output unavailable large_2d_array element from history"
235
236 gdb_test "print \$\$5\[5\]\[0\] + \$\$5\[5\]\[1\]" \
237 "value is not available" \
238 "print expression referring unavailable element from history"
239 gdb_test "output \$\$5\[5\]\[0\] + \$\$5\[5\]\[1\]" \
240 "value is not available" \
241 "output expression referring unavailable element from history"
242}