Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.ada / limited-length.exp
blobd0e912b79cfc1687a7f78a8e99d2538befa8f8e6
1 # Copyright 2023-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 load_lib "ada.exp"
18 require allow_ada_tests
20 standard_ada_testfile foo
22 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \
23         [list debug ]] != "" } {
24   return -1
27 clean_restart ${testfile}
29 set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
30 if {![runto "foo.adb:$bp_location"]} {
31     perror "Couldn't run ${testfile}"
32     return
35 with_test_prefix "with standard max-value size" {
36     gdb_test "print Large_1d_Array" \
37         " = \\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
38                13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
39                25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\
40                37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,\
41                49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,\
42                61, 62, 63, 64\\)"
43     gdb_test -nonl "output Large_1d_Array" \
44         "\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
45             13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
46             25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\
47             37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,\
48             49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,\
49             61, 62, 63, 64\\)"
50     gdb_test "print Large_3d_Array" \
51         " = \\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
52                   \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
53                \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
54                   \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
55                \\(\\(33, 34, 35, 36\\), \\(37, 38, 39, 40\\),\
56                   \\(41, 42, 43, 44\\), \\(45, 46, 47, 48\\)\\),\
57                \\(\\(49, 50, 51, 52\\), \\(53, 54, 55, 56\\),\
58                   \\(57, 58, 59, 60\\), \\(61, 62, 63, 64\\)\\)\\)"
59     gdb_test -nonl "output Large_3d_Array" \
60         "\\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
61                \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
62             \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
63                \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
64             \\(\\(33, 34, 35, 36\\), \\(37, 38, 39, 40\\),\
65                \\(41, 42, 43, 44\\), \\(45, 46, 47, 48\\)\\),\
66             \\(\\(49, 50, 51, 52\\), \\(53, 54, 55, 56\\),\
67                \\(57, 58, 59, 60\\), \\(61, 62, 63, 64\\)\\)\\)"
70 # Set the max-value-size so we can only print 33 elements.
71 set elements 33
72 set elem_size [get_valueof "/d" "(Large_1d_Array(1)'Size + 7) / 8" "*unknown*"]
73 gdb_test_no_output "set max-value-size [expr $elem_size * $elements]"
75 with_test_prefix "with reduced max-value size" {
76     # GNAT historically named this type, but as the array type is
77     # nameless, this accepts both variants.
78     set response \
79         "value (of type `.*' )?requires $decimal bytes, which is more than max-value-size"
81     gdb_test "print Large_1d_Array" $response
82     gdb_test "output Large_1d_Array" $response
83     gdb_test "print Large_3d_Array" $response
84     gdb_test "output Large_3d_Array" $response
87 with_test_prefix "with reduced print -elements flag" {
88     gdb_test "print -elements 2 -- Large_1d_Array" \
89         " = \\(1, 2\\.\\.\\.\\)"
90     gdb_test "print -elements 2 -- Large_3d_Array" \
91         " = \\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
92                \\(\\(17, 18\\.\\.\\.\\),\
93                   \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)"
96 gdb_test_no_output "set print elements 2"
98 with_test_prefix "with reduced print elements" {
99     gdb_test "print Large_1d_Array" \
100         " = \\(1, 2\\.\\.\\.\\)"
101     gdb_test -nonl "output Large_1d_Array" \
102         "\\(1, 2\\.\\.\\.\\)"
104     gdb_test "print \$" \
105         " = \\(1, 2\\.\\.\\.\\)" \
106         "print Large_1d_Array from history"
107     gdb_test -nonl "output \$\$" \
108         "\\(1, 2\\.\\.\\.\\)" \
109         "output Large_1d_Array from history"
111     gdb_test "print Large_3d_Array" \
112         " = \\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
113                \\(\\(17, 18\\.\\.\\.\\),\
114                   \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)"
115     gdb_test -nonl "output Large_3d_Array" \
116         "\\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
117             \\(\\(17, 18\\.\\.\\.\\),\
118                \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)"
120     gdb_test "print \$" \
121         " = \\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
122                \\(\\(17, 18\\.\\.\\.\\),\
123                   \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)" \
124         "print Large_3d_Array from history"
125     gdb_test -nonl "output \$\$" \
126         "\\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
127             \\(\\(17, 18\\.\\.\\.\\),\
128                \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)" \
129         "output Large_3d_Array from history"
132 gdb_test_no_output "set print elements $elements"
134 with_test_prefix "with print elements matching max-value size" {
135     gdb_test "print \$\$2" \
136         " = \\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
137                13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
138                25, 26, 27, 28, 29, 30, 31, 32, 33\\.\\.\\.\\)" \
139         "print Large_1d_Array from history"
140     gdb_test -nonl "output \$\$3" \
141         "\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
142             13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
143             25, 26, 27, 28, 29, 30, 31, 32, 33\\.\\.\\.\\)" \
144         "output Large_1d_Array from history"
146     gdb_test "print \$\$2" \
147         " = \\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
148                   \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
149                \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
150                   \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
151                \\(\\(33(?:, <unavailable>)\{3\}\\)(?:,\
152                   \\(<unavailable>(?:, <unavailable>)\{3\}\\))\{3\}\\),\
153                \\(\\(<unavailable>(?:, <unavailable>)\{3\}\\)(?:,\
154                   \\(<unavailable>(?:, <unavailable>)\{3\}\\))\{3\}\\)\\)" \
155         "print Large_3d_Array from history"
156     gdb_test -nonl "output \$\$3" \
157         "\\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
158                \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
159             \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
160                \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
161             \\(\\(33(?:, <unavailable>)\{3\}\\)(?:,\
162                \\(<unavailable>(?:, <unavailable>)\{3\}\\))\{3\}\\),\
163             \\(\\(<unavailable>(?:, <unavailable>)\{3\}\\)(?:,\
164                \\(<unavailable>(?:, <unavailable>)\{3\}\\))\{3\}\\)\\)" \
165         "output Large_3d_Array from history"
168 gdb_test_no_output "set max-value-size unlimited"
169 gdb_test_no_output "set print elements unlimited"
170 gdb_test_no_output "set print repeats 2"
172 with_test_prefix "with unlimited print elements" {
173     gdb_test "print \$\$" \
174         " = \\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
175                13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
176                25, 26, 27, 28, 29, 30, 31, 32, 33,\
177                <unavailable> <repeats 31 times>\\)" \
178         "print Large_1d_Array from history"
179     gdb_test -nonl "output \$\$2" \
180         "\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
181             13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
182             25, 26, 27, 28, 29, 30, 31, 32, 33,\
183             <unavailable> <repeats 31 times>\\)" \
184         "output Large_1d_Array from history"
186     gdb_test "print \$\$" \
187         " = \\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
188                   \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
189                \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
190                   \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
191                \\(\\(33, <unavailable> <repeats 3 times>\\),\
192                   \\(<unavailable> <repeats 4 times>\\) <repeats 3 times>\\),\
193                \\(\\(<unavailable> <repeats 4 times>\\)\
194                   <repeats 4 times>\\)\\)" \
195         "print Large_3d_Array from history"
196     gdb_test -nonl "output \$\$2" \
197         "\\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
198                \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
199             \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
200                \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
201             \\(\\(33, <unavailable> <repeats 3 times>\\),\
202                \\(<unavailable> <repeats 4 times>\\) <repeats 3 times>\\),\
203             \\(\\(<unavailable> <repeats 4 times>\\) <repeats 4 times>\\)\\)" \
204         "output Large_3d_Array from history"
206     gdb_test "print \$\[2\]" \
207         " = \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
208                \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\)" \
209         "print available Large_3d_Array row from history"
210     gdb_test -nonl "output \$\$\[2\]" \
211         "\\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
212             \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\)" \
213         "output available Large_3d_Array row from history"
215     gdb_test "print \$\$\[3\]" \
216         " = \\(\\(33, <unavailable> <repeats 3 times>\\),\
217                \\(<unavailable> <repeats 4 times>\\) <repeats 3 times>\\)" \
218         "print partially available Large_3d_Array row from history"
219     gdb_test -nonl "output \$\$2\[3\]" \
220         "\\(\\(33, <unavailable> <repeats 3 times>\\),\
221             \\(<unavailable> <repeats 4 times>\\) <repeats 3 times>\\)" \
222         "output partially available Large_3d_Array row from history"
224     # These go straigth to the inferior.
225     gdb_test "print \$\$2(3)" \
226         " = \\(\\(33, 34, 35, 36\\), \\(37, 38, 39, 40\\),\
227                \\(41, 42, 43, 44\\), \\(45, 46, 47, 48\\)\\)" \
228         "print partially available Large_3d_Array row bypassing history"
229     gdb_test -nonl "output \$\$3(3)" \
230         "\\(\\(33, 34, 35, 36\\), \\(37, 38, 39, 40\\),\
231             \\(41, 42, 43, 44\\), \\(45, 46, 47, 48\\)\\)" \
232         "output partially available Large_3d_Array row bypassing history"
234     gdb_test "print \$\$3\[4\]" \
235         " = <unavailable>" \
236         "print unavailable Large_3d_Array row from history"
237     gdb_test -nonl "output \$\$4\[4\]" \
238         "<unavailable>" \
239         "output unavailable Large_3d_Array row from history"
241     gdb_test "print \$\$4\[3\]\[1\]\[1\]" \
242         " = 33" \
243         "print available Large_3d_Array element from history"
244     gdb_test -nonl "output \$\$5\[3\]\[1\]\[1\]" \
245         "33" \
246         "output available Large_3d_Array element from history"
248     gdb_test "print \$\$5\[3\]\[1\]\[2\]" \
249         " = <unavailable>" \
250         "print unavailable Large_3d_Array element from history"
251     gdb_test -nonl "output \$\$6\[3\]\[1\]\[2\]" \
252         "<unavailable>" \
253         "output unavailable Large_3d_Array element from history"
255     gdb_test "print \$\$6\[3\]\[1\]\[1\] + \$\$6\[3\]\[1\]\[2\]" \
256         "value is not available" \
257         "print expression referring unavailable element from history"
258     gdb_test "output \$\$6\[3\]\[1\]\[1\] + \$\$6\[3\]\[1\]\[2\]" \
259         "value is not available" \
260         "output expression referring unavailable element from history"