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/>.
18 require allow_ada_tests
20 standard_ada_testfile foo
22 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \
23 [list debug ]] != "" } {
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}"
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,\
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,\
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.
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 gdb_test "print Large_1d_Array" \
77 "value of type `.*' requires $decimal bytes,\
78 which is more than max-value-size"
79 gdb_test "output Large_1d_Array" \
80 "value of type `.*' requires $decimal bytes,\
81 which is more than max-value-size"
82 gdb_test "print Large_3d_Array" \
83 "value of type `.*' requires $decimal bytes,\
84 which is more than max-value-size"
85 gdb_test "output Large_3d_Array" \
86 "value of type `.*' requires $decimal bytes,\
87 which is more than max-value-size"
90 with_test_prefix "with reduced print -elements flag" {
91 gdb_test "print -elements 2 -- Large_1d_Array" \
92 " = \\(1, 2\\.\\.\\.\\)"
93 gdb_test "print -elements 2 -- Large_3d_Array" \
94 " = \\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
95 \\(\\(17, 18\\.\\.\\.\\),\
96 \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)"
99 gdb_test_no_output "set print elements 2"
101 with_test_prefix "with reduced print elements" {
102 gdb_test "print Large_1d_Array" \
103 " = \\(1, 2\\.\\.\\.\\)"
104 gdb_test -nonl "output Large_1d_Array" \
105 "\\(1, 2\\.\\.\\.\\)"
107 gdb_test "print \$" \
108 " = \\(1, 2\\.\\.\\.\\)" \
109 "print Large_1d_Array from history"
110 gdb_test -nonl "output \$\$" \
111 "\\(1, 2\\.\\.\\.\\)" \
112 "output Large_1d_Array from history"
114 gdb_test "print Large_3d_Array" \
115 " = \\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
116 \\(\\(17, 18\\.\\.\\.\\),\
117 \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)"
118 gdb_test -nonl "output Large_3d_Array" \
119 "\\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
120 \\(\\(17, 18\\.\\.\\.\\),\
121 \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)"
123 gdb_test "print \$" \
124 " = \\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
125 \\(\\(17, 18\\.\\.\\.\\),\
126 \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)" \
127 "print Large_3d_Array from history"
128 gdb_test -nonl "output \$\$" \
129 "\\(\\(\\(1, 2\\.\\.\\.\\), \\(5, 6\\.\\.\\.\\)\\.\\.\\.\\),\
130 \\(\\(17, 18\\.\\.\\.\\),\
131 \\(21, 22\\.\\.\\.\\)\\.\\.\\.\\)\\.\\.\\.\\)" \
132 "output Large_3d_Array from history"
135 gdb_test_no_output "set print elements $elements"
137 with_test_prefix "with print elements matching max-value size" {
138 gdb_test "print \$\$2" \
139 " = \\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
140 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
141 25, 26, 27, 28, 29, 30, 31, 32, 33\\.\\.\\.\\)" \
142 "print Large_1d_Array from history"
143 gdb_test -nonl "output \$\$3" \
144 "\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
145 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
146 25, 26, 27, 28, 29, 30, 31, 32, 33\\.\\.\\.\\)" \
147 "output Large_1d_Array from history"
149 gdb_test "print \$\$2" \
150 " = \\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
151 \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
152 \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
153 \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
154 \\(\\(33(?:, <unavailable>)\{3\}\\)(?:,\
155 \\(<unavailable>(?:, <unavailable>)\{3\}\\))\{3\}\\),\
156 \\(\\(<unavailable>(?:, <unavailable>)\{3\}\\)(?:,\
157 \\(<unavailable>(?:, <unavailable>)\{3\}\\))\{3\}\\)\\)" \
158 "print Large_3d_Array from history"
159 gdb_test -nonl "output \$\$3" \
160 "\\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
161 \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
162 \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
163 \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
164 \\(\\(33(?:, <unavailable>)\{3\}\\)(?:,\
165 \\(<unavailable>(?:, <unavailable>)\{3\}\\))\{3\}\\),\
166 \\(\\(<unavailable>(?:, <unavailable>)\{3\}\\)(?:,\
167 \\(<unavailable>(?:, <unavailable>)\{3\}\\))\{3\}\\)\\)" \
168 "output Large_3d_Array from history"
171 gdb_test_no_output "set max-value-size unlimited"
172 gdb_test_no_output "set print elements unlimited"
173 gdb_test_no_output "set print repeats 2"
175 with_test_prefix "with unlimited print elements" {
176 gdb_test "print \$\$" \
177 " = \\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
178 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
179 25, 26, 27, 28, 29, 30, 31, 32, 33,\
180 <unavailable> <repeats 31 times>\\)" \
181 "print Large_1d_Array from history"
182 gdb_test -nonl "output \$\$2" \
183 "\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,\
184 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,\
185 25, 26, 27, 28, 29, 30, 31, 32, 33,\
186 <unavailable> <repeats 31 times>\\)" \
187 "output Large_1d_Array from history"
189 gdb_test "print \$\$" \
190 " = \\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
191 \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
192 \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
193 \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
194 \\(\\(33, <unavailable> <repeats 3 times>\\),\
195 \\(<unavailable> <repeats 4 times>\\) <repeats 3 times>\\),\
196 \\(\\(<unavailable> <repeats 4 times>\\)\
197 <repeats 4 times>\\)\\)" \
198 "print Large_3d_Array from history"
199 gdb_test -nonl "output \$\$2" \
200 "\\(\\(\\(1, 2, 3, 4\\), \\(5, 6, 7, 8\\),\
201 \\(9, 10, 11, 12\\), \\(13, 14, 15, 16\\)\\),\
202 \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
203 \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\),\
204 \\(\\(33, <unavailable> <repeats 3 times>\\),\
205 \\(<unavailable> <repeats 4 times>\\) <repeats 3 times>\\),\
206 \\(\\(<unavailable> <repeats 4 times>\\) <repeats 4 times>\\)\\)" \
207 "output Large_3d_Array from history"
209 gdb_test "print \$\[2\]" \
210 " = \\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
211 \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\)" \
212 "print available Large_3d_Array row from history"
213 gdb_test -nonl "output \$\$\[2\]" \
214 "\\(\\(17, 18, 19, 20\\), \\(21, 22, 23, 24\\),\
215 \\(25, 26, 27, 28\\), \\(29, 30, 31, 32\\)\\)" \
216 "output available Large_3d_Array row from history"
218 gdb_test "print \$\$\[3\]" \
219 " = \\(\\(33, <unavailable> <repeats 3 times>\\),\
220 \\(<unavailable> <repeats 4 times>\\) <repeats 3 times>\\)" \
221 "print partially available Large_3d_Array row from history"
222 gdb_test -nonl "output \$\$2\[3\]" \
223 "\\(\\(33, <unavailable> <repeats 3 times>\\),\
224 \\(<unavailable> <repeats 4 times>\\) <repeats 3 times>\\)" \
225 "output partially available Large_3d_Array row from history"
227 # These go straigth to the inferior.
228 gdb_test "print \$\$2(3)" \
229 " = \\(\\(33, 34, 35, 36\\), \\(37, 38, 39, 40\\),\
230 \\(41, 42, 43, 44\\), \\(45, 46, 47, 48\\)\\)" \
231 "print partially available Large_3d_Array row bypassing history"
232 gdb_test -nonl "output \$\$3(3)" \
233 "\\(\\(33, 34, 35, 36\\), \\(37, 38, 39, 40\\),\
234 \\(41, 42, 43, 44\\), \\(45, 46, 47, 48\\)\\)" \
235 "output partially available Large_3d_Array row bypassing history"
237 gdb_test "print \$\$3\[4\]" \
239 "print unavailable Large_3d_Array row from history"
240 gdb_test -nonl "output \$\$4\[4\]" \
242 "output unavailable Large_3d_Array row from history"
244 gdb_test "print \$\$4\[3\]\[1\]\[1\]" \
246 "print available Large_3d_Array element from history"
247 gdb_test -nonl "output \$\$5\[3\]\[1\]\[1\]" \
249 "output available Large_3d_Array element from history"
251 gdb_test "print \$\$5\[3\]\[1\]\[2\]" \
253 "print unavailable Large_3d_Array element from history"
254 gdb_test -nonl "output \$\$6\[3\]\[1\]\[2\]" \
256 "output unavailable Large_3d_Array element from history"
258 gdb_test "print \$\$6\[3\]\[1\]\[1\] + \$\$6\[3\]\[1\]\[2\]" \
259 "value is not available" \
260 "print expression referring unavailable element from history"
261 gdb_test "output \$\$6\[3\]\[1\]\[1\] + \$\$6\[3\]\[1\]\[2\]" \
262 "value is not available" \
263 "output expression referring unavailable element from history"