📄 funcargs.exp
字号:
delete_breakpoints gdb_breakpoint hitbottom # Run; should stop at hitbottom and print actual arguments. # Print backtrace. gdb_run_cmd gdb_expect { -re ".*Breakpoint $decimal, hitbottom .*$gdb_prompt $" { pass "run to hitbottom" } -re "$gdb_prompt $" { fail "run to hitbottom" ; gdb_suppress_tests; } timeout { fail "(timeout) run to hitbottom" ; gdb_suppress_tests; } } if ![istarget sparclet-*-*] { # The a29k fails all of these tests, perhaps because the prologue # code is broken. setup_xfail "a29k-*-udi" send_gdb "backtrace 100\n" gdb_expect_list "recursive passing of structs by value" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* hitbottom \\(\\) " ".*\[\r\n\]#1 .* recurse \\(a=\{s = 0, i = 0, l = 0\}, depth=0\\) " ".*\[\r\n\]#2 .* recurse \\(a=\{s = 1, i = 1, l = 1\}, depth=1\\) " ".*\[\r\n\]#3 .* recurse \\(a=\{s = 2, i = 2, l = 2\}, depth=2\\) " ".*\[\r\n\]#4 .* recurse \\(a=\{s = 3, i = 3, l = 3\}, depth=3\\) " ".*\[\r\n\]#5 .* recurse \\(a=\{s = 4, i = 4, l = 4\}, depth=4\\) " ".*\[\r\n\]#6 .* test_struct_args \\(\\) " ".*\[\r\n\]#7 .* main \\(.*\\) " } } else { fail "recursive passing of structs by value (sparclet)" } gdb_stop_suppressing_tests;}proc funcargs_reload { } { global objdir global subdir global binfile global srcdir if [istarget "mips-idt-*"] { # Restart because IDT/SIM runs out of file descriptors. gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} }}## Test for accessing local stack variables in functions which call alloca#proc localvars_after_alloca { } { global gdb_prompt global hex global decimal global gcc_compiled if { ! [ runto localvars_after_alloca ] } then { gdb_suppress_tests; } # Print each arg as a double check to see if we can print # them here as well as with backtrace. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_test "print c" " = 97 'a'" "print c after runto localvars_after_alloca" if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_test "print s" " = 1" "print s after runto localvars_after_alloca" gdb_test "print i" " = 2" "print i after runto localvars_after_alloca" gdb_test "print l" " = 3" "print l after runto localvars_after_alloca" # Lame regexp. gdb_test "next" ".*" "next in localvars_after_alloca()" # Print each arg as a double check to see if we can print # them here as well as with backtrace. gdb_test "print c" " = 97 'a'" "print c in localvars_after_alloca" gdb_test "print s" " = 1" "print s in localvars_after_alloca" gdb_test "print i" " = 2" "print i in localvars_after_alloca" gdb_test "print l" " = 3" "print l in localvars_after_alloca" gdb_test "backtrace 8" "#0.*localvars_after_alloca \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" "backtrace after alloca" gdb_stop_suppressing_tests;}proc call_after_alloca { } { global gdb_prompt global hex global decimal global gcc_compiled if { ! [ runto call_after_alloca_subr ] } then { gdb_suppress_tests; } # Print each arg as a double check to see if we can print # them here as well as with backtrace. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_test "print c" " = 97 'a'" "print c in call_after_alloca" if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_test "print s" " = 1" "print s in call_after_alloca" gdb_test "print i" " = 2" "print i in call_after_alloca" gdb_test "print l" " = 3" "print l in call_after_alloca" if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } 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" gdb_stop_suppressing_tests;}## Test for accessing local stack variables, backtraces, finish,# and finally stepping into indirect calls. The point is that on the PA# these use a funky `dyncall' mechanism which GDB needs to know about.#proc localvars_in_indirect_call { } { global gdb_prompt global hex global decimal global gcc_compiled # Can not use "runto call0a" as call0a is called several times # during single run. Instead stop in a marker function and # take control from there. if { ! [ runto marker_indirect_call ] } then { gdb_suppress_tests; } # break on the next call to call0a, then delete all the breakpoints # and start testing. gdb_breakpoint call0a gdb_continue call0a delete_breakpoints # Print each arg as a double check to see if we can print # them here as well as with backtrace. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_test "print c" " = 97 'a'" "print c in localvars_in_indirect_call" if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_test "print s" " = 1" "print s in localvars_in_indirect_call" gdb_test "print i" " = 2" "print i in localvars_in_indirect_call" gdb_test "print l" " = 3" "print l in localvars_in_indirect_call" if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_test "backtrace 8" \ "#0.*call0a \\(c=97 'a', s=1, i=2, l=3\\).*#1.*main.*" \ "backtrace in indirectly called function" # # "finish" brings us back to main. We then will try to step through # the second indirect call. # On some targets (e.g. m68k) gdb will stop from the finish in midline # of the first indirect call. This is due to stack adjustment instructions # after the indirect call. In these cases we will step till we hit the # second indirect call. # send_gdb "finish\n" gdb_expect { -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" {#On hppa2.0w-hp-hpux11.00, gdb finishes at one line earlier than #hppa1.1-hp-hpux11.00. Therefore, an extra "step" is necessary to continue the test. send_gdb "step\n" exp_continue } -re ".*\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" { pass "finish from indirectly called function" } -re ".*$gdb_prompt $" { fail "finish from indirectly called function" gdb_suppress_tests; } default { fail "finish from indirectly called function" ; gdb_suppress_tests; } } if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_test "step" "call0a \\(c=97 'a', s=1, i=2, l=3\\).*" \ "stepping into indirectly called function" gdb_stop_suppressing_tests;}## Test for stepping into indirect calls which may have trampolines (possibly# cascaded) on both the call path and the gdb_suppress_tests; path.# to handle trampolines.#proc test_stepping_over_trampolines { } { global gdb_prompt global hex global decimal # Stop in a marker function and take control from there. if { ! [ runto marker_call_with_trampolines ] } then { gdb_suppress_tests; } # Cater for gdb stopping in midline, see comment for finish above. send_gdb "finish\n" gdb_expect { -re "marker_call_with_trampolines ..;.*$gdb_prompt $" { send_gdb "step\n" exp_continue } -re "pointer_to_call_with_trampolines.*$gdb_prompt $" { pass "finish from marker_call_with_trampolines" } -re ".*$gdb_prompt $" { fail "finish from marker_call_with_trampolines" } default { fail "finish from marker_call_with_trampolines" ; gdb_suppress_tests; } } # Try to step into the target function. gdb_test "step" "call_with_trampolines \\(d1=5\\).*" \ "stepping into function called with trampolines" # Make we can backtrace and the argument looks correct. */ gdb_test "backtrace 8" "#0.*call_with_trampolines \\(d1=5\\).*1.*main.*" \ "backtrace through call with trampolines" # Make sure we can get back to main. # Stepping back to main might stop again after the gdb_suppress_tests; statement # or immediately transfer control back to main if optimizations # are performed. send_gdb "step\n" gdb_expect { -re "main .* at.*$gdb_prompt $" { pass "stepping back to main from function called with trampolines" ; gdb_suppress_tests } -re "\}.*End of call_with_trampolines.*$gdb_prompt $" { send_gdb "step\n" exp_continue } -re ".*$gdb_prompt $" { fail "stepping back to main from function called with trampolines" } default { fail "stepping back to main from function called with trampolines" ; gdb_suppress_tests; } } gdb_stop_suppressing_tests;}# Start with a fresh gdb.gdb_exitgdb_startgdb_reinitialize_dir $srcdir/$subdirgdb_load ${binfile}if [istarget "mips*tx39-*"] { set timeout 300} elseif [istarget "hppa*-hp-hpux*"] then { set timeout 240} else { set timeout 60}# Determine expected output for unsigned long variables,# the output varies with sizeof (unsigned long).set target_sizeof_long 4send_gdb "print sizeof (long)\n"gdb_expect { -re ".\[0-9\]* = 4.*$gdb_prompt $" { } -re ".\[0-9\]* = 8.*$gdb_prompt $" { set target_sizeof_long 8 } -re ".*$gdb_prompt $" { fail "getting sizeof long" } default { fail "(timeout) getting sizeof long" }}set target_sizeof_int 4send_gdb "print sizeof (int)\n"gdb_expect { -re ".\[0-9\]* = 2.*$gdb_prompt $" { set target_sizeof_int 2 } -re ".\[0-9\]* = 4.*$gdb_prompt $" { } -re ".\[0-9\]* = 8.*$gdb_prompt $" { set target_sizeof_int 8 } -re ".*$gdb_prompt $" { fail "getting sizeof unsigned long" } default { fail "(timeout) getting sizeof int" }}set target_bigendian_p 1send_gdb "show endian\n"gdb_expect { -re ".*little endian.*$gdb_prompt $" { set target_bigendian_p 0 } -re ".*big endian.*$gdb_prompt $" { } -re ".*$gdb_prompt $" { fail "getting target endian" } default { fail "(timeout) getting target endian" }}# Perform testsintegral_argsfuncargs_reloadunsigned_integral_argsfuncargs_reloadif {![target_info exists gdb,skip_float_tests]} { float_and_integral_args}funcargs_reloadpointer_argsfuncargs_reloadstructs_by_referencefuncargs_reloadstructs_by_valuefuncargs_reloaddiscard_and_shufflefuncargs_reloadshuffle_round_robinfuncargs_reloadrecursive_structs_by_valuefuncargs_reloadlocalvars_after_allocafuncargs_reloadcall_after_allocafuncargs_reloadlocalvars_in_indirect_callfuncargs_reloadtest_stepping_over_trampolines
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -