Remove path name from test case
[binutils-gdb.git] / gdb / testsuite / gdb.base / call-ar-st.exp
1 # Copyright 1998-2023 Free Software Foundation, Inc.
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 # This file was written by Elena Zannoni (ezannoni@cygnus.com)
17
18
19
20 standard_testfile
21
22 # Some targets can't call functions, so don't even bother with this
23 # test.
24 require {!target_info exists gdb,cannot_call_functions}
25
26 # Create and source the file that provides information about the compiler
27 # used to compile the test case.
28
29 set allow_float_test [allow_float_test]
30
31 set flags {}
32 lappend flags debug
33 lappend_include_file flags $srcdir/lib/unbuffer_output.c
34
35 if {[prepare_for_testing "failed to prepare" $testfile $srcfile $flags]} {
36 return -1
37 }
38
39
40 set oldtimeout $timeout
41 set timeout [expr "$timeout + 60"]
42
43 gdb_test_no_output "set print sevenbit-strings"
44 gdb_test_no_output "set print address off"
45 gdb_test_no_output "set width 0"
46
47
48 if {![runto_main]} {
49 return
50 }
51
52 get_debug_format
53
54 set stop_line [gdb_get_line_number "-tbreak1-"]
55 gdb_test "tbreak $stop_line" \
56 "Temporary breakpoint ${decimal}.*file.*$srcfile, line $stop_line.*" \
57 "tbreakpoint at tbreak1"
58
59 gdb_test continue \
60 "Continuing\\..*main \\(\\) at.*$srcfile:$stop_line.*" \
61 "run until breakpoint set at a line"
62
63
64 #call print_double_array(double_array)
65 if {$allow_float_test && \
66 ![gdb_skip_stdio_test "print print_double_array(double_array)"] } {
67
68 gdb_test_stdio "print print_double_array(double_array)" \
69 [multi_line \
70 "array_d :" \
71 "=========" \
72 "" \
73 "0.000000 *" \
74 "23.456\[0-9\]* 46.913\[0-9\]* 70.370\[0-9\]* 93.826\[0-9\]* 117.283\[0-9\]* 140.740\[0-9\]* 164.196\[0-9\]* 187.653\[0-9\]"]
75 }
76
77 #call print_char_array(char_array)
78
79 set array_c_re \
80 [multi_line \
81 "array_c :" \
82 "=========" \
83 "" \
84 "Z" \
85 "aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \
86 "aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ" \
87 "aZaZaZaZaZaZaZaZaZa"]
88
89 if ![gdb_skip_stdio_test "print_char_array(char_array)"] {
90 gdb_test_stdio "print print_char_array(char_array)" $array_c_re
91 }
92
93 set stop_line [gdb_get_line_number "-tbreak2-"]
94 gdb_test "tbreak $stop_line" \
95 "Temporary breakpoint.*file.*$srcfile, line $stop_line.*" \
96 "tbreakpoint at tbreak2"
97
98 if ![gdb_skip_stdio_test "continue to tbreak2"] {
99 set gdb_re \
100 [multi_line \
101 "main.*at.*:\[0-9\]+" \
102 "\[0-9\]+.*print_double_array\\(double_array\\).*"]
103 gdb_test_stdio "continue" $array_c_re $gdb_re "continue to tbreak2"
104 } else {
105 gdb_test "continue" ".*" ""
106 }
107
108 # I am disabling this test, because it takes too long. I verified by
109 # hand that it works, feel free to check for yourself.
110 #call print_all_arrays(integer_array, char_array, float_array, double_array)
111 #send_gdb "print print_all_arrays(integer_array, char_array, float_array, double_array)\n"
112 #gdb_expect {
113 # -re ".*array_i :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+0\[ \t\r\n\]+-1 -2 -3 -4 -5 -6 -7 -8\[ \t\r\n\]+-9 -10 -11 -12 -13 -14 -15 -16\[ \t\r\n\]+-17 -18 -19 -20 -21 -22 -23 -24\[ \t\r\n\]+-25 -26 -27 -28 -29 -30 -31 -32\[ \t\r\n\]+-33 -34 -35 -36 -37 -38 -39 -40\[ \t\r\n\]+-41 -42 -43 -44 -45 -46 -47 -48\[ \t\r\n\]+-49\[ \t\r\n\]+\[ \t\r\n\]+array_c :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+Z\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ\[ \t\r\n\]+aZaZaZaZaZaZaZaZaZa\[ \t\r\n\]+\[ \t\r\n\]+array_f :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+0.000000\[ \t\r\n\]+0.142450 0.284900 0.427350 0.569801 0.712251 0.854701 0.997151 1.139601\[ \t\r\n\]+1.282051 1.424501 1.566952 1.709402 1.851852 1.994302\[ \t\r\n\]+\[ \t\r\n\]+array_d :\[ \t\r\n\]+=========\[ \t\r\n\]+\[ \t\r\n\]+0.000000\[ \t\r\n\]+23.456700 46.913400 70.370100 93.826800 117.283500 140.740200 164.196900 187.653600\[ \t\r\n\]+211.110300 234.567000 258.023700 281.480400 304.937100 328.393800 351.850500 375.307200\[ \t\r\n\]+398.763900 422.220600 445.677300 469.134000 492.590700 516.047400 539.504100 562.960800\[ \t\r\n\]+586.41750 609.874200 633.330900 656.787600 680.244300 703.701000 727.157700 750.614400\[ \t\r\n\]+774.071100 797.527800 820.984500 844.441200 867.897900 891.354600 914.811300 938.268000\[ \t\r\n\]+961.724700 985.181400 1008.638100 1032.094800 1055.551500 1079.008200 1102.464900 1125.921600\[ \t\r\n\]+1149.378300 1172.835000 1196.291700 1219.748400 1243.205100 1266.661800 1290.118500 1313.575200\[ \t\r\n\]+1337.031900 1360.488600 1383.945300 1407.402000 1430.858700 1454.315400 1477.772100 1501.228800\[ \t\r\n\]+1524.685500 1548.142200 1571.598900 1595.055600 1618.512300 1641.969000 1665.425700 1688.882400\[ \t\r\n\]+1712.339100 1735.795800 1759.252500 1782.709200 1806.165900 1829.622600 1853.079300 1876.536000\[ \t\r\n\]+1899.992700 1923.449400 1946.906100 1970.362800 1993.819500 2017.276200 2040.732900 2064.189600\[ \t\r\n\]+2087.646300 2111.103000 2134.559700 2158.016400 2181.473100 2204.929800 2228.386500 2251.843200\[ \t\r\n\]+2275.299900 2298.756600 2322.213300.*$gdb_prompt $" {
114 # pass "print print_all_arrays(integer_array, char_array, float_array, double_array)"
115 # }
116 # -re ".*$gdb_prompt $" { fail "print print_all_arrays(integer_array, char_array, float_array, double_array)" }
117 # timeout { fail "(timeout) print print_all_arrays(integer_array, char_array, float_array, double_array)" }
118 # }
119
120 #set timeout $oldtimeout
121 set stop_line [gdb_get_line_number "-tbreak3-"]
122 gdb_test "tbreak $stop_line" \
123 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
124 "tbreakpoint at tbreak3"
125
126 if {$allow_float_test && \
127 ![gdb_skip_stdio_test "continuing to tbreak3"] } {
128
129 gdb_test_stdio "continue" \
130 [multi_line \
131 "array_d :" \
132 "=========" \
133 "" \
134 "0.000000 *" \
135 "23.456\[0-9\]* 46.913\[0-9\]* 70.370\[0-9\]* 93.826\[0-9\]* 117.283\[0-9\]* 140.740\[0-9\]* 164.196\[0-9\]* 187.653\[0-9\]* *" \
136 "" \
137 "" \
138 "array_f :" \
139 ".*" \
140 "student id :\[\t \]+.*YELLOW" \
141 "array_i :" \
142 ] \
143 "main \\(\\) at .*call-ar-st.c:\[0-9\]+\[ \t\r\n\]+.*print_all_arrays\\(integer_array, char_array, float_array, double_array\\)..*" \
144 "continuing to tbreak3"
145
146 } else {
147 gdb_test "continue" ".*" ""
148 }
149
150 # Return a regexp that matches the linkage name of SYM, assuming SYM
151 # is a local static variable inside the main function.
152 proc main_static_local_re {sym} {
153 # Clang prepends the function name + '.'.
154 return "(main\\.)?${sym}"
155 }
156
157 #step
158 set stop_line [gdb_get_line_number "-step1-"]
159 gdb_test "step" \
160 "print_all_arrays \\(array_i=<[main_static_local_re integer_array]>,\
161 array_c=<[main_static_local_re char_array]> .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa.,\
162 array_f=<[main_static_local_re float_array]>,\
163 array_d=<[main_static_local_re double_array]>\\)\
164 at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(array_i\\);.*" \
165 "step inside print_all_arrays"
166
167 #step -over
168 if ![gdb_skip_stdio_test "next over print_int_array in print_all_arrays"] {
169 set stop_line [gdb_get_line_number "-next1-"]
170 gdb_test_stdio "next" \
171 "array_i :" \
172 "$stop_line.*print_char_array.*" \
173 "next over print_int_array in print-all_arrays"
174 } else {
175 gdb_test "next" ".*" ""
176 }
177
178 #call print_double_array(array_d)
179 if {$allow_float_test && \
180 ![gdb_skip_stdio_test "print print_double_array(array_d)"] } {
181
182 gdb_test_stdio "print print_double_array(array_d)" \
183 [multi_line \
184 "array_d :" \
185 "=========" \
186 "" \
187 "0.000000 *" \
188 "23.456\[0-9\]* 46.913\[0-9\]* 70.370\[0-9\]* 93.826\[0-9\]* 117.283\[0-9\]* 140.740\[0-9\]* 164.196\[0-9\]* 187.653\[0-9\]*" \
189 ]
190 }
191
192 set stop_line [gdb_get_line_number "-tbreak4-"]
193 gdb_test "tbreak $stop_line" \
194 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
195 "tbreakpoint at tbreak4"
196
197 if {$allow_float_test && \
198 ![gdb_skip_stdio_test "continuing to tbreak4"] } {
199
200 gdb_test_stdio "continue" \
201 [multi_line \
202 "array_d :" \
203 "=========" \
204 "" \
205 "0.000000 *" \
206 "23.456\[0-9\]* 46.913\[0-9\]* 70.370\[0-9\]* 93.826\[0-9\]* 117.283\[0-9\]* 140.740\[0-9\]* 164.196\[0-9\]* 187.653\[0-9\]*" \
207 ] \
208 "" \
209 "continuing to tbreak4"
210 } else {
211 gdb_test "continue" ".*" ""
212 }
213
214
215 #call sum_array_print(10, *list1, *list2, *list3, *list4)
216
217 if ![gdb_skip_stdio_test "print sum_array_print(...)"] {
218
219 gdb_test_stdio "print sum_array_print(10, *list1, *list2, *list3, *list4)" \
220 [multi_line \
221 "Sum of 4 arrays, by element \\(add in seed as well\\): " \
222 "" \
223 "Seed: 10" \
224 "Element Index . Sum " \
225 "-------------------------" \
226 ".*" \
227 "\[ \t\]+0\[ \t\]+52" \
228 "\[ \t\]+1\[ \t\]+60" \
229 "\[ \t\]+2\[ \t\]+68" \
230 "\[ \t\]+3\[ \t\]+76" \
231 "\[ \t\]+4\[ \t\]+84" \
232 "\[ \t\]+5\[ \t\]+92" \
233 "\[ \t\]+6\[ \t\]+100" \
234 "\[ \t\]+7\[ \t\]+108" \
235 "\[ \t\]+8\[ \t\]+116" \
236 "\[ \t\]+9\[ \t\]+124" \
237 ]
238 }
239
240 #step over
241 set stop_line [gdb_get_line_number "-next2-"]
242 if ![gdb_skip_stdio_test "next to next2"] {
243 gdb_test_stdio "next" \
244 "BYE BYE FOR NOW" \
245 "$stop_line.*printf\\(.VERY GREEN GRASS.n.\\);.*" \
246 "next to next2"
247 } else {
248 gdb_test "next" ".*" ""
249 }
250
251 #call print_array_rep(\*list1, \*list2, \*list3)
252
253 if ![gdb_skip_stdio_test "print print_array_rep(...)"] {
254 gdb_test_stdio "print print_array_rep(\*list1, \*list2, \*list3)" \
255 "Contents of linked list3:"
256 }
257
258 set stop_line [gdb_get_line_number "-tbreak5-"]
259 gdb_test "tbreak $stop_line" \
260 "Temporary breakpoint..* file .*$srcfile, line $stop_line.*" \
261 "tbreakpoint at tbreak5"
262
263 gdb_test "continue" \
264 "main \\(\\) at .*$srcfile:$stop_line\r\n$stop_line\[\t \]+sum_array_print\\(10, \\*list1, \\*list2, \\*list3, \\*list4\\);.*" \
265 "continue to tbreak5"
266
267
268 # Run into sum_array_print, and verify that the arguments were passed
269 # accurately.
270 #
271 # Note that we shouldn't use a `step' here to get into
272 # sum_array_print; GCC may emit calls to memcpy to put the arguments
273 # in the right place, and a step may end up in memcpy instead. This
274 # may itself be a bug, but it's not the one we're trying to catch
275 # here. I've added something to step-test.exp for this.
276 gdb_test "break sum_array_print" \
277 ".*Breakpoint ${decimal}: file .*$srcfile, line.*" \
278 "set breakpoint in sum_array_print"
279 gdb_test_no_output "set print frame-arguments all"
280 gdb_test "continue" \
281 ".*Breakpoint ${decimal}, sum_array_print \\(seed=10, linked_list1=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .4, 6, 8, 10, 12, 14, 16, 18, 20, 22., head = 0., linked_list2=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .8, 10, 12, 14, 16, 18, 20, 22, 24, 26., head = 0., linked_list3=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .10, 12, 14, 16, 18, 20, 22, 24, 26, 28., head = 0., linked_list4=.next_index = .1, 2, 3, 4, 5, 6, 7, 8, 9, 10., values = .20, 22, 24, 26, 28, 30, 32, 34, 36, 38., head = 0.\\) at .*$srcfile:${decimal}\[ \t\n\r\]+${decimal}.*printf\\(.Sum of 4 arrays, by element \\(add in seed as well\\).*\\);.*" \
282 "check args of sum_array_print"
283
284 #call print_array_rep(linked_list1, linked_list2, linked_list3)
285 # this calls works from gdb without gdb_expect. But it does seem to hang
286 #from within gdb_expect.
287 #I comment this out
288 #send_gdb "print print_array_rep(linked_list1, linked_list2, linked_list3)\n"
289 #gdb_expect {
290 # -re ".*Contents of linked list1:\[ \t\n\r\]+Element Value . Index of Next Element\[ \t\n\r\]+-------------------------------------\[ \t\n\r\]+.*\[ \t\n\r\]+.*4.*1\[ \t\n\r\]+.*6.*2\[ \t\n\r\]+.*8.*3\[ \t\n\r\]+.*10.*4\[ \t\n\r\]+.*12.*5\[ \t\n\r\]+.*14.*6\[ \t\n\r\]+.*16.*7\[ \t\n\r\]+.*18.*8\[ \t\n\r\]+.*20.*9\[ \t\n\r\]+.*22.*10\[ \t\n\r\]+Contents of linked list2:\[ \t\n\r\]+Element Value | Index of Next Element\[ \t\n\r\]+-------------------------------------\[ \t\n\r\]+.*\[ \t\n\r\]+.*8.*1\[ \t\n\r\]+.*10.*2\[ \t\n\r\]+.*12.*3\[ \t\n\r\]+.*14.*4\[ \t\n\r\]+.*16.*5\[ \t\n\r\]+.*18.*6\[ \t\n\r\]+.*20.*7\[ \t\n\r\]+.*22.*8\[ \t\n\r\]+.*24.*9\[ \t\n\r\]+.*26.*10\[ \t\n\r\]+Contents of linked list3:\[ \t\n\r\]+Element Value | Index of Next Element\[ \t\n\r\]+-------------------------------------\[ \t\n\r\]+.*\[ \t\n\r\]+.*10.*1\[ \t\n\r\]+.*12.*2\[ \t\n\r\]+.*14.*3\[ \t\n\r\]+.*16.*4\[ \t\n\r\]+.*18.*5\[ \t\n\r\]+.*20.*6\[ \t\n\r\]+.*22.*7\[ \t\n\r\]+.*24.*8\[ \t\n\r\]+.*26.*9\[ \t\n\r\]+.*28.*10\[ \t\n\r\]+.*$gdb_prompt $" {
291 # pass "print print_array_rep(linked_list1, linked_list2, linked_list3)"
292 # }
293 # -re ".*$gdb_prompt $" { fail "print print_array_rep(linked_list1, linked_list2, linked_list3)" }
294 # timeout { fail "(timeout) print print_array_rep(linked_list1, linked_list2, linked_list3)" }
295 #}
296
297
298 set stop_line [gdb_get_line_number "-tbreak6-"]
299 gdb_test "tbreak $stop_line" \
300 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
301 "tbreakpoint at tbreak6"
302
303 if ![gdb_skip_stdio_test "continuing to tbreak6"] {
304 gdb_test_stdio "continue" \
305 "Sum of 4 arrays.*Contents of linked list1.*Contents of two_floats_t" \
306 "main \\(\\) at .*$srcfile:$stop_line.*c = 0.*" \
307 "continue to tbreak6"
308 } else {
309 gdb_test "continue" ".*" ""
310 }
311
312 #call print_small_structs(*struct1, *struct2, *struct3, *struct4,
313 # *flags, *flags_combo, *three_char, *five_char,
314 # *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)
315
316 if {$allow_float_test && \
317 ![gdb_skip_stdio_test "print print_small_structs(...)"] } {
318 gdb_test_stdio "print print_small_structs(*struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)" \
319 [multi_line \
320 "alpha" \
321 "gamma" \
322 "epsilon" \
323 "alpha" \
324 "gamma" \
325 "epsilon" \
326 "ch1: y\[ \t\]*ch2: n" \
327 "Contents of three_char_t: " \
328 "" \
329 "a\[ \t\]*b\[ \t\]*c" \
330 "Contents of five_char_t: " \
331 "" \
332 "l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p" \
333 "Contents of int_char_combo_t: " \
334 "" \
335 "123\[ \t\]*z" \
336 "Sum of the 4 struct values and seed : " \
337 "" \
338 "\[ \t\]*52" \
339 "Contents of struct1: " \
340 "" \
341 "\[ \t\]*6\[ \t\]*0" \
342 "Contents of struct2: " \
343 "" \
344 "\[ \t\]*10\[ \t\]*0" \
345 "Contents of struct3: " \
346 "" \
347 "\[ \t\]*12\[ \t\]*0" \
348 "Contents of one_double_t: " \
349 "" \
350 "10.500000" \
351 "Contents of one_double_t: " \
352 "" \
353 "-3.375000" \
354 "Contents of one_double_t: " \
355 "" \
356 "675.093750" \
357 "Contents of two_floats_t: " \
358 "" \
359 "\[ \t\]*45.234001\[ \t\]*43.599998" \
360 "Contents of two_floats_t: " \
361 "" \
362 "\[ \t\]*78.010002\[ \t\]*122.099998" \
363 "Contents of two_floats_t: " \
364 "" \
365 "-1232.344971\[ \t\]*-199.210007" \
366 ] \
367 "" \
368 "print print_small_structs"
369 }
370
371 #call compute_with_small_structs(20)
372 gdb_test "print compute_with_small_structs(20)" \
373 "\[0-9\]+ = void"
374
375
376 #call print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098,
377 # 3.14, -5678.12345, -0.11111111, 216.97065)
378
379 if {$allow_float_test && \
380 ![gdb_skip_stdio_test "print print_ten_doubles(...)"]} {
381 gdb_test_stdio "print print_ten_doubles(123.456, 123.456, -0.12, -1.23, 343434.8, 89.098, 3.14, -5678.12345, -0.11111111, 216.97065)" \
382 [multi_line \
383 "Two Doubles : 123.45\[0-9\]*.*123.45\[0-9\]*" \
384 "Two Doubles : -0.1200\[0-9\]*.*-1.2300\[0-9\]*" \
385 "Two Doubles : 343434.\[0-9\]*.*89.09\[0-9\]*" \
386 "Two Doubles : 3.1400\[0-9\]*.*-5678.123\[0-9\]*" \
387 "Two Doubles : -0.1111\[0-9\]*.*216.97\[0-9\]*" \
388 ]
389 }
390
391 set stop_line [gdb_get_line_number "-tbreak7-"]
392 gdb_test "tbreak $stop_line" \
393 "Temporary breakpoint .* file .*$srcfile, line $stop_line.*" \
394 "tbreakpoint at tbreak7"
395
396 gdb_test continue "Continuing\\..*main \\(.*\\) at.*$srcfile:$stop_line\[\t\r\n \]+$stop_line.*print_long_arg_list \\( a, b, c, d, e, f, .struct1, .struct2, .struct3, .struct4,.*" "continue to tbreak7"
397
398 set stop_line [gdb_get_line_number "-step2-"]
399 # We can't just assume that a "step" will get us into
400 # print_long_arg_list here,either.
401 gdb_test "tbreak print_long_arg_list" \
402 "Temporary breakpoint .* file .*$srcfile, line .*" \
403 "tbreak in print_long_arg_list after stepping into memcpy"
404 # The short match case below handles cases where a buffer
405 # overflows or something, and expect can't deal with the full
406 # line. Perhaps a more elegant solution exists... -sts 1999-08-17
407 if {$allow_float_test} {
408 gdb_test_multiple "continue" "step into print_long_arg_list" {
409 -re ".*print_long_arg_list \\(a=22.25, b=33.375, c=0, d=-25, e=100, f=2345, struct1=\{value = 6, head = 0\}, struct2=\{value = 10, head = 0\}, struct3=\{value = 12, head = 0\}, struct4=\{value = 14, head = 0\}, flags=\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\}, flags_combo=\{alpha = 1, beta = 0, ch1 = 121 \'y\', gamma = 1, delta = 0, ch2 = 110 \'n\', epsilon = 1, omega = 0\}, three_char=\{ch1 = 97 \'a\', ch2 = 98 \'b\', ch3 = 99 \'c\'\}, five_char=\{ch1 = 108 \'l\', ch2 = 109 \'m\', ch3 = 110 \'n\', ch4 = 111 \'o\', ch5 = 112 \'p\'\}, int_char_combo=\{int1 = 123, ch1 = 122 \'z\'\}, d1=\{double1 = 10.5\}, d2=\{double1 = -3.375\}, d3=\{double1 = 675.09375\}, f1=\{float1 = 45.2340012, float2 = 43.5999985\}, f2=\{float1 = 78.0100021, float2 = 122.099998\}, f3=\{float1 = -1232.34497, float2 = -199.210007\}\\) at .*${srcfile}:$stop_line\[\r\n\]+$stop_line\[ \t\]+printf\\(\"double :.*\", a\\);.*$gdb_prompt $" {
410 pass "step into print_long_arg_list"
411 }
412 -re ".*print_long_arg_list.*\\(a=22.25, b=33.375, c=0, d=-25, e=100, f=2345, struct1=\{value = 6, head = 0\}, struct2=\{value = 10, head = 0\}, struct3=\{value = 12, head = 0\}, struct4=\{value = 14, head = 0\}, flags=\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\}, flags_combo=\{alpha = 1, beta = 0, ch1 = 121 \'y\', gamma = 1, delta = 0, ch2 = 110 \'n\', epsilon = 1, omega = 0\}, three_char=\{ch1 = 97 \'a\', ch2 = 98 \'b\', ch3 = 99 \'c\'\}.*\\) at .*${srcfile}:$stop_line\[\r\n\]+$stop_line\[ \t\]+printf\\(\"double :.*\", a\\);.*$gdb_prompt $" {
413 pass "step into print_long_arg_list (short match)"
414 }
415 }
416 } else {
417 # If skipping float tests, don't expect anything in arg list.
418 gdb_test "continue" \
419 "print_long_arg_list \\(.*\\).*" \
420 "step into print_long_arg_list"
421 }
422
423 set ws "\[\n\r\t \]+"
424
425 #call print_small_structs(struct1, struct2, struct3, struct4, flags,
426 # flags_combo, three_char, five_char, int_char_combo,
427 # d1, d2, d3, f1, f2, f3)
428
429 if {$allow_float_test && \
430 ![gdb_skip_stdio_test "print_small_structs from print_long_arg_list"] } {
431
432 # On 32-bit SPARC, some of the args are passed by ref, others by
433 # value, and GDB gets confused and says "Invalid cast" because it
434 # thinks it has to cast the structure into a pointer to structure.
435 if {[test_debug_format "stabs"]} {
436 setup_kfail "gdb/1539" "sparc-*-*"
437 }
438
439
440 gdb_test_stdio "print print_small_structs(struct1, struct2, struct3, struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3)" \
441 [multi_line \
442 "alpha" \
443 "gamma" \
444 "epsilon" \
445 "alpha" \
446 "gamma" \
447 "epsilon" \
448 "ch1: y\[ \t\]*ch2: n" \
449 "Contents of three_char_t: " \
450 "" \
451 "a\[ \t\]*b\[ \t\]*c" \
452 "Contents of five_char_t: " \
453 "" \
454 "l\[ \t\]*m\[ \t\]*n\[ \t\]*o\[ \t\]*p" \
455 "Contents of int_char_combo_t: " \
456 "" \
457 "123\[ \t\]*z" \
458 "Sum of the 4 struct values and seed : " \
459 "" \
460 "\[ \t\]*52" \
461 "Contents of struct1: " \
462 "" \
463 "\[ \t\]*6\[ \t\]*0" \
464 "Contents of struct2: " \
465 "" \
466 "\[ \t\]*10\[ \t\]*0" \
467 "Contents of struct3: " \
468 "" \
469 "\[ \t\]*12\[ \t\]*0" \
470 "Contents of one_double_t: " \
471 "" \
472 "10.500000" \
473 "Contents of one_double_t: " \
474 "" \
475 "-3.375000" \
476 "Contents of one_double_t: " \
477 "" \
478 "675.093750" \
479 "Contents of two_floats_t: " \
480 "" \
481 "\[ \t\]*45.234001\[ \t\]*43.599998" \
482 "Contents of two_floats_t: " \
483 "" \
484 "\[ \t\]*78.010002\[ \t\]*122.099998" \
485 "Contents of two_floats_t: " \
486 "" \
487 "-1232.344971\[ \t\]*-199.210007" \
488 ] \
489 "" \
490 "print print_small_structs from print_long_arg_list"
491 }
492
493 set stop_line [gdb_get_line_number "-tbreak8-"]
494 gdb_test "tbreak $stop_line" \
495 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
496 "tbreakpoint at tbreak8"
497
498 if ![gdb_skip_stdio_test "continuing to tbreak8"] {
499 gdb_test_stdio "continue" \
500 "Contents of two_floats_t:" \
501 ".*main \\(\\) at.*$srcfile:$stop_line.*$stop_line.*init_bit_flags_combo\\(flags_combo, \\(unsigned\\)1, \\(unsigned\\)0, .y.,.*" \
502 "continue to tbreak8"
503 } else {
504 gdb_test "continue" ".*" ""
505 }
506
507 #step
508 set stop_line [gdb_get_line_number "-step3-"]
509 gdb_test "step" \
510 "init_bit_flags_combo \\(bit_flags_combo=, a=1, b=0, ch1=121 .y., g=1, d=0, ch2=110 .n., e=1, o=0\\) at .*$srcfile:$stop_line\[ \t\n\r\]+$stop_line.*bit_flags_combo->alpha = a;.*" \
511 "step into init_bit_flags_combo"
512
513 #call print_bit_flags_combo(*bit_flags_combo)
514 if ![gdb_skip_stdio_test "continuing at step3"] {
515 gdb_test_stdio "print print_bit_flags_combo(*bit_flags_combo)" \
516 "alpha.*gamma.*epsilon.*ch1: y.*ch2: n"
517 }
518
519
520 set stop_line [gdb_get_line_number "-tbreak9-"]
521 gdb_test "tbreak $stop_line" \
522 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
523 "tbreakpoint at tbreak9"
524
525 gdb_test continue "Continuing\\..*main \\(\\) at .*$srcfile:$stop_line\[\r\n\t \]+$stop_line.*init_int_char_combo\\(int_char_combo, 13, .!.\\);.*" \
526 "continue to tbreak9"
527
528 #call print_long_arg_list(a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)
529
530 if {$allow_float_test && \
531 ![gdb_skip_stdio_test "print print_long_arg_list"] } {
532
533 gdb_test_stdio "print print_long_arg_list(a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3)" \
534 [multi_line \
535 "double : 22.250000" \
536 "double : 33.375000" \
537 "int : 0" \
538 "int : -25" \
539 "int : 100" \
540 "int : 2345" \
541 "alpha" \
542 "gamma" \
543 "epsilon" \
544 "alpha" \
545 "gamma" \
546 "epsilon" \
547 "ch1: y\[ \t\]*ch2: n" \
548 "Contents of three_char_t: " \
549 "" \
550 "x\[ \t\]*y\[ \t\]*z" \
551 "Contents of five_char_t: " \
552 "" \
553 "h\[ \t\]*e\[ \t\]*l\[ \t\]*l\[ \t\]*o" \
554 "Contents of int_char_combo_t: " \
555 "" \
556 "123\[ \t\]*z" \
557 "Sum of the 4 struct values and seed : " \
558 "" \
559 "\[ \t\]*52" \
560 "Contents of struct1: " \
561 "" \
562 "\[ \t\]*6\[ \t\]*0" \
563 "Contents of struct2: " \
564 "" \
565 "\[ \t\]*10\[ \t\]*0" \
566 "Contents of struct3: " \
567 "" \
568 "\[ \t\]*12\[ \t\]*0" \
569 "Contents of one_double_t: " \
570 "" \
571 "1.111110" \
572 "Contents of one_double_t: " \
573 "" \
574 "-345.340000" \
575 "Contents of one_double_t: " \
576 "" \
577 "546464.200000" \
578 "Contents of two_floats_t: " \
579 "" \
580 "0.234000\[ \t\]*453.100006" \
581 "Contents of two_floats_t: " \
582 "" \
583 "78.345001\[ \t\]*23.090000" \
584 "Contents of two_floats_t: " \
585 "" \
586 "-2.345000\[ \t\]*1.000000" \
587 ] \
588 "" \
589 "print print_long_arg_list"
590 }
591
592
593 set stop_line [gdb_get_line_number "-tbreak10-"]
594 gdb_test "tbreak $stop_line" \
595 "Temporary breakpoint.* file .*$srcfile, line $stop_line.*" \
596 "tbreakpoint at tbreak10"
597
598 gdb_test continue "Continuing\\..*main \\(\\) at .*$srcfile:$stop_line\[ \t\n\r\]+$stop_line.*compute_with_small_structs\\(35\\);.*" \
599 "continue to tbreak10"
600
601
602 #call sum_struct_print(10, *struct1, *struct2, *struct3, *struct4)
603 if ![gdb_skip_stdio_test "print sum_struct_print(...)"] {
604 gdb_test_stdio "print sum_struct_print(10,*struct1,*struct2,*struct3,*struct4)" \
605 "Sum of the 4 struct values and seed :\[ \t\n\r\]+218"
606 }
607
608
609 #call print_struct_rep(*struct1, *struct2, *struct3)
610 if ![gdb_skip_stdio_test "print print_struct_rep(...)"] {
611 gdb_test_stdio "print print_struct_rep(*struct1, *struct2, *struct3)" \
612 [multi_line \
613 "Contents of struct1: " \
614 "" \
615 " 22 0" \
616 "Contents of struct2: " \
617 "" \
618 " 42 0" \
619 "Contents of struct3: " \
620 "" \
621 " 62 0" \
622 ]
623 }
624
625 if ![gdb_skip_stdio_test "print print_one_large_struct(...)"] {
626 gdb_test_stdio "print print_one_large_struct(*list1)" \
627 " 4 1"
628 }
629
630 set timeout $oldtimeout