funcargs.exp revision 1.1
1# Copyright 1992-2014 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 Fred Fish. (fnf@cygnus.com) 17 18 19standard_testfile 20 21set compile_flags {debug nowarnings quiet} 22if [support_complex_tests] { 23 lappend compile_flags "additional_flags=-DTEST_COMPLEX" 24} 25 26# Create and source the file that provides information about the compiler 27# used to compile the test case. 28if [get_compiler_info] { 29 return -1 30} 31 32if {[prepare_for_testing $testfile.exp $testfile $srcfile $compile_flags]} { 33 untested $testfile.exp 34 return -1 35} 36 37# 38# Locate actual args; integral types. 39# 40 41proc integral_args {} { 42 global gdb_prompt 43 global det_file 44 global gcc_compiled 45 46 delete_breakpoints 47 48 gdb_breakpoint call0a 49 gdb_breakpoint call0b 50 gdb_breakpoint call0c 51 gdb_breakpoint call0d 52 gdb_breakpoint call0e 53 54 # Run; should stop at call0a and print actual arguments. 55 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 56 gdb_run_cmd 57 gdb_expect { 58 -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$gdb_prompt $" { 59 pass "run to call0a" 60 } 61 -re "$gdb_prompt $" { fail "run to call0a" ; gdb_suppress_tests } 62 timeout { fail "(timeout) run to call0a" ; gdb_suppress_tests } 63 } 64 65 # Print each arg as a double check to see if we can print 66 # them here as well as with backtrace. 67 gdb_test "print c" ".* = 97 'a'" "print c after run to call0a" 68 gdb_test "print s" ".* = 1" "print s after run to call0a" 69 gdb_test "print i" ".* = 2" "print i after run to call0a" 70 gdb_test "print l " ".* = 3" "print l after run to call0a" 71 72 # Continue; should stop at call0b and print actual arguments. 73 if [gdb_test "cont" ".* call0b \\(s=1, i=2, l=3, c=97 'a'\\) .*" "continue to call0b"] { 74 gdb_suppress_tests 75 } 76 77 # Continue; should stop at call0c and print actual arguments. 78 if [gdb_test "cont" ".* call0c \\(i=2, l=3, c=97 'a', s=1\\) .*" "continue to call0c"] { 79 gdb_suppress_tests 80 } 81 82 # Continue; should stop at call0d and print actual arguments. 83 if [gdb_test "cont" ".* call0d \\(l=3, c=97 'a', s=1, i=2\\) .*" "continue to call0d";] { 84 gdb_suppress_tests 85 } 86 87 # Continue; should stop at call0e and print actual arguments. 88 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" ] { 89 gdb_suppress_tests 90 } 91 gdb_stop_suppressing_tests 92} 93 94# 95# Locate actual args; unsigned integral types. 96# 97 98proc unsigned_integral_args {} { 99 global gdb_prompt 100 global det_file 101 global gcc_compiled 102 103 delete_breakpoints 104 105 gdb_breakpoint call1a 106 gdb_breakpoint call1b 107 gdb_breakpoint call1c 108 gdb_breakpoint call1d 109 gdb_breakpoint call1e 110 111 # Run; should stop at call1a and print actual arguments. 112 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 113 gdb_run_cmd 114 gdb_expect { 115 -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$gdb_prompt $" { 116 pass "run to call1a" 117 } 118 -re "$gdb_prompt $" { fail "run to call1a" ; gdb_suppress_tests; } 119 timeout { fail "(timeout) run to call1a" ; gdb_suppress_tests; } 120 } 121 122 # Print each arg as a double check to see if we can print 123 # them here as well as with backtrace. 124 gdb_test "print uc" ".* = 98 'b'" 125 gdb_test "print us" ".* = 6" 126 gdb_test "print ui" ".* = 7" 127 gdb_test "print ul" ".* = 8" 128 129 # Continue; should stop at call1b and print actual arguments. 130 if [gdb_test "cont" ".* call1b \\(us=6, ui=7, ul=8, uc=98 'b'\\) .*" "continue to call1b"] { 131 gdb_suppress_tests 132 } 133 134 # Continue; should stop at call1c and print actual arguments. 135 if [gdb_test "cont" ".* call1c \\(ui=7, ul=8, uc=98 'b', us=6\\) .*" "continue to call1c"] { 136 gdb_suppress_tests 137 } 138 139 # Continue; should stop at call1d and print actual arguments. 140 if [gdb_test "cont" ".* call1d \\(ul=8, uc=98 'b', us=6, ui=7\\) .*" "continue to call1d"] { 141 gdb_suppress_tests 142 } 143 144 # Continue; should stop at call1e and print actual arguments. 145 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"] { 146 gdb_suppress_tests 147 } 148 gdb_stop_suppressing_tests 149} 150 151# 152# Locate actual args; integrals mixed with floating point. 153# 154 155proc float_and_integral_args {} { 156 global gdb_prompt 157 global det_file 158 global gcc_compiled 159 160 delete_breakpoints 161 162 gdb_breakpoint call2a 163 gdb_breakpoint call2b 164 gdb_breakpoint call2c 165 gdb_breakpoint call2d 166 gdb_breakpoint call2e 167 gdb_breakpoint call2f 168 gdb_breakpoint call2g 169 gdb_breakpoint call2h 170 171 # Run; should stop at call2a and print actual arguments. 172 173 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } 174 gdb_run_cmd 175 gdb_expect { 176 -re ".* call2a \\(c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" { pass "run to call2a" } 177 -re ".* call2a \\(c=97 'a', f1=.*, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" { xfail "run to call2a" } 178 -re "$gdb_prompt $" { fail "run to call2a" ; gdb_suppress_tests; } 179 timeout { fail "(timeout) run to call2a" ; gdb_suppress_tests; } 180 } 181 182 # Print each arg as a double check to see if we can print 183 gdb_test "print c" ".* = 97 'a'" "print c after run to call2a" 184 gdb_test "print f1" ".* = 4" "print f1 after run to call2a" 185 gdb_test "print s" ".* = 1" "print s after run to call2a" 186 gdb_test "print d1" ".* = 5" "print d1 after run to call2a" 187 gdb_test "print i" ".* = 2" "print i after run to call2a" 188 gdb_test "print f2" ".* = 4" "print f2 after run to call2a" 189 gdb_test "print l" ".* = 3" "print l after run to call2a" 190 gdb_test "print d2" ".* = 5" "print d2 after run to call2a" 191 192 setup_xfail "rs6000-*-*" 193 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" } 194 # Continue; should stop at call2b and print actual arguments. 195 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"] { 196 gdb_suppress_tests 197 } 198 199 # Continue; should stop at call2c and print actual arguments. 200 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"] { 201 gdb_suppress_tests 202 } 203 204 # Continue; should stop at call2d and print actual arguments. 205 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"] { 206 gdb_suppress_tests 207 } 208 209 # Continue; should stop at call2e and print actual arguments. 210 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"] { 211 gdb_suppress_tests 212 } 213 214 # Continue; should stop at call2f and print actual arguments. 215 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"] { 216 gdb_suppress_tests 217 } 218 219 # Continue; should stop at call2g and print actual arguments. 220 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"] { 221 gdb_suppress_tests 222 } 223 224 # Continue; should stop at call2h and print actual arguments. 225 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"] { 226 gdb_suppress_tests 227 } 228 229 # monitor only allows 8 breakpoints; w89k board allows 10, so 230 # break them up into two groups. 231 delete_breakpoints 232 gdb_breakpoint call2i 233 234 # Continue; should stop at call2i and print actual arguments. 235 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"] { 236 gdb_suppress_tests 237 } 238 gdb_stop_suppressing_tests 239} 240 241 242# 243# Locate actual args; _Complex types. 244# 245 246proc complex_args {} { 247 global gdb_prompt 248 249 delete_breakpoints 250 251 gdb_breakpoint callca 252 gdb_breakpoint callcb 253 gdb_breakpoint callcc 254 gdb_breakpoint callcd 255 gdb_breakpoint callce 256 gdb_breakpoint callcf 257 258 # Run; should stop at call1a and print actual arguments. 259 gdb_run_cmd 260 gdb_expect { 261 -re ".* callca \\(f1=1 \\+ 2 \\* I, f2=1 \\+ 2 \\* I, f3=1 \\+ 2 \\* I\\) .*$gdb_prompt $" { pass "run to call2a" } 262 timeout { fail "(timeout) run to callca" ; gdb_suppress_tests; } 263 } 264 gdb_test "cont" ".* callcb \\(d1=3 \\+ 4 \\* I, d2=3 \\+ 4 \\* I, d3=3 \\+ 4 \\* I\\) .*" "continue to callcb" 265 gdb_test "cont" ".* callcc \\(ld1=5 \\+ 6 \\* I, ld2=5 \\+ 6 \\* I, ld3=5 \\+ 6 \\* I\\) .*" "continue to callcc" 266 gdb_test "cont" ".* callcd \\(fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*" "continue to callcd" 267 gdb_test "cont" ".* callce \\(dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I\\) .*" "continue to callce" 268 gdb_test "cont" ".* callcf \\(ldc1=5 \\+ 6 \\* I, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I\\) .*" "continue to callcf" 269} 270 271 272# 273# Locate actual args; _Complex types and integral. 274# 275proc complex_integral_args {} { 276 global gdb_prompt 277 278 delete_breakpoints 279 280 gdb_breakpoint callc1a 281 gdb_breakpoint callc1b 282 283 # Run; should stop at call1a and print actual arguments. 284 gdb_run_cmd 285 gdb_expect { 286 -re ".* callc1a \\(c=97 'a', s=1, i=2, ui=7, l=3, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc1a" } 287 timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; } 288 } 289 gdb_test "cont" ".* callc1b \\(ldc1=5 \\+ 6 \\* I\\, c=97 'a', s=1, i=2, fc1=1 \\+ 2 \\* I, ui=7, l=3, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc1b" 290} 291 292# 293# Locate actual args; _Complex types and integral/float. 294# 295proc complex_float_integral_args {} { 296 global gdb_prompt 297 298 delete_breakpoints 299 300 gdb_breakpoint callc2a 301 gdb_breakpoint callc2b 302 303 # Run; should stop at call1a and print actual arguments. 304 gdb_run_cmd 305 gdb_expect { 306 -re ".* callc2a \\(c=97 'a', s=1, i=2, ui=7, l=3, f=4, d=5, fc1=1 \\+ 2 \\* I, dc1=3 \\+ 4 \\* I, ldc1=5 \\+ 6 \\* I\\) .*$gdb_prompt $" { pass "run to callc2a" } 307 timeout { fail "(timeout) run to callc1a" ; gdb_suppress_tests; } 308 } 309 gdb_test "cont" ".* callc2b \\(fc1=1 \\+ 2 \\* I, c=97 'a', s=1, i=2, ui=7, ldc1=5 \\+ 6 \\* I\\, l=3, f=4, d=5, dc1=3 \\+ 4 \\* I\\) .*" "continue to callc2b" 310} 311 312# 313# Locate actual args; dereference pointers to ints and floats. 314# 315 316proc pointer_args {} { 317 global gdb_prompt 318 global hex 319 global det_file 320 321 delete_breakpoints 322 323 gdb_breakpoint call3a 324 gdb_breakpoint call3b 325 gdb_breakpoint call3c 326 327 # Run; should stop at call3a and print actual arguments. 328 # Try dereferencing the arguments. 329 330 gdb_run_cmd 331 gdb_expect { 332 -re ".* call3a \\(cp=$hex <c> \"a.*\", sp=$hex <s>, ip=$hex <i>, lp=$hex <l>\\) .*$gdb_prompt $" { pass "run to call3a" } 333 -re "$gdb_prompt $" { fail "run to call3a" ; gdb_suppress_tests; } 334 timeout { fail "(timeout) run to call3a" ; gdb_suppress_tests; } 335 } 336 337 gdb_test "print *cp" ".* = 97 'a'" 338 gdb_test "print *sp" ".* = 1" 339 gdb_test "print *ip" ".* = 2" 340 gdb_test "print *lp" ".* = 3" 341 342 # Continue; should stop at call3b and print actual arguments. 343 # Try dereferencing the arguments. 344 if [gdb_test "cont" ".* call3b \\(ucp=$hex <uc> \"b.*\", usp=$hex <us>, uip=$hex <ui>, ulp=$hex <ul>\\) .*" "continue to call3b"] { 345 gdb_suppress_tests 346 } 347 348 gdb_test "print *ucp" ".* = 98 'b'" 349 gdb_test "print *usp" ".* = 6" 350 gdb_test "print *uip" ".* = 7" 351 gdb_test "print *ulp" ".* = 8" 352 353 # Continue; should stop at call3c and print actual arguments. 354 # Try dereferencing the arguments. 355 if [gdb_test "cont" ".* call3c \\(fp=$hex <f>, dp=$hex <d>\\) .*" "continue to call3c"] { 356 gdb_suppress_tests 357 } 358 359 gdb_test "print *fp" ".* = 4" 360 gdb_test "print *dp" ".* = 5" 361 362# pass "locate actual args, pointer types" 363 gdb_stop_suppressing_tests 364} 365 366# 367# Locate actual args; structures and unions passed by reference. 368# 369 370proc structs_by_reference {} { 371 global gdb_prompt 372 global hex 373 global det_file 374 global target_sizeof_int 375 global target_sizeof_long 376 global target_bigendian_p 377 378 delete_breakpoints 379 380 gdb_breakpoint call4a 381 gdb_breakpoint call4b 382 383 # Run; should stop at call4a and print actual arguments. 384 # Try dereferencing the arguments. 385 386 gdb_run_cmd 387 gdb_expect { 388 -re ".* call4a \\(stp=$hex <st>\\) .*$gdb_prompt $" { 389 pass "run to call4a" 390 } 391 -re "$gdb_prompt $" { fail "run to call4a" ; gdb_suppress_tests; } 392 timeout { fail "(timeout) run to call4a" ; gdb_suppress_tests; } 393 } 394 395 gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}" 396 397 # Continue; should stop at call4b and print actual arguments. 398 399 gdb_test "cont" ".* call4b \\(unp=$hex <un>\\) .*" "continue to call4b" 400 401 # Try dereferencing the arguments. 402 if { $target_sizeof_long == $target_sizeof_int } { 403 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}" \ 404 "print *unp (sizeof long == sizeof int)" 405 } elseif { ! $target_bigendian_p } { 406 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}" \ 407 "print *unp (little-endian, sizeof long != sizeof int)" 408 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } { 409 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 4294967296\}" \ 410 "print *unp (big-endian, sizeof long == 8, sizeof int = 4)" 411 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } { 412 gdb_test "print *unp" ".* = \{u1 = 1, u2 = 65536\}" \ 413 "print *unp (big-endian, sizeof long == 4, sizeof int = 2)" 414 } else { 415 fail "print *unp (unknown case)" 416 } 417 418 pass "locate actual args, structs/unions passed by reference" 419 gdb_stop_suppressing_tests 420} 421 422# 423# Locate actual args; structures and unions passed by value. 424# 425 426proc structs_by_value {} { 427 global gdb_prompt 428 global hex 429 global det_file 430 global target_sizeof_int 431 global target_sizeof_long 432 global target_bigendian_p 433 434 delete_breakpoints 435 436 gdb_breakpoint call5a 437 gdb_breakpoint call5b 438 439 # Run; should stop at call5a and print actual arguments. 440 # Try dereferencing the arguments. 441 442 gdb_run_cmd 443 gdb_expect { 444 -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$gdb_prompt $" { 445 pass "run to call5a" 446 } 447 -re "$gdb_prompt $" { fail "run to call5a" ; gdb_suppress_tests; } 448 timeout { fail "(timeout) run to call5a" ; gdb_suppress_tests; } 449 } 450 451 gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}" 452 453 # Continue; should stop at call5b and print actual arguments. 454 if { $target_sizeof_long == $target_sizeof_int } { 455 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \ 456 "continue to call5b (sizeof long == sizeof int)" 457 } elseif { ! $target_bigendian_p } { 458 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \ 459 "continue to call5b (little-endian, sizeof long != sizeof int)" 460 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } { 461 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 8589934592\}\\) .*" \ 462 "continue to call5b (big-endian, sizeof long == 8, sizeof int = 4)" 463 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } { 464 gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 131072\}\\) .*" \ 465 "continue to call5b (big-endian, sizeof long == 4, sizeof int = 2)" 466 } else { 467 fail "continue to call5b (unknown case)" 468 } 469 470 # Try dereferencing the arguments. 471 if { $target_sizeof_long == $target_sizeof_int } { 472 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}" \ 473 "print un (sizeof long == sizeof int)" 474 } elseif { ! $target_bigendian_p } { 475 gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}" \ 476 "print un (little-endian, sizeof long != sizeof int)" 477 } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } { 478 gdb_test "print un" ".* = \{u1 = 2, u2 = 8589934592\}" \ 479 "print un (big-endian, sizeof long == 8, sizeof int = 4)" 480 } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } { 481 gdb_test "print un" ".* = \{u1 = 2, u2 = 131072\}" \ 482 "print un (big-endian, sizeof long == 4, sizeof int = 2)" 483 } else { 484 fail "print un (unknown case)" 485 } 486 487 gdb_stop_suppressing_tests 488} 489 490# 491# Locate actual args; discard, shuffle, and call 492# 493 494proc discard_and_shuffle {} { 495 global gdb_prompt 496 global hex 497 global decimal 498 global det_file 499 global gcc_compiled 500 501 delete_breakpoints 502 503 gdb_breakpoint call6a 504 gdb_breakpoint call6b 505 gdb_breakpoint call6c 506 gdb_breakpoint call6d 507 gdb_breakpoint call6e 508 gdb_breakpoint call6f 509 gdb_breakpoint call6g 510 gdb_breakpoint call6h 511 512 # Run; should stop at call6a and print actual arguments. 513 # Print backtrace. 514 515 gdb_run_cmd 516 gdb_expect { 517 -re ".*Breakpoint $decimal, call6a .*$gdb_prompt $" { pass "run to call6a" } 518 -re "$gdb_prompt $" { fail "run to call6a" ; gdb_suppress_tests; } 519 timeout { fail "(timeout) run to call6a" ; gdb_suppress_tests; } 520 } 521 522 setup_xfail "rs6000-*-*" 523 524 if {!$gcc_compiled} { 525 setup_xfail "mips-sgi-irix5*" 526 } 527 528 gdb_test_multiple "backtrace 100" "backtrace from call6a" { 529 -re " call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .* main \\(.*\\) .*$gdb_prompt $" { 530 pass "backtrace from call6a" 531 } 532 -re " call6a \\(c=97 'a', s=1, i=2, l=3, f=.*, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .* main \\(.*\\) .*$gdb_prompt $" { 533 xfail "backtrace from call6a" 534 } 535 } 536 537 # Continue; should stop at call6b and print actual arguments. 538 # Print backtrace. 539 540 gdb_continue call6b 541 542 if [gdb_test_sequence "backtrace 100" "backtrace from call6b" { 543 "\[\r\n\]#0 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 544 "\[\r\n\]#1 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 545 "\[\r\n\]#2 .* main \\(.*\\) at " 546 } ] { 547 gdb_suppress_tests 548 } 549 550 # Continue; should stop at call6c and print actual arguments. 551 # Print backtrace. 552 553 gdb_continue call6c 554 555 if [gdb_test_sequence "backtrace 100" "backtrace from call6c" { 556 "\[\r\n\]#0 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 557 "\[\r\n\]#1 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 558 "\[\r\n\]#2 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 559 "\[\r\n\]#3 .* main \\(.*\\) at " 560 } ] { 561 gdb_suppress_tests 562 } 563 # Continue; should stop at call6d and print actual arguments. 564 # Print backtrace. 565 566 gdb_continue call6d 567 568 if [gdb_test_sequence "backtrace 100" "backtrace from call6d" { 569 "\[\r\n\]#0 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 570 "\[\r\n\]#1 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 571 "\[\r\n\]#2 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 572 "\[\r\n\]#3 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 573 "\[\r\n\]#4 .* main \\(.*\\) at " 574 } ] { 575 gdb_suppress_tests 576 } 577 578 # Continue; should stop at call6e and print actual arguments. 579 # Print backtrace. 580 581 gdb_continue call6e 582 583 if [gdb_test_sequence "backtrace 100" "backtrace from call6e" { 584 "\[\r\n\]#0 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 585 "\[\r\n\]#1 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 586 "\[\r\n\]#2 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 587 "\[\r\n\]#3 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 588 "\[\r\n\]#4 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 589 "\[\r\n\]#5 .* main \\(.*\\) at " 590 } ] { 591 gdb_suppress_tests 592 } 593 594 # Continue; should stop at call6f and print actual arguments. 595 # Print backtrace. 596 597 gdb_continue call6f 598 599 if [gdb_test_sequence "backtrace 100" "backtrace from call6f" { 600 "\[\r\n\]#0 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 601 "\[\r\n\]#1 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 602 "\[\r\n\]#2 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 603 "\[\r\n\]#3 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 604 "\[\r\n\]#4 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 605 "\[\r\n\]#5 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 606 "\[\r\n\]#6 .* main \\(.*\\) at " 607 } ] { 608 gdb_suppress_tests 609 } 610 611 # Continue; should stop at call6g and print actual arguments. 612 # Print backtrace. 613 614 gdb_continue call6g 615 616 if [gdb_test_sequence "backtrace 100" "backtrace from call6g" { 617 "\[\r\n\]#0 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) " 618 "\[\r\n\]#1 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 619 "\[\r\n\]#2 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 620 "\[\r\n\]#3 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 621 "\[\r\n\]#4 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 622 "\[\r\n\]#5 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 623 "\[\r\n\]#6 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 624 "\[\r\n\]#7 .* main \\(.*\\) at " 625 } ] { 626 gdb_suppress_tests 627 } 628 629 # Continue; should stop at call6h and print actual arguments. 630 # Print backtrace. 631 632 gdb_continue call6h 633 634 if [gdb_test_sequence "backtrace 100" "backtrace from call6h" { 635 "\[\r\n\]#0 .* call6h \\(us=6, ui=7, ul=8\\) " 636 "\[\r\n\]#1 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) " 637 "\[\r\n\]#2 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 638 "\[\r\n\]#3 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 639 "\[\r\n\]#4 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 640 "\[\r\n\]#5 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 641 "\[\r\n\]#6 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 642 "\[\r\n\]#7 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 643 "\[\r\n\]#8 .* main \\(.*\\) at " 644 } ] { 645 gdb_suppress_tests 646 } 647 648 # monitor only allows 8 breakpoints; w89k board allows 10, so 649 # break them up into two groups. 650 delete_breakpoints 651 gdb_breakpoint call6i 652 gdb_breakpoint call6j 653 gdb_breakpoint call6k 654 655 # Continue; should stop at call6i and print actual arguments. 656 # Print backtrace. 657 658 gdb_continue call6i 659 660 if [gdb_test_sequence "backtrace 100" "backtrace from call6i" { 661 "\[\r\n\]#0 .* call6i \\(ui=7, ul=8\\) " 662 "\[\r\n\]#1 .* call6h \\(us=6, ui=7, ul=8\\) " 663 "\[\r\n\]#2 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) " 664 "\[\r\n\]#3 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 665 "\[\r\n\]#4 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 666 "\[\r\n\]#5 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 667 "\[\r\n\]#6 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 668 "\[\r\n\]#7 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 669 "\[\r\n\]#8 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 670 "\[\r\n\]#9 .* main \\(.*\\) at " 671 } ] { 672 gdb_suppress_tests 673 } 674 675 # Continue; should stop at call6j and print actual arguments. 676 # Print backtrace. 677 678 gdb_continue call6j 679 680 if [gdb_test_sequence "backtrace 100" "backtrace from call6j" { 681 "\[\r\n\]#0 .* call6j \\(ul=8\\) " 682 "\[\r\n\]#1 .* call6i \\(ui=7, ul=8\\) " 683 "\[\r\n\]#2 .* call6h \\(us=6, ui=7, ul=8\\) " 684 "\[\r\n\]#3 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) " 685 "\[\r\n\]#4 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 686 "\[\r\n\]#5 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 687 "\[\r\n\]#6 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 688 "\[\r\n\]#7 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 689 "\[\r\n\]#8 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 690 "\[\r\n\]#9 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 691 "\[\r\n\]#10 .* main \\(.*\\) at " 692 } ] { 693 gdb_suppress_tests 694 } 695 696 # Continue; should stop at call6k and print actual arguments. 697 # Print backtrace. 698 gdb_continue call6k 699 700 if [gdb_test_sequence "backtrace 100" "backtrace from call6k" { 701 "\[\r\n\]#0 .* call6k \\(\\) " 702 "\[\r\n\]#1 .* call6j \\(ul=8\\) " 703 "\[\r\n\]#2 .* call6i \\(ui=7, ul=8\\) " 704 "\[\r\n\]#3 .* call6h \\(us=6, ui=7, ul=8\\) " 705 "\[\r\n\]#4 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) " 706 "\[\r\n\]#5 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 707 "\[\r\n\]#6 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 708 "\[\r\n\]#7 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 709 "\[\r\n\]#8 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 710 "\[\r\n\]#9 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 711 "\[\r\n\]#10 .* call6a \\(c=97 'a', s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " 712 "\[\r\n\]#11 .* main \\(.*\\) at " 713 } ] { 714 gdb_suppress_tests 715 } 716 gdb_stop_suppressing_tests 717} 718 719 720# 721# Locate actual args; shuffle round robin and call 722# 723 724proc shuffle_round_robin {} { 725 global gdb_prompt 726 global hex 727 global decimal 728 global det_file 729 global gcc_compiled 730 731 delete_breakpoints 732 733 gdb_breakpoint call7a 734 gdb_breakpoint call7b 735 gdb_breakpoint call7c 736 gdb_breakpoint call7d 737 gdb_breakpoint call7e 738 gdb_breakpoint call7f 739 gdb_breakpoint call7g 740 gdb_breakpoint call7h 741 742 # Run; should stop at call7a and print actual arguments. 743 # Print backtrace. 744 745 gdb_run_cmd 746 gdb_expect { 747 -re ".*Breakpoint $decimal, call7a .*$gdb_prompt $" { 748 pass "run to call7a" 749 } 750 -re "$gdb_prompt $" { fail "run to call7a" ; gdb_suppress_tests; } 751 timeout { fail "(timeout) run to call7a" ; gdb_suppress_tests; } 752 } 753 754 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } 755 gdb_test_multiple "backtrace 100" "backtrace from call7a" { 756 -re " call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .* main \\(.*\\) .*$gdb_prompt $" { 757 pass "backtrace from call7a" 758 } 759 -re " call7a \\(c=97 'a', i=2, s=1, l=3, f=.*, uc=98 'b', d=5, us=6, ul=8, ui=7\\) .* main \\(.*\\) .*$gdb_prompt $" { 760 xfail "backtrace from call7a" 761 } 762 } 763 764 # Continue; should stop at call7b and print actual arguments. 765 # Print backtrace. 766 767 gdb_continue call7b 768 769 if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } 770 771 gdb_test_sequence "backtrace 100" "backtrace from call7b" { 772 "\[\r\n\]#0 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 773 "\[\r\n\]#1 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 774 "\[\r\n\]#2 .* main \\(.*\\) at " 775 } 776 777 # Continue; should stop at call7c and print actual arguments. 778 # Print backtrace. 779 780 gdb_continue call7c 781 782 gdb_test_sequence "backtrace 100" "backtrace from call7c" { 783 "\[\r\n\]#0 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 784 "\[\r\n\]#1 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 785 "\[\r\n\]#2 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 786 "\[\r\n\]#3 .* main \\(.*\\) at " 787 } 788 789 # Continue; should stop at call7d and print actual arguments. 790 # Print backtrace. 791 792 gdb_continue call7d 793 794 gdb_test_sequence "backtrace 100" "backtrace from call7d" { 795 "\[\r\n\]#0 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) " 796 "\[\r\n\]#1 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 797 "\[\r\n\]#2 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 798 "\[\r\n\]#3 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 799 "\[\r\n\]#4 .* main \\(.*\\) at " 800 } 801 802 gdb_continue call7e 803 804 gdb_test_sequence "backtrace 100" "backtrace from call7e" { 805 "\[\r\n\]#0 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) " 806 "\[\r\n\]#1 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) " 807 "\[\r\n\]#2 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 808 "\[\r\n\]#3 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 809 "\[\r\n\]#4 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 810 "\[\r\n\]#5 .* main \\(.*\\) at " 811 } 812 813 # Continue; should stop at call7f and print actual arguments. 814 # Print backtrace. 815 816 gdb_continue call7f 817 818 gdb_test_sequence "backtrace 100" "backtrace from call7f" { 819 "\[\r\n\]#0 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) " 820 "\[\r\n\]#1 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) " 821 "\[\r\n\]#2 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) " 822 "\[\r\n\]#3 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 823 "\[\r\n\]#4 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 824 "\[\r\n\]#5 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 825 "\[\r\n\]#6 .* main \\(.*\\) at " 826 } 827 828 # Continue; should stop at call7g and print actual arguments. 829 # Print backtrace. 830 831 gdb_continue call7g 832 833 gdb_test_sequence "backtrace 100" "backtrace from call7g" { 834 "\[\r\n\]#0 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) " 835 "\[\r\n\]#1 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) " 836 "\[\r\n\]#2 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) " 837 "\[\r\n\]#3 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) " 838 "\[\r\n\]#4 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 839 "\[\r\n\]#5 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 840 "\[\r\n\]#6 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 841 "\[\r\n\]#7 .* main \\(.*\\) at " 842 } 843 844 gdb_continue call7h 845 846 gdb_test_sequence "backtrace 100" "backtrace from call7h" { 847 "\[\r\n\]#0 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) " 848 "\[\r\n\]#1 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) " 849 "\[\r\n\]#2 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) " 850 "\[\r\n\]#3 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) " 851 "\[\r\n\]#4 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) " 852 "\[\r\n\]#5 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 853 "\[\r\n\]#6 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 854 "\[\r\n\]#7 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 855 "\[\r\n\]#8 .* main \\(.*\\) at " 856 } 857 858 # monitor only allows 8 breakpoints; w89k board allows 10, so 859 # break them up into two groups. 860 delete_breakpoints 861 gdb_breakpoint call7i 862 gdb_breakpoint call7j 863 gdb_breakpoint call7k 864 865 # Continue; should stop at call7i and print actual arguments. 866 # Print backtrace. 867 868 gdb_continue call7i 869 870 gdb_test_sequence "backtrace 100" "backtrace from call7i" { 871 "\[\r\n\]#0 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) " 872 "\[\r\n\]#1 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) " 873 "\[\r\n\]#2 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) " 874 "\[\r\n\]#3 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) " 875 "\[\r\n\]#4 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) " 876 "\[\r\n\]#5 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) " 877 "\[\r\n\]#6 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 878 "\[\r\n\]#7 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 879 "\[\r\n\]#8 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 880 "\[\r\n\]#9 .* main \\(.*\\) at " 881 } 882 883 # Continue; should stop at call7j and print actual arguments. 884 # Print backtrace. 885 886 gdb_continue call7j 887 888 gdb_test_sequence "backtrace 100" "backtrace from call7j" { 889 "\[\r\n\]#0 .* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) " 890 "\[\r\n\]#1 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) " 891 "\[\r\n\]#2 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) " 892 "\[\r\n\]#3 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) " 893 "\[\r\n\]#4 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) " 894 "\[\r\n\]#5 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) " 895 "\[\r\n\]#6 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) " 896 "\[\r\n\]#7 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 897 "\[\r\n\]#8 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 898 "\[\r\n\]#9 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 899 "\[\r\n\]#10 .* main \\(.*\\) at " 900 } 901 902 # Continue; should stop at call7k and print actual arguments. 903 # Print backtrace. 904 905 gdb_continue call7k 906 907 if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" } 908 gdb_test_sequence "backtrace 100" "backtrace from call7k" { 909 "\[\r\n\]#0 .* call7k \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 910 "\[\r\n\]#1 .* call7j \\(ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8\\) " 911 "\[\r\n\]#2 .* call7i \\(ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6\\) " 912 "\[\r\n\]#3 .* call7h \\(us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5\\) " 913 "\[\r\n\]#4 .* call7g \\(d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b'\\) " 914 "\[\r\n\]#5 .* call7f \\(uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3, f=4\\) " 915 "\[\r\n\]#6 .* call7e \\(f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1, l=3\\) " 916 "\[\r\n\]#7 .* call7d \\(l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2, s=1\\) " 917 "\[\r\n\]#8 .* call7c \\(s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a', i=2\\) " 918 "\[\r\n\]#9 .* call7b \\(i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7, c=97 'a'\\) " 919 "\[\r\n\]#10 .* call7a \\(c=97 'a', i=2, s=1, l=3, f=4, uc=98 'b', d=5, us=6, ul=8, ui=7\\) " 920 "\[\r\n\]#11 .* main \\(.*\\) at " 921 } 922 gdb_stop_suppressing_tests 923} 924 925# 926# Locate actual args; recursive passing of structs by value 927# 928 929proc recursive_structs_by_value {} { 930 global gdb_prompt 931 global hex 932 global decimal 933 global det_file 934 935 delete_breakpoints 936 937 gdb_breakpoint hitbottom 938 939 # Run; should stop at hitbottom and print actual arguments. 940 # Print backtrace. 941 gdb_run_cmd 942 gdb_expect { 943 -re ".*Breakpoint $decimal, hitbottom .*$gdb_prompt $" { pass "run to hitbottom" } 944 -re "$gdb_prompt $" { fail "run to hitbottom" ; gdb_suppress_tests; } 945 timeout { fail "(timeout) run to hitbottom" ; gdb_suppress_tests; } 946 } 947 948 if ![istarget sparclet-*-*] { 949 gdb_test_sequence "backtrace 100" "recursive passing of structs by value" { 950 "\[\r\n\]#0 .* hitbottom \\(\\) " 951 "\[\r\n\]#1 .* recurse \\(a=\{s = 0, i = 0, l = 0\}, depth=0\\) " 952 "\[\r\n\]#2 .* recurse \\(a=\{s = 1, i = 1, l = 1\}, depth=1\\) " 953 "\[\r\n\]#3 .* recurse \\(a=\{s = 2, i = 2, l = 2\}, depth=2\\) " 954 "\[\r\n\]#4 .* recurse \\(a=\{s = 3, i = 3, l = 3\}, depth=3\\) " 955 "\[\r\n\]#5 .* recurse \\(a=\{s = 4, i = 4, l = 4\}, depth=4\\) " 956 "\[\r\n\]#6 .* test_struct_args \\(\\) " 957 "\[\r\n\]#7 .* main \\(.*\\) at " 958 } 959 } else { 960 fail "recursive passing of structs by value (sparclet)" 961 } 962 gdb_stop_suppressing_tests 963} 964 965# 966# Test for accessing local stack variables in functions which call alloca 967# 968proc localvars_after_alloca { } { 969 global gdb_prompt 970 global hex 971 global decimal 972 global gcc_compiled 973 974 if { ! [ runto localvars_after_alloca ] } then { gdb_suppress_tests; } 975 976 # Print each arg as a double check to see if we can print 977 # them here as well as with backtrace. 978 979 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 980 gdb_test "print c" " = 97 'a'" "print c after runto localvars_after_alloca" 981 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 982 gdb_test "print s" " = 1" "print s after runto localvars_after_alloca" 983 gdb_test "print i" " = 2" "print i after runto localvars_after_alloca" 984 gdb_test "print l" " = 3" "print l after runto localvars_after_alloca" 985 986 # Lame regexp. 987 gdb_test "next" ".*" "next in localvars_after_alloca()" 988 989 # Print each arg as a double check to see if we can print 990 # them here as well as with backtrace. 991 992 gdb_test "print c" " = 97 'a'" "print c in localvars_after_alloca" 993 gdb_test "print s" " = 1" "print s in localvars_after_alloca" 994 gdb_test "print i" " = 2" "print i in localvars_after_alloca" 995 gdb_test "print l" " = 3" "print l in localvars_after_alloca" 996 997 gdb_test "backtrace 8" "#0.*localvars_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" "backtrace after alloca" 998 gdb_stop_suppressing_tests 999} 1000 1001proc call_after_alloca { } { 1002 global gdb_prompt 1003 global hex 1004 global decimal 1005 global gcc_compiled 1006 1007 if { ! [ runto call_after_alloca_subr ] } then { gdb_suppress_tests; } 1008 1009 # Print each arg as a double check to see if we can print 1010 # them here as well as with backtrace. 1011 1012 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 1013 gdb_test "print c" " = 97 'a'" "print c in call_after_alloca" 1014 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 1015 gdb_test "print s" " = 1" "print s in call_after_alloca" 1016 gdb_test "print i" " = 2" "print i in call_after_alloca" 1017 gdb_test "print l" " = 3" "print l in call_after_alloca" 1018 1019 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 1020 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" 1021 gdb_stop_suppressing_tests 1022} 1023 1024# 1025# Test for accessing local stack variables, backtraces, finish, 1026# and finally stepping into indirect calls. The point is that on the PA 1027# these use a funky `dyncall' mechanism which GDB needs to know about. 1028# 1029proc localvars_in_indirect_call { } { 1030 global gdb_prompt 1031 global hex 1032 global decimal 1033 global gcc_compiled 1034 1035 # Can not use "runto call0a" as call0a is called several times 1036 # during single run. Instead stop in a marker function and 1037 # take control from there. 1038 if { ! [ runto marker_indirect_call ] } then { gdb_suppress_tests; } 1039 1040 # break on the next call to call0a, then delete all the breakpoints 1041 # and start testing. 1042 gdb_breakpoint call0a 1043 gdb_continue call0a 1044 delete_breakpoints 1045 1046 # Print each arg as a double check to see if we can print 1047 # them here as well as with backtrace. 1048 1049 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 1050 gdb_test "print c" " = 97 'a'" "print c in localvars_in_indirect_call" 1051 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 1052 gdb_test "print s" " = 1" "print s in localvars_in_indirect_call" 1053 gdb_test "print i" " = 2" "print i in localvars_in_indirect_call" 1054 gdb_test "print l" " = 3" "print l in localvars_in_indirect_call" 1055 1056 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 1057 gdb_test "backtrace 8" \ 1058 "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \ 1059 "backtrace in indirectly called function" 1060 1061 # 1062 # "finish" brings us back to main. We then will try to step through 1063 # the second indirect call. 1064 # On some targets (e.g. m68k) gdb will stop from the finish in midline 1065 # of the first indirect call. This is due to stack adjustment instructions 1066 # after the indirect call. In these cases we will step till we hit the 1067 # second indirect call. 1068 # 1069 1070 gdb_test_multiple "finish" "finish from indirectly called function" { 1071 -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" { 1072 #On hppa2.0w-hp-hpux11.00, gdb finishes at one line earlier than 1073 #hppa1.1-hp-hpux11.00. Therefore, an extra "step" is necessary 1074 #to continue the test. 1075 send_gdb "step\n" 1076 exp_continue 1077 } 1078 -re ".*\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" { 1079 pass "finish from indirectly called function" 1080 } 1081 -re ".*$gdb_prompt $" { 1082 fail "finish from indirectly called function" 1083 gdb_suppress_tests 1084 } 1085 default { 1086 fail "finish from indirectly called function" 1087 gdb_suppress_tests 1088 } 1089 } 1090 1091 if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 1092 gdb_test "step" "call0a \\(c=97 'a', s=1, i=2, l=3\\).*" \ 1093 "stepping into indirectly called function" 1094 gdb_stop_suppressing_tests 1095} 1096 1097# 1098# Test for stepping into indirect calls which may have trampolines (possibly 1099# cascaded) on both the call path and the gdb_suppress_tests; path. 1100# to handle trampolines. 1101# 1102proc test_stepping_over_trampolines { } { 1103 global gdb_prompt 1104 global hex 1105 global decimal 1106 1107 # Stop in a marker function and take control from there. 1108 if { ! [ runto marker_call_with_trampolines ] } then { gdb_suppress_tests; } 1109 1110 # Cater for gdb stopping in midline, see comment for finish above. 1111 gdb_test_multiple "finish" "finish from marker_call_with_trampolines" { 1112 -re "marker_call_with_trampolines ..;.*$gdb_prompt $" { 1113 send_gdb "step\n" 1114 exp_continue 1115 } 1116 -re "pointer_to_call_with_trampolines.*$gdb_prompt $" { 1117 pass "finish from marker_call_with_trampolines" 1118 } 1119 -re ".*$gdb_prompt $" { 1120 fail "finish from marker_call_with_trampolines" 1121 } 1122 default { 1123 fail "finish from marker_call_with_trampolines" 1124 gdb_suppress_tests 1125 } 1126 } 1127 1128 # Try to step into the target function. 1129 gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \ 1130 "stepping into function called with trampolines" 1131 1132 # Make we can backtrace and the argument looks correct. */ 1133 gdb_test "backtrace 8" "#0.*call_with_trampolines \\(d1=5\\).*1.*main.*" \ 1134 "backtrace through call with trampolines" 1135 1136 # Make sure we can get back to main. 1137 # Stepping back to main might stop again after the gdb_suppress_tests; statement 1138 # or immediately transfer control back to main if optimizations 1139 # are performed. 1140 gdb_test_multiple "step" "stepping back to main from function called with trampolines" { 1141 -re "main .* at.*$gdb_prompt $" { 1142 pass "stepping back to main from function called with trampolines" 1143 gdb_suppress_tests 1144 } 1145 -re "\}.*End of call_with_trampolines.*$gdb_prompt $" { 1146 send_gdb "step\n" 1147 exp_continue 1148 } 1149 -re ".*$gdb_prompt $" { 1150 fail "stepping back to main from function called with trampolines" 1151 } 1152 default { 1153 fail "stepping back to main from function called with trampolines" 1154 gdb_suppress_tests 1155 } 1156 } 1157 gdb_stop_suppressing_tests 1158} 1159 1160set prev_timeout $timeout 1161if [istarget "mips*tx39-*"] { 1162 set timeout 300 1163} else { 1164 set timeout 60 1165} 1166 1167# Determine expected output for unsigned long variables, 1168# the output varies with sizeof (unsigned long). 1169 1170gdb_test_multiple "print sizeof (long)" "getting sizeof long" { 1171 -re ".\[0-9\]* = 4.*$gdb_prompt $" { 1172 set target_sizeof_long 4 1173 # pass silently 1174 } 1175 -re ".\[0-9\]* = 8.*$gdb_prompt $" { 1176 set target_sizeof_long 8 1177 # pass silently 1178 } 1179} 1180 1181gdb_test_multiple "print sizeof (int)" "getting sizeof int" { 1182 -re ".\[0-9\]* = 2.*$gdb_prompt $" { 1183 set target_sizeof_int 2 1184 # pass silently 1185 } 1186 -re ".\[0-9\]* = 4.*$gdb_prompt $" { 1187 set target_sizeof_int 4 1188 # pass silently 1189 } 1190 -re ".\[0-9\]* = 8.*$gdb_prompt $" { 1191 set target_sizeof_int 8 1192 # pass silently 1193 } 1194} 1195 1196gdb_test_multiple "show endian" "getting target endian" { 1197 -re ".*little endian.*$gdb_prompt $" { 1198 set target_bigendian_p 0 1199 # pass silently 1200 } 1201 -re ".*big endian.*$gdb_prompt $" { 1202 set target_bigendian_p 1 1203 # pass silently 1204 } 1205} 1206 1207# Perform tests 1208 1209gdb_test_no_output "set print frame-arguments all" 1210 1211integral_args 1212unsigned_integral_args 1213if {![target_info exists gdb,skip_float_tests]} { 1214 float_and_integral_args 1215} 1216 1217# Test _Complex type here if supported. 1218if [support_complex_tests] { 1219 complex_args 1220 1221 complex_integral_args 1222 1223 if {![target_info exists gdb,skip_float_tests]} { 1224 complex_float_integral_args 1225 } 1226} 1227 1228pointer_args 1229structs_by_reference 1230structs_by_value 1231discard_and_shuffle 1232shuffle_round_robin 1233recursive_structs_by_value 1234localvars_after_alloca 1235call_after_alloca 1236localvars_in_indirect_call 1237test_stepping_over_trampolines 1238 1239set timeout $prev_timeout 1240