* gdb.base/nodebug.exp: Don't try to do an inferior function
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / funcargs.exp
CommitLineData
07b96357 1# Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
ef44eed1
SS
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 2 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, write to the Free Software
ce102e96 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
ef44eed1
SS
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Fred Fish. (fnf@cygnus.com)
21
787f6220
BM
22if $tracelevel {
23 strace $tracelevel
ef44eed1
SS
24}
25
26set prms_id 0
27set bug_id 0
28
782445c7 29set testfile "funcargs"
787f6220 30set srcfile ${testfile}.c
782445c7 31set binfile ${objdir}/${subdir}/${testfile}
787f6220 32if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
782445c7
FF
33 perror "Couldn't compile ${srcfile}"
34 return -1
35}
ef44eed1 36
787f6220
BM
37# Create and source the file that provides information about the compiler
38# used to compile the test case.
39if [get_compiler_info ${binfile}] {
40 return -1;
ef44eed1
SS
41}
42
43#
44# Locate actual args; integral types.
45#
46
47proc integral_args {} {
48 global prompt
49 global det_file
ce102e96 50 global gcc_compiled
787f6220 51 global gdb_spawn_id
ef44eed1
SS
52
53 delete_breakpoints
54
787f6220
BM
55 gdb_breakpoint call0a
56 gdb_breakpoint call0b
57 gdb_breakpoint call0c
58 gdb_breakpoint call0d
59 gdb_breakpoint call0e
ef44eed1
SS
60
61 # Run; should stop at call0a and print actual arguments.
62 # The a29k fails all of these tests, perhaps because the prologue
63 # code is broken.
64 setup_xfail "a29k-*-udi"
ce102e96 65 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
07b96357
PS
66 gdb_run_cmd
67 expect {
787f6220 68 -i $gdb_spawn_id -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$prompt $" {
07b96357
PS
69 pass "run to call0a"
70 }
787f6220
BM
71 -i $gdb_spawn_id -re "$prompt $" { fail "run to call0a" ; return }
72 -i $gdb_spawn_id timeout { fail "(timeout) run to call0a" ; return }
ef44eed1
SS
73 }
74
75 # Print each arg as a double check to see if we can print
76 # them here as well as with backtrace.
ce102e96
FF
77 gdb_test "print c" ".* = 97 'a'" "print c after run to call0a"
78 gdb_test "print s" ".* = 1" "print s after run to call0a"
79 gdb_test "print i" ".* = 2" "print i after run to call0a"
80 gdb_test "print l " ".* = 3" "print l after run to call0a"
ef44eed1
SS
81
82 # Continue; should stop at call0b and print actual arguments.
ce102e96 83 if [gdb_test "cont" ".* call0b \\(s=1, i=2, l=3, c=97 'a'\\) .*" "continue to call0b"] {
07b96357 84 return
ef44eed1
SS
85 }
86
87 # Continue; should stop at call0c and print actual arguments.
ce102e96 88 if [gdb_test "cont" ".* call0c \\(i=2, l=3, c=97 'a', s=1\\) .*" "continue to call0c"] {
07b96357 89 return
ef44eed1
SS
90 }
91
92 # Continue; should stop at call0d and print actual arguments.
ce102e96 93 if [gdb_test "cont" ".* call0d \\(l=3, c=97 'a', s=1, i=2\\) .*" "continue to call0d";] {
07b96357 94 return
ef44eed1
SS
95 }
96
97 # Continue; should stop at call0e and print actual arguments.
ce102e96 98 if [gdb_test "cont" ".* call0e \\(c1=97 'a', l=3, c2=97 'a', i=2, c3=97 'a', s=1, c4=97 'a', c5=97 'a'\\) .*" "continue to call0e" ] {
07b96357 99 return
ef44eed1 100 }
ef44eed1
SS
101}
102
103#
104# Locate actual args; unsigned integral types.
105#
106
107proc unsigned_integral_args {} {
108 global prompt
109 global det_file
ce102e96 110 global gcc_compiled
787f6220 111 global gdb_spawn_id
ef44eed1
SS
112
113 delete_breakpoints
114
787f6220
BM
115 gdb_breakpoint call1a;
116 gdb_breakpoint call1b;
117 gdb_breakpoint call1c;
118 gdb_breakpoint call1d;
119 gdb_breakpoint call1e;
ef44eed1
SS
120
121 # Run; should stop at call1a and print actual arguments.
122 # The a29k fails all of these tests, perhaps because the prologue
123 # code is broken.
124 setup_xfail "a29k-*-udi"
ce102e96 125 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
07b96357
PS
126 gdb_run_cmd
127 expect {
787f6220 128 -i $gdb_spawn_id -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$prompt $" {
07b96357
PS
129 pass "run to call1a"
130 }
787f6220
BM
131 -i $gdb_spawn_id -re "$prompt $" { fail "run to call1a" ; return }
132 -i $gdb_spawn_id timeout { fail "(timeout) run to call1a" ; return }
ef44eed1
SS
133 }
134
135 # Print each arg as a double check to see if we can print
136 # them here as well as with backtrace.
07b96357
PS
137 gdb_test "print uc" ".* = 98 'b'"
138 gdb_test "print us" ".* = 6"
139 gdb_test "print ui" ".* = 7"
140 gdb_test "print ul" ".* = 8"
ef44eed1
SS
141
142 # Continue; should stop at call1b and print actual arguments.
ce102e96 143 if [gdb_test "cont" ".* call1b \\(us=6, ui=7, ul=8, uc=98 'b'\\) .*" "continue to call1b"] {
07b96357 144 return
ef44eed1
SS
145 }
146
147 # Continue; should stop at call1c and print actual arguments.
ce102e96 148 if [gdb_test "cont" ".* call1c \\(ui=7, ul=8, uc=98 'b', us=6\\) .*" "continue to call1c"] {
07b96357 149 return
ef44eed1
SS
150 }
151
152 # Continue; should stop at call1d and print actual arguments.
ce102e96 153 if [gdb_test "cont" ".* call1d \\(ul=8, uc=98 'b', us=6, ui=7\\) .*" "continue to call1d"] {
07b96357 154 return
ef44eed1
SS
155 }
156
157 # Continue; should stop at call1e and print actual arguments.
ce102e96 158 if [gdb_test "cont" ".* call1e \\(uc1=98 'b', ul=8, uc2=98 'b', ui=7, uc3=98 'b', us=6, uc4=98 'b', uc5=98 'b'\\) .*" "continue to call1e"] {
07b96357 159 return
ef44eed1 160 }
ef44eed1
SS
161}
162
163#
164# Locate actual args; integrals mixed with floating point.
165#
166
167proc float_and_integral_args {} {
168 global prompt
169 global det_file
ce102e96 170 global gcc_compiled
787f6220 171 global gdb_spawn_id
ef44eed1
SS
172
173 delete_breakpoints
174
787f6220
BM
175 gdb_breakpoint call2a
176 gdb_breakpoint call2b
177 gdb_breakpoint call2c
178 gdb_breakpoint call2d
179 gdb_breakpoint call2e
180 gdb_breakpoint call2f
181 gdb_breakpoint call2g
182 gdb_breakpoint call2h
ef44eed1
SS
183
184 # Run; should stop at call2a and print actual arguments.
185
186 setup_xfail "i960-*-*" 1813
187 # The a29k fails all of these tests, perhaps because the prologue
188 # code is broken.
189 setup_xfail "a29k-*-udi"
5762d8c6 190 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
07b96357
PS
191 gdb_run_cmd
192 expect {
787f6220
BM
193 -i $gdb_spawn_id -re ".* call2a \\(c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$prompt $" { pass "run to call2a" }
194 -i $gdb_spawn_id -re "$prompt $" { fail "run to call2a" ; return }
195 -i $gdb_spawn_id timeout { fail "(timeout) run to call2a" ; return }
ef44eed1
SS
196 }
197
198 # Print each arg as a double check to see if we can print
ce102e96 199 gdb_test "print c" ".* = 97 'a'" "print c after run to call2a"
71568251 200 gdb_test "print f1" ".* = 4" "print f1 after run to call2a"
ce102e96
FF
201 gdb_test "print s" ".* = 1" "print s after run to call2a"
202 gdb_test "print d1" ".* = 5" "print d1 after run to call2a"
203 gdb_test "print i" ".* = 2" "print i after run to call2a"
204 gdb_test "print f2" ".* = 4" "print f2 after run to call2a"
205 gdb_test "print l" ".* = 3" "print l after run to call2a"
206 gdb_test "print d2" ".* = 5" "print d2 after run to call2a"
207
208 setup_xfail "rs6000-*-*"
5762d8c6 209 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
ef44eed1 210 # Continue; should stop at call2b and print actual arguments.
ce102e96 211 if [gdb_test "cont" ".* call2b \\(f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5, c=97 'a'\\) .*" "continue to call2b"] {
07b96357 212 return
ef44eed1
SS
213 }
214
215 # Continue; should stop at call2c and print actual arguments.
ce102e96 216 if [gdb_test "cont" ".* call2c \\(s=1, d1=5, i=2, f2=4, l=3, d2=5, c=97 'a', f1=4\\) .*" "continue to call2c"] {
07b96357 217 return
ef44eed1
SS
218 }
219
220 # Continue; should stop at call2d and print actual arguments.
ce102e96 221 if [gdb_test "cont" ".* call2d \\(d1=5, i=2, f2=4, l=3, d2=5, c=97 'a', f1=4, s=1\\) .*" "continue to call2d"] {
07b96357 222 return
ef44eed1
SS
223 }
224
225 # Continue; should stop at call2e and print actual arguments.
ce102e96 226 if [gdb_test "cont" ".* call2e \\(i=2, f2=4, l=3, d2=5, c=97 'a', f1=4, s=1, d1=5\\) .*" "continue to call2e"] {
07b96357 227 return
ef44eed1
SS
228 }
229
230 # Continue; should stop at call2f and print actual arguments.
ce102e96 231 if [gdb_test "cont" ".* call2f \\(f2=4, l=3, d2=5, c=97 'a', f1=4, s=1, d1=5, i=2\\) .*" "continue to call2f"] {
07b96357 232 return
ef44eed1
SS
233 }
234
235 # Continue; should stop at call2g and print actual arguments.
ce102e96 236 if [gdb_test "cont" ".* call2g \\(l=3, d2=5, c=97 'a', f1=4, s=1, d1=5, i=2, f2=4\\) .*" "continue to call2g"] {
07b96357 237 return
ef44eed1
SS
238 }
239
240 # Continue; should stop at call2h and print actual arguments.
ce102e96 241 if [gdb_test "cont" ".* call2h \\(d2=5, c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3\\) .*" "continue to call2h"] {
07b96357 242 return
ef44eed1
SS
243 }
244
80d28979
JL
245 # monitor only allows 8 breakpoints; w89k board allows 10, so
246 # break them up into two groups.
247 delete_breakpoints
787f6220 248 gdb_breakpoint call2i
80d28979 249
ef44eed1 250 # Continue; should stop at call2i and print actual arguments.
ce102e96 251 if [gdb_test "cont" ".* call2i \\(c1=97 'a', f1=4, c2=97 'a', c3=97 'a', d1=5, c4=97 'a', c5=97 'a', c6=97 'a', f2=4, s=1, c7=97 'a', d2=5\\) .*" "continue to call2i"] {
07b96357 252 return
ef44eed1 253 }
ef44eed1
SS
254}
255
256#
257# Locate actual args; dereference pointers to ints and floats.
258#
259
260proc pointer_args {} {
261 global prompt
262 global hex
263 global det_file
787f6220 264 global gdb_spawn_id
ef44eed1
SS
265
266 delete_breakpoints
267
787f6220
BM
268 gdb_breakpoint call3a
269 gdb_breakpoint call3b
270 gdb_breakpoint call3c
ef44eed1
SS
271
272 # Run; should stop at call3a and print actual arguments.
273 # Try dereferencing the arguments.
274
ef44eed1
SS
275 # The a29k fails all of these tests, perhaps because the prologue
276 # code is broken.
277 setup_xfail "a29k-*-udi"
07b96357
PS
278 gdb_run_cmd
279 expect {
787f6220
BM
280 -i $gdb_spawn_id -re ".* call3a \\(cp=$hex \"a\", sp=$hex, ip=$hex, lp=$hex\\) .*$prompt $" { pass "run to call3a" }
281 -i $gdb_spawn_id -re "$prompt $" { fail "run to call3a" ; return }
282 -i $gdb_spawn_id timeout { fail "(timeout) run to call3a" ; return }
ef44eed1
SS
283 }
284
07b96357
PS
285 gdb_test "print *cp" ".* = 97 'a'"
286 gdb_test "print *sp" ".* = 1"
287 gdb_test "print *ip" ".* = 2"
288 gdb_test "print *lp" ".* = 3"
ef44eed1
SS
289
290 # Continue; should stop at call3b and print actual arguments.
291 # Try dereferencing the arguments.
ce102e96 292 if [gdb_test "cont" ".* call3b \\(ucp=$hex \"b\", usp=$hex, uip=$hex, ulp=$hex\\) .*" "continue to call3b"] {
07b96357 293 return
ef44eed1
SS
294 }
295
07b96357
PS
296 gdb_test "print *ucp" ".* = 98 'b'"
297 gdb_test "print *usp" ".* = 6"
298 gdb_test "print *uip" ".* = 7"
299 gdb_test "print *ulp" ".* = 8"
ef44eed1
SS
300
301 # Continue; should stop at call3c and print actual arguments.
302 # Try dereferencing the arguments.
ce102e96 303 if [gdb_test "cont" ".* call3c \\(fp=$hex, dp=$hex\\) .*" "continue to call3c"] {
07b96357 304 return
ef44eed1
SS
305 }
306
07b96357
PS
307 gdb_test "print *fp" ".* = 4"
308 gdb_test "print *dp" ".* = 5"
ef44eed1
SS
309
310 pass "locate actual args, pointer types"
311}
312
313#
314# Locate actual args; structures and unions passed by reference.
315#
316
317proc structs_by_reference {} {
318 global prompt
319 global hex
320 global det_file
787f6220 321 global gdb_spawn_id
ef44eed1
SS
322
323 delete_breakpoints
324
787f6220
BM
325 gdb_breakpoint call4a
326 gdb_breakpoint call4b
ef44eed1
SS
327
328 # Run; should stop at call4a and print actual arguments.
329 # Try dereferencing the arguments.
330
331 # The a29k fails all of these tests, perhaps because the prologue
332 # code is broken.
333 setup_xfail "a29k-*-udi"
07b96357
PS
334 gdb_run_cmd
335 expect {
787f6220 336 -i $gdb_spawn_id -re ".* call4a \\(stp=$hex\\) .*$prompt $" {
07b96357
PS
337 pass "run to call4a"
338 }
787f6220
BM
339 -i $gdb_spawn_id -re "$prompt $" { fail "run to call4a" ; return }
340 -i $gdb_spawn_id timeout { fail "(timeout) run to call4a" ; return }
ef44eed1
SS
341 }
342
07b96357 343 gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}"
ef44eed1
SS
344
345 # Continue; should stop at call4b and print actual arguments.
346 # Try dereferencing the arguments.
347
ce102e96 348 gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b"
ef44eed1 349
787f6220
BM
350 # sizeof int != sizeof long on h8300
351 setup_xfail "h8300*-*-*"
07b96357 352 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}"
ef44eed1
SS
353
354 pass "locate actual args, structs/unions passed by reference"
355}
356
357#
358# Locate actual args; structures and unions passed by value.
359#
360
361proc structs_by_value {} {
362 global prompt
363 global hex
364 global det_file
787f6220 365 global gdb_spawn_id
ef44eed1
SS
366
367 delete_breakpoints
368
787f6220
BM
369 gdb_breakpoint call5a
370 gdb_breakpoint call5b
ef44eed1
SS
371
372 # Run; should stop at call5a and print actual arguments.
373 # Try dereferencing the arguments.
374
375 # The a29k fails all of these tests, perhaps because the prologue
376 # code is broken.
377 setup_xfail "a29k-*-udi"
07b96357
PS
378 gdb_run_cmd
379 expect {
787f6220 380 -i $gdb_spawn_id -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$prompt $" {
07b96357
PS
381 pass "run to call5a"
382 }
787f6220
BM
383 -i $gdb_spawn_id -re "$prompt $" { fail "run to call5a" ; return }
384 -i $gdb_spawn_id timeout { fail "(timeout) run to call5a" ; return }
ef44eed1
SS
385 }
386
07b96357 387 gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}"
ef44eed1
SS
388
389 # Continue; should stop at call5b and print actual arguments.
390 # Try dereferencing the arguments.
787f6220
BM
391 # sizeof int != sizeof long on h8300
392 setup_xfail "h8300*-*-*"
ce102e96 393 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \
07b96357 394 "continue to call5b"
ef44eed1 395
787f6220
BM
396 # sizeof int != sizeof long on h8300
397 setup_xfail "h8300*-*-*"
07b96357 398 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}"
ef44eed1
SS
399}
400
401#
402# Locate actual args; discard, shuffle, and call
403#
404
405proc discard_and_shuffle {} {
406 global prompt
407 global hex
408 global decimal
409 global det_file
5762d8c6 410 global gcc_compiled
787f6220 411 global gdb_spawn_id
ef44eed1
SS
412
413 delete_breakpoints
414
787f6220
BM
415 gdb_breakpoint call6a
416 gdb_breakpoint call6b
417 gdb_breakpoint call6c
418 gdb_breakpoint call6d
419 gdb_breakpoint call6e
420 gdb_breakpoint call6f
421 gdb_breakpoint call6g
422 gdb_breakpoint call6h
ef44eed1
SS
423
424 # Run; should stop at call6a and print actual arguments.
425 # Print backtrace.
426
427 # The a29k fails all of these tests, perhaps because the prologue
428 # code is broken.
429 setup_xfail "a29k-*-udi"
07b96357
PS
430 gdb_run_cmd
431 expect {
787f6220
BM
432 -i $gdb_spawn_id -re ".*Breakpoint $decimal, call6a .*$prompt $" { pass "run to call6a" }
433 -i $gdb_spawn_id -re "$prompt $" { fail "run to call6a" ; return }
434 -i $gdb_spawn_id timeout { fail "(timeout) run to call6a" ; return }
ef44eed1
SS
435 }
436
ce102e96 437 setup_xfail "rs6000-*-*"
787f6220
BM
438
439 if {!$gcc_compiled} {
440 setup_xfail "mips-sgi-irix5*"
441 }
442
443 if [gdb_test "backtrace 100" ".* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\]" "backtrace from call6a"] {
444 return;
ef44eed1
SS
445 }
446
447 # Continue; should stop at call6b and print actual arguments.
448 # Print backtrace.
449
787f6220 450 gdb_continue call6b
ef44eed1 451
787f6220
BM
452 if [gdb_test "backtrace 100" ".* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\]*.* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\]" "backtrace from call6b"] {
453 return;
ef44eed1
SS
454 }
455
456 # Continue; should stop at call6c and print actual arguments.
457 # Print backtrace.
458
787f6220 459 gdb_continue call6c
ef44eed1 460
787f6220
BM
461 if [gdb_test "backtrace 100" ".* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6c"] {
462 return;
ef44eed1 463 }
ef44eed1
SS
464 # Continue; should stop at call6d and print actual arguments.
465 # Print backtrace.
466
787f6220 467 gdb_continue call6d
ef44eed1 468
787f6220
BM
469 if [gdb_test "backtrace 100" ".* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6d"] {
470 return;
ef44eed1
SS
471 }
472
473 # Continue; should stop at call6e and print actual arguments.
474 # Print backtrace.
475
787f6220 476 gdb_continue call6e
ef44eed1 477
787f6220
BM
478 if [gdb_test "backtrace 100" ".* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6e"] {
479 return;
ef44eed1
SS
480 }
481
482 # Continue; should stop at call6f and print actual arguments.
483 # Print backtrace.
484
787f6220 485 gdb_continue call6f
ef44eed1 486
787f6220
BM
487 if [gdb_test "backtrace 100" ".* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6f"] {
488 return;
ef44eed1
SS
489 }
490
491 # Continue; should stop at call6g and print actual arguments.
492 # Print backtrace.
493
787f6220 494 gdb_continue call6g
ef44eed1 495
787f6220
BM
496 if [gdb_test "backtrace 100" ".* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6g"] {
497 return;
ef44eed1
SS
498 }
499
500 # Continue; should stop at call6h and print actual arguments.
501 # Print backtrace.
502
787f6220 503 gdb_continue call6h
ef44eed1 504
787f6220
BM
505 if [gdb_test "backtrace 100" ".* call6h \\(us=6, ui=7, ul=8\\) .*\[\r\n\].* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6h"] {
506 return;
ef44eed1
SS
507 }
508
80d28979
JL
509 # monitor only allows 8 breakpoints; w89k board allows 10, so
510 # break them up into two groups.
511 delete_breakpoints
787f6220
BM
512 gdb_breakpoint call6i
513 gdb_breakpoint call6j
514 gdb_breakpoint call6k
80d28979 515
ef44eed1
SS
516 # Continue; should stop at call6i and print actual arguments.
517 # Print backtrace.
518
787f6220 519 gdb_continue call6i
ef44eed1 520
787f6220
BM
521 if [gdb_test "backtrace 100" ".* call6i \\(ui=7, ul=8\\) .*\[\r\n\].* call6h \\(us=6, ui=7, ul=8\\) .*\[\r\n\].* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6i"] {
522 return;
ef44eed1
SS
523 }
524
525 # Continue; should stop at call6j and print actual arguments.
526 # Print backtrace.
527
787f6220 528 gdb_continue call6j
ef44eed1 529
787f6220
BM
530 if [gdb_test "backtrace 100" ".* call6j \\(ul=8\\) .*\[\r\n\].* call6i \\(ui=7, ul=8\\) .*\[\r\n\].* call6h \\(us=6, ui=7, ul=8\\) .*\[\r\n\].* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6j"] {
531 return;
ef44eed1
SS
532 }
533
534 # Continue; should stop at call6k and print actual arguments.
535 # Print backtrace.
536 # This fails on i960-*-vxworks because gdb gets confused by
537 # breakpoints on adjacent instructions.
538 setup_xfail "i960-*-vxworks" 1786
787f6220 539 gdb_continue call6k
ef44eed1 540
787f6220
BM
541 if [gdb_test "backtrace 100" ".* call6k \\(\\) .*\[\r\n\].* call6j \\(ul=8\\) .*\[\r\n\].* call6i \\(ui=7, ul=8\\) .*\[\r\n\].* call6h \\(us=6, ui=7, ul=8\\) .*\[\r\n\].* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n\].* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\[\r\n].* main \\(.*\\) .*" "backtrace from call6k"] {
542 return;
ef44eed1 543 }
ef44eed1
SS
544}
545
546#
547# Locate actual args; shuffle round robin and call
548#
549
550proc shuffle_round_robin {} {
551 global prompt
552 global hex
553 global decimal
554 global det_file
ce102e96 555 global gcc_compiled
787f6220 556 global gdb_spawn_id
ef44eed1
SS
557
558 delete_breakpoints
559
787f6220
BM
560 gdb_breakpoint call7a
561 gdb_breakpoint call7b
562 gdb_breakpoint call7c
563 gdb_breakpoint call7d
564 gdb_breakpoint call7e
565 gdb_breakpoint call7f
566 gdb_breakpoint call7g
567 gdb_breakpoint call7h
ef44eed1
SS
568
569 # Run; should stop at call7a and print actual arguments.
570 # Print backtrace.
571
572 # The a29k fails all of these tests, perhaps because the prologue
573 # code is broken.
574 setup_xfail "a29k-*-udi"
07b96357
PS
575 gdb_run_cmd
576 expect {
787f6220 577 -i $gdb_spawn_id -re ".*Breakpoint $decimal, call7a .*$prompt $" {
07b96357
PS
578 pass "run to call7a"
579 }
787f6220
BM
580 -i $gdb_spawn_id -re "$prompt $" { fail "run to call7a" ; return }
581 -i $gdb_spawn_id timeout { fail "(timeout) run to call7a" ; return }
ef44eed1
SS
582 }
583
584 setup_xfail "i960-*-*" 1813
5762d8c6 585 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" }
787f6220 586 gdb_test "backtrace 100" ".* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7a"
ef44eed1
SS
587
588 # Continue; should stop at call7b and print actual arguments.
589 # Print backtrace.
590
787f6220 591 gdb_continue call7b
ef44eed1 592
ce102e96 593 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" }
787f6220
BM
594
595 gdb_test "backtrace 100" ".* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7b"
ef44eed1
SS
596
597 # Continue; should stop at call7c and print actual arguments.
598 # Print backtrace.
599
787f6220 600 gdb_continue call7c
ef44eed1 601
787f6220 602 gdb_test "backtrace 100" ".* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7c"
ef44eed1
SS
603
604 # Continue; should stop at call7d and print actual arguments.
605 # Print backtrace.
606
787f6220 607 gdb_continue call7d
ef44eed1 608
787f6220 609 gdb_test "backtrace 100" ".* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7d"
ef44eed1 610
787f6220 611 gdb_continue call7e
ef44eed1 612
787f6220 613 gdb_test "backtrace 100" ".* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7e"
ef44eed1
SS
614
615 # Continue; should stop at call7f and print actual arguments.
616 # Print backtrace.
617
787f6220 618 gdb_continue call7f
ef44eed1 619
787f6220 620 gdb_test "backtrace 100" ".* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7f"
ef44eed1
SS
621
622 # Continue; should stop at call7g and print actual arguments.
623 # Print backtrace.
624
787f6220 625 gdb_continue call7g
ef44eed1 626
787f6220 627 gdb_test "backtrace 100" ".* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7g"
ef44eed1 628
787f6220 629 gdb_continue call7h
ef44eed1 630
787f6220 631 gdb_test "backtrace 100" ".* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\[\r\n\].* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7h"
ef44eed1 632
bed1eef3
JL
633 # monitor only allows 8 breakpoints; w89k board allows 10, so
634 # break them up into two groups.
635 delete_breakpoints
787f6220
BM
636 gdb_breakpoint call7i
637 gdb_breakpoint call7j
638 gdb_breakpoint call7k
bed1eef3 639
ef44eed1
SS
640 # Continue; should stop at call7i and print actual arguments.
641 # Print backtrace.
642
787f6220 643 gdb_continue call7i
ef44eed1 644
787f6220 645 gdb_test "backtrace 100" ".* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\[\r\n\].* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\[\r\n\].* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7i"
ef44eed1
SS
646
647 # Continue; should stop at call7j and print actual arguments.
648 # Print backtrace.
649
787f6220 650 gdb_continue call7j
ef44eed1 651
787f6220 652 gdb_test "backtrace 100" ".* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) .*\[\r\n\].* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\[\r\n\].* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\[\r\n\].* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7j"
ef44eed1
SS
653
654 # Continue; should stop at call7k and print actual arguments.
655 # Print backtrace.
656
787f6220 657 gdb_continue call7k
ef44eed1 658
5762d8c6 659 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" }
787f6220 660 gdb_test "backtrace 100" ".* call7k \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) .*\[\r\n\].* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) .*\[\r\n\].* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) .*\[\r\n\].* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) .*\[\r\n\].* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) .*\[\r\n\].* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) .*\[\r\n\].* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) .*\[\r\n\].* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) .*\[\r\n\].* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) .*\[\r\n\].* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\].*" "backtrace from call7k"
ef44eed1
SS
661}
662
663#
664# Locate actual args; recursive passing of structs by value
665#
666
667proc recursive_structs_by_value {} {
668 global prompt
669 global hex
670 global decimal
671 global det_file
787f6220 672 global gdb_spawn_id
ef44eed1
SS
673
674 delete_breakpoints
675
787f6220 676 gdb_breakpoint hitbottom
ef44eed1
SS
677
678 # Run; should stop at hitbottom and print actual arguments.
679 # Print backtrace.
07b96357
PS
680 gdb_run_cmd
681 expect {
787f6220
BM
682 -i $gdb_spawn_id -re ".*Breakpoint $decimal, hitbottom .*$prompt $" { pass "run to hitbottom" }
683 -i $gdb_spawn_id -re "$prompt $" { fail "run to hitbottom" ; return }
684 -i $gdb_spawn_id timeout { fail "(timeout) run to hitbottom" ; return }
ef44eed1
SS
685 }
686
787f6220 687 if ![istarget sparclet-*-*] {
ef44eed1
SS
688 # The a29k fails all of these tests, perhaps because the prologue
689 # code is broken.
787f6220
BM
690 setup_xfail "a29k-*-udi"
691 gdb_test "backtrace 100" ".* hitbottom \\(\\) .*\[\r\n\].* recurse \\(a=\{s = 0, i = 0, l = 0\}, depth=0\\) .*\[\r\n\].* recurse \\(a=\{s = 1, i = 1, l = 1\}, depth=1\\) .*\[\r\n\].* recurse \\(a=\{s = 2, i = 2, l = 2\}, depth=2\\) .*\[\r\n\].* recurse \\(a=\{s = 3, i = 3, l = 3\}, depth=3\\) .*\[\r\n\].* recurse \\(a=\{s = 4, i = 4, l = 4\}, depth=4\\) .*\[\r\n\].* test_struct_args \\(\\) .*\[\r\n\].* main \\(.*\\) .*\[\r\n\]" "recursive passing of structs by value"
692 } else {
693 fail "recursive passing of structs by value (sparclet)"
ef44eed1 694 }
ef44eed1
SS
695}
696
697proc funcargs_reload { } {
698 global objdir
699 global subdir
700 global binfile
701 global srcdir
702
787f6220 703 if [istarget "mips-idt-*"] {
ef44eed1
SS
704 # Restart because IDT/SIM runs out of file descriptors.
705 gdb_exit
706 gdb_start
707 gdb_reinitialize_dir $srcdir/$subdir
782445c7 708 gdb_load ${binfile}
ef44eed1
SS
709 }
710}
711
712#
713# Test for accessing local stack variables in functions which call alloca
714#
715proc localvars_after_alloca { } {
716 global prompt
717 global hex
718 global decimal
71568251 719 global gcc_compiled
ef44eed1
SS
720
721 if { ! [ runto localvars_after_alloca ] } then { return 0 }
722
723 # Print each arg as a double check to see if we can print
724 # them here as well as with backtrace.
725
71568251
PS
726 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
727 gdb_test "print c" " = 97 'a'" "print c after runto localvars_after_alloca"
728 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
729 gdb_test "print s" " = 1" "print s after runto localvars_after_alloca"
730 gdb_test "print i" " = 2" "print i after runto localvars_after_alloca"
731 gdb_test "print l" " = 3" "print l after runto localvars_after_alloca"
ef44eed1 732
787f6220
BM
733 # Lame regexp.
734 gdb_test "next" ".*" "next in localvars_after_alloca()"
ef44eed1
SS
735
736 # Print each arg as a double check to see if we can print
737 # them here as well as with backtrace.
738
07b96357
PS
739 gdb_test "print c" " = 97 'a'" "print c in localvars_after_alloca"
740 gdb_test "print s" " = 1" "print s in localvars_after_alloca"
741 gdb_test "print i" " = 2" "print i in localvars_after_alloca"
742 gdb_test "print l" " = 3" "print l in localvars_after_alloca"
ef44eed1 743
ce102e96 744 gdb_test "backtrace 8" "#0.*localvars_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" "backtrace after alloca"
ef44eed1
SS
745}
746
07b96357
PS
747proc call_after_alloca { } {
748 global prompt
749 global hex
750 global decimal
ce102e96 751 global gcc_compiled
07b96357
PS
752
753 if { ! [ runto call_after_alloca_subr ] } then { return 0 }
754
755 # Print each arg as a double check to see if we can print
756 # them here as well as with backtrace.
757
ce102e96 758 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
07b96357 759 gdb_test "print c" " = 97 'a'" "print c in call_after_alloca"
ce102e96 760 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
07b96357
PS
761 gdb_test "print s" " = 1" "print s in call_after_alloca"
762 gdb_test "print i" " = 2" "print i in call_after_alloca"
763 gdb_test "print l" " = 3" "print l in call_after_alloca"
764
ce102e96
FF
765 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
766 gdb_test "backtrace 8" "#0.*call_after_alloca_subr \\(c=97 'a', s=1, i=2, l=3, uc=98 'b', us=11, ui=12, ul=13\\).*#1.*call_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#2.*main.*" "backtrace from call_after_alloca_subr"
07b96357
PS
767}
768
ef44eed1
SS
769#
770# Test for accessing local stack variables, backtraces, finish,
771# and finally stepping into indirect calls. The point is that on the PA
772# these use a funky `dyncall' mechanism which GDB needs to know about.
773#
774proc localvars_in_indirect_call { } {
775 global prompt
776 global hex
777 global decimal
ce102e96 778 global gcc_compiled
787f6220 779 global gdb_spawn_id
ef44eed1
SS
780
781 # Can not use "runto call0a" as call0a is called several times
782 # during single run. Instead stop in a marker function and
783 # take control from there.
784 if { ! [ runto marker_indirect_call ] } then { return 0 }
785
786 # break on the next call to call0a, then delete all the breakpoints
787 # and start testing.
787f6220
BM
788 gdb_breakpoint call0a
789 gdb_continue call0a
ef44eed1
SS
790 delete_breakpoints
791
792 # Print each arg as a double check to see if we can print
793 # them here as well as with backtrace.
794
ce102e96 795 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
07b96357 796 gdb_test "print c" " = 97 'a'" "print c in localvars_in_indirect_call"
ce102e96 797 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
07b96357
PS
798 gdb_test "print s" " = 1" "print s in localvars_in_indirect_call"
799 gdb_test "print i" " = 2" "print i in localvars_in_indirect_call"
800 gdb_test "print l" " = 3" "print l in localvars_in_indirect_call"
ef44eed1 801
ce102e96 802 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
9be82863 803 gdb_test "backtrace 8" \
ce102e96 804 "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \
9be82863 805 "backtrace in indirectly called function"
ef44eed1
SS
806
807 #
808 # "finish" brings us back to main. We then will try to step through
809 # the second indirect call.
810 # On some targets (e.g. m68k) gdb will stop from the finish in midline
811 # of the first indirect call. This is due to stack adjustment instructions
812 # after the indirect call. In these cases we will step till we hit the
813 # second indirect call.
814 #
815
787f6220 816 send_gdb "finish\n"
ef44eed1 817 expect {
787f6220
BM
818 -i $gdb_spawn_id -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$prompt $" {
819 send_gdb "step\n"
ef44eed1
SS
820 exp_continue
821 }
787f6220 822 -i $gdb_spawn_id -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$prompt $" {
ef44eed1
SS
823 pass "finish from indirectly called function"
824 }
787f6220 825 -i $gdb_spawn_id -re ".*$prompt $" {
07b96357
PS
826 fail "finish from indirectly called function"
827 return
828 }
787f6220 829 -i $gdb_spawn_id default { fail "finish from indirectly called function" ; return }
ef44eed1
SS
830 }
831
ce102e96
FF
832 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" }
833 gdb_test "step" "call0a \\(c=97 'a', s=1, i=2, l=3\\).*" \
ef44eed1
SS
834 "stepping into indirectly called function"
835}
836
837# Start with a fresh gdb.
838#
839# Test for stepping into indirect calls which may have trampolines (possibly
840# cascaded) on both the call path and the return path.
841# to handle trampolines.
842#
843proc test_stepping_over_trampolines { } {
844 global prompt
845 global hex
846 global decimal
787f6220 847 global gdb_spawn_id
ef44eed1
SS
848
849 # Stop in a marker function and take control from there.
850 if { ! [ runto marker_call_with_trampolines ] } then { return 0 }
851
852 # Cater for gdb stopping in midline, see comment for finish above.
787f6220 853 send_gdb "finish\n"
ef44eed1 854 expect {
787f6220
BM
855 -i $gdb_spawn_id -re "marker_call_with_trampolines ..;.*$prompt $" {
856 send_gdb "step\n"
ef44eed1
SS
857 exp_continue
858 }
787f6220 859 -i $gdb_spawn_id -re "pointer_to_call_with_trampolines.*$prompt $" {
ef44eed1
SS
860 pass "finish from marker_call_with_trampolines"
861 }
787f6220 862 -i $gdb_spawn_id -re ".*$prompt $" {
ef44eed1
SS
863 fail "finish from marker_call_with_trampolines"
864 }
787f6220 865 -i $gdb_spawn_id default { fail "finish from marker_call_with_trampolines" ; return 0 }
ef44eed1
SS
866 }
867
868 # Try to step into the target function.
ce102e96 869 gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \
ef44eed1
SS
870 "stepping into function called with trampolines"
871
872 # Make we can backtrace and the argument looks correct. */
ce102e96 873 gdb_test "backtrace 8" "#0.*call_with_trampolines \\(d1=5\\).*1.*main.*" \
9be82863 874 "backtrace through call with trampolines"
ef44eed1
SS
875
876 # Make sure we can get back to main.
877 # Stepping back to main might stop again after the return statement
878 # or immediately transfer control back to main if optimizations
879 # are performed.
787f6220 880 send_gdb "step\n"
ef44eed1 881 expect {
787f6220 882 -i $gdb_spawn_id -re "main .* at.*$prompt $" {
ef44eed1
SS
883 pass "stepping back to main from function called with trampolines" ;
884 return 1
885 }
787f6220
BM
886 -i $gdb_spawn_id -re "\}.*End of call_with_trampolines.*$prompt $" {
887 send_gdb "step\n"
ef44eed1
SS
888 exp_continue
889 }
787f6220 890 -i $gdb_spawn_id -re ".*$prompt $" {
ef44eed1
SS
891 fail "stepping back to main from function called with trampolines"
892 }
787f6220 893 -i $gdb_spawn_id default { fail "stepping back to main from function called with trampolines" ; return 0 }
ef44eed1
SS
894 }
895}
896
897# Start with a fresh gdb.
898
899gdb_exit
900gdb_start
901gdb_reinitialize_dir $srcdir/$subdir
782445c7 902gdb_load ${binfile}
ef44eed1 903
787f6220 904set timeout 60
ef44eed1
SS
905
906integral_args
907funcargs_reload
908unsigned_integral_args
909funcargs_reload
910float_and_integral_args
911funcargs_reload
912pointer_args
913funcargs_reload
914structs_by_reference
915funcargs_reload
916structs_by_value
917funcargs_reload
918discard_and_shuffle
919funcargs_reload
920shuffle_round_robin
921funcargs_reload
922recursive_structs_by_value
923funcargs_reload
924localvars_after_alloca
925funcargs_reload
07b96357
PS
926call_after_alloca
927funcargs_reload
ef44eed1
SS
928localvars_in_indirect_call
929funcargs_reload
930test_stepping_over_trampolines
This page took 0.267294 seconds and 4 git commands to generate.