limited-length.exp revision 1.1 1 1.1 christos # Copyright 2023-2024 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos # This program is free software; you can redistribute it and/or modify
4 1.1 christos # it under the terms of the GNU General Public License as published by
5 1.1 christos # the Free Software Foundation; either version 3 of the License, or
6 1.1 christos # (at your option) any later version.
7 1.1 christos #
8 1.1 christos # This program is distributed in the hope that it will be useful,
9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 1.1 christos # GNU General Public License for more details.
12 1.1 christos #
13 1.1 christos # You should have received a copy of the GNU General Public License
14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 1.1 christos
16 1.1 christos # Test GDB's limited array printing.
17 1.1 christos
18 1.1 christos standard_testfile
19 1.1 christos
20 1.1 christos if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
21 1.1 christos return -1
22 1.1 christos }
23 1.1 christos
24 1.1 christos if {![runto_main]} {
25 1.1 christos perror "couldn't run to breakpoint"
26 1.1 christos continue
27 1.1 christos }
28 1.1 christos
29 1.1 christos with_test_prefix "with standard max-value size" {
30 1.1 christos gdb_test "print large_1d_array" \
31 1.1 christos " = \\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
32 1.1 christos 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
33 1.1 christos 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
34 1.1 christos 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
35 1.1 christos 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,\
36 1.1 christos 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,\
37 1.1 christos 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,\
38 1.1 christos 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,\
39 1.1 christos 96, 97, 98, 99\\\}"
40 1.1 christos gdb_test -nonl "output large_1d_array" \
41 1.1 christos "\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
42 1.1 christos 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
43 1.1 christos 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
44 1.1 christos 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
45 1.1 christos 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,\
46 1.1 christos 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,\
47 1.1 christos 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,\
48 1.1 christos 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,\
49 1.1 christos 96, 97, 98, 99\\\}"
50 1.1 christos gdb_test "print large_2d_array" \
51 1.1 christos " = \\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
52 1.1 christos \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
53 1.1 christos \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
54 1.1 christos \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
55 1.1 christos \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
56 1.1 christos \\\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59\\\},\
57 1.1 christos \\\{60, 61, 62, 63, 64, 65, 66, 67, 68, 69\\\},\
58 1.1 christos \\\{70, 71, 72, 73, 74, 75, 76, 77, 78, 79\\\},\
59 1.1 christos \\\{80, 81, 82, 83, 84, 85, 86, 87, 88, 89\\\},\
60 1.1 christos \\\{90, 91, 92, 93, 94, 95, 96, 97, 98, 99\\\}\\\}"
61 1.1 christos gdb_test -nonl "output large_2d_array" \
62 1.1 christos "\\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
63 1.1 christos \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
64 1.1 christos \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
65 1.1 christos \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
66 1.1 christos \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
67 1.1 christos \\\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59\\\},\
68 1.1 christos \\\{60, 61, 62, 63, 64, 65, 66, 67, 68, 69\\\},\
69 1.1 christos \\\{70, 71, 72, 73, 74, 75, 76, 77, 78, 79\\\},\
70 1.1 christos \\\{80, 81, 82, 83, 84, 85, 86, 87, 88, 89\\\},\
71 1.1 christos \\\{90, 91, 92, 93, 94, 95, 96, 97, 98, 99\\\}\\\}"
72 1.1 christos }
73 1.1 christos
74 1.1 christos # Set the max-value-size so we can only print 51 elements.
75 1.1 christos set elements 51
76 1.1 christos set int_size [get_valueof "/d" "sizeof(large_1d_array\[0\])" "*unknown*"]
77 1.1 christos gdb_test_no_output "set max-value-size [expr $int_size * $elements]"
78 1.1 christos
79 1.1 christos with_test_prefix "with reduced max-value size" {
80 1.1 christos gdb_test "print large_1d_array" \
81 1.1 christos "\r\nvalue requires $decimal bytes, which is more than max-value-size"
82 1.1 christos gdb_test "output large_1d_array" \
83 1.1 christos "\r\nvalue requires $decimal bytes, which is more than max-value-size"
84 1.1 christos gdb_test "print large_2d_array" \
85 1.1 christos "\r\nvalue requires $decimal bytes, which is more than max-value-size"
86 1.1 christos gdb_test "output large_2d_array" \
87 1.1 christos "\r\nvalue requires $decimal bytes, which is more than max-value-size"
88 1.1 christos }
89 1.1 christos
90 1.1 christos gdb_test_no_output "set print elements 3"
91 1.1 christos
92 1.1 christos with_test_prefix "with reduced print elements" {
93 1.1 christos gdb_test "print large_1d_array" \
94 1.1 christos " = \\\{0, 1, 2\\.\\.\\.\\\}"
95 1.1 christos gdb_test -nonl "output large_1d_array" \
96 1.1 christos "\\\{0, 1, 2\\.\\.\\.\\\}"
97 1.1 christos
98 1.1 christos gdb_test "print \$" \
99 1.1 christos " = \\\{0, 1, 2\\.\\.\\.\\\}" \
100 1.1 christos "print large_1d_array from history"
101 1.1 christos gdb_test -nonl "output \$\$" \
102 1.1 christos "\\\{0, 1, 2\\.\\.\\.\\\}" \
103 1.1 christos "output large_1d_array from history"
104 1.1 christos
105 1.1 christos gdb_test "print large_2d_array" \
106 1.1 christos " = \\\{\\\{0, 1, 2\\.\\.\\.\\\}, \\\{10, 11, 12\\.\\.\\.\\\},\
107 1.1 christos \\\{20, 21, 22\\.\\.\\.\\\}\\.\\.\\.\\\}"
108 1.1 christos gdb_test -nonl "output large_2d_array" \
109 1.1 christos "\\\{\\\{0, 1, 2\\.\\.\\.\\\}, \\\{10, 11, 12\\.\\.\\.\\\},\
110 1.1 christos \\\{20, 21, 22\\.\\.\\.\\\}\\.\\.\\.\\\}"
111 1.1 christos
112 1.1 christos gdb_test "print \$" \
113 1.1 christos " = \\\{\\\{0, 1, 2\\.\\.\\.\\\}, \\\{10, 11, 12\\.\\.\\.\\\},\
114 1.1 christos \\\{20, 21, 22\\.\\.\\.\\\}\\.\\.\\.\\\}" \
115 1.1 christos "print large_2d_array from history"
116 1.1 christos gdb_test -nonl "output \$\$" \
117 1.1 christos "\\\{\\\{0, 1, 2\\.\\.\\.\\\}, \\\{10, 11, 12\\.\\.\\.\\\},\
118 1.1 christos \\\{20, 21, 22\\.\\.\\.\\\}\\.\\.\\.\\\}" \
119 1.1 christos "output large_2d_array from history"
120 1.1 christos }
121 1.1 christos
122 1.1 christos gdb_test_no_output "set print elements $elements"
123 1.1 christos
124 1.1 christos with_test_prefix "with print elements matching max-value size" {
125 1.1 christos gdb_test "print \$\$2" \
126 1.1 christos " = \\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
127 1.1 christos 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
128 1.1 christos 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
129 1.1 christos 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
130 1.1 christos 48, 49, 50\\.\\.\\.\\\}" \
131 1.1 christos "print large_1d_array from history"
132 1.1 christos gdb_test -nonl "output \$\$3" \
133 1.1 christos "\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
134 1.1 christos 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
135 1.1 christos 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
136 1.1 christos 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
137 1.1 christos 48, 49, 50\\.\\.\\.\\\}" \
138 1.1 christos "output large_1d_array from history"
139 1.1 christos
140 1.1 christos gdb_test "print \$\$2" \
141 1.1 christos " = \\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
142 1.1 christos \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
143 1.1 christos \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
144 1.1 christos \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
145 1.1 christos \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
146 1.1 christos \\\{50(?:, <unavailable>)\{9\}\\\}(?:,\
147 1.1 christos \\\{<unavailable>(?:, <unavailable>)\{9\}\\\})\{4\}\\\}" \
148 1.1 christos "print large_2d_array from history"
149 1.1 christos gdb_test -nonl "output \$\$3" \
150 1.1 christos "\\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
151 1.1 christos \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
152 1.1 christos \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
153 1.1 christos \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
154 1.1 christos \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
155 1.1 christos \\\{50(?:, <unavailable>)\{9\}\\\}(?:,\
156 1.1 christos \\\{<unavailable>(?:, <unavailable>)\{9\}\\\})\{4\}\\\}" \
157 1.1 christos "output large_2d_array from history"
158 1.1 christos }
159 1.1 christos
160 1.1 christos gdb_test_no_output "set max-value-size unlimited"
161 1.1 christos gdb_test_no_output "set print elements unlimited"
162 1.1 christos gdb_test_no_output "set print repeats 3"
163 1.1 christos
164 1.1 christos with_test_prefix "with unlimited print elements" {
165 1.1 christos gdb_test "print \$\$" \
166 1.1 christos " = \\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
167 1.1 christos 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
168 1.1 christos 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
169 1.1 christos 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
170 1.1 christos 48, 49, 50, <unavailable> <repeats 49 times>\\\}" \
171 1.1 christos "print large_1d_array from history"
172 1.1 christos gdb_test -nonl "output \$\$2" \
173 1.1 christos "\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,\
174 1.1 christos 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,\
175 1.1 christos 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\
176 1.1 christos 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,\
177 1.1 christos 48, 49, 50, <unavailable> <repeats 49 times>\\\}" \
178 1.1 christos "output large_1d_array from history"
179 1.1 christos
180 1.1 christos gdb_test "print \$\$" \
181 1.1 christos " = \\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
182 1.1 christos \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
183 1.1 christos \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
184 1.1 christos \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
185 1.1 christos \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
186 1.1 christos \\\{50, <unavailable> <repeats 9 times>\\\},\
187 1.1 christos \\\{<unavailable> <repeats 10 times>\\\}\
188 1.1 christos <repeats 4 times>\\\}" \
189 1.1 christos "print large_2d_array from history"
190 1.1 christos gdb_test -nonl "output \$\$2" \
191 1.1 christos "\\\{\\\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\\\},\
192 1.1 christos \\\{10, 11, 12, 13, 14, 15, 16, 17, 18, 19\\\},\
193 1.1 christos \\\{20, 21, 22, 23, 24, 25, 26, 27, 28, 29\\\},\
194 1.1 christos \\\{30, 31, 32, 33, 34, 35, 36, 37, 38, 39\\\},\
195 1.1 christos \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\},\
196 1.1 christos \\\{50, <unavailable> <repeats 9 times>\\\},\
197 1.1 christos \\\{<unavailable> <repeats 10 times>\\\}\
198 1.1 christos <repeats 4 times>\\\}" \
199 1.1 christos "output large_2d_array from history"
200 1.1 christos
201 1.1 christos gdb_test "print \$\[4\]" \
202 1.1 christos " = \\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\}" \
203 1.1 christos "print available large_2d_array row from history"
204 1.1 christos gdb_test -nonl "output \$\$\[4\]" \
205 1.1 christos "\\\{40, 41, 42, 43, 44, 45, 46, 47, 48, 49\\\}" \
206 1.1 christos "output available large_2d_array row from history"
207 1.1 christos
208 1.1 christos gdb_test "print \$\$\[5\]" \
209 1.1 christos " = \\\{50, <unavailable> <repeats 9 times>\\\}" \
210 1.1 christos "print partially available large_2d_array row from history"
211 1.1 christos gdb_test -nonl "output \$\$2\[5\]" \
212 1.1 christos "\\\{50, <unavailable> <repeats 9 times>\\\}" \
213 1.1 christos "output partially available large_2d_array row from history"
214 1.1 christos
215 1.1 christos gdb_test "print \$\$2\[6\]" \
216 1.1 christos " = <unavailable>" \
217 1.1 christos "print unavailable large_2d_array row from history"
218 1.1 christos gdb_test -nonl "output \$\$3\[6\]" \
219 1.1 christos "<unavailable>" \
220 1.1 christos "output unavailable large_2d_array row from history"
221 1.1 christos
222 1.1 christos gdb_test "print \$\$3\[5\]\[0\]" \
223 1.1 christos " = 50" \
224 1.1 christos "print available large_2d_array element from history"
225 1.1 christos gdb_test -nonl "output \$\$4\[5\]\[0\]" \
226 1.1 christos "50" \
227 1.1 christos "output available large_2d_array element from history"
228 1.1 christos
229 1.1 christos gdb_test "print \$\$4\[5\]\[1\]" \
230 1.1 christos " = <unavailable>" \
231 1.1 christos "print unavailable large_2d_array element from history"
232 1.1 christos gdb_test -nonl "output \$\$5\[5\]\[1\]" \
233 1.1 christos "<unavailable>" \
234 1.1 christos "output unavailable large_2d_array element from history"
235 1.1 christos
236 1.1 christos gdb_test "print \$\$5\[5\]\[0\] + \$\$5\[5\]\[1\]" \
237 1.1 christos "value is not available" \
238 1.1 christos "print expression referring unavailable element from history"
239 1.1 christos gdb_test "output \$\$5\[5\]\[0\] + \$\$5\[5\]\[1\]" \
240 1.1 christos "value is not available" \
241 1.1 christos "output expression referring unavailable element from history"
242 1.1 christos }
243