📄 funcargs.exp
字号:
}## Locate actual args; structures and unions passed by reference.#proc structs_by_reference {} { global gdb_prompt global hex global det_file global target_sizeof_int global target_sizeof_long global target_bigendian_p delete_breakpoints gdb_breakpoint call4a gdb_breakpoint call4b # Run; should stop at call4a and print actual arguments. # Try dereferencing the arguments. # The a29k fails all of these tests, perhaps because the prologue # code is broken. setup_xfail "a29k-*-udi" gdb_run_cmd gdb_expect { -re ".* call4a \\(stp=$hex\\) .*$gdb_prompt $" { pass "run to call4a" } -re "$gdb_prompt $" { fail "run to call4a" ; gdb_suppress_tests; } timeout { fail "(timeout) run to call4a" ; gdb_suppress_tests; } } gdb_test "print *stp" ".* = \{s1 = 101, s2 = 102\}" # Continue; should stop at call4b and print actual arguments. gdb_test "cont" ".* call4b \\(unp=$hex\\) .*" "continue to call4b" # Try dereferencing the arguments. if { $target_sizeof_long == $target_sizeof_int } { gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}" \ "print *unp (sizeof long == sizeof int)" } elseif { ! $target_bigendian_p } { gdb_test "print *unp" ".* = \{u1 = 1, u2 = 1\}" \ "print *unp (little-endian, sizeof long != sizeof int)" } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } { gdb_test "print *unp" ".* = \{u1 = 1, u2 = 4294967296\}" \ "print *unp (big-endian, sizeof long == 8, sizeof int = 4)" } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } { gdb_test "print *unp" ".* = \{u1 = 1, u2 = 65536\}" \ "print *unp (big-endian, sizeof long == 4, sizeof int = 2)" } else { fail "print *unp (unknown case)" } pass "locate actual args, structs/unions passed by reference" gdb_stop_suppressing_tests;}## Locate actual args; structures and unions passed by value.#proc structs_by_value {} { global gdb_prompt global hex global det_file global target_sizeof_int global target_sizeof_long global target_bigendian_p delete_breakpoints gdb_breakpoint call5a gdb_breakpoint call5b # Run; should stop at call5a and print actual arguments. # Try dereferencing the arguments. # The a29k fails all of these tests, perhaps because the prologue # code is broken. setup_xfail "a29k-*-udi" gdb_run_cmd gdb_expect { -re ".* call5a \\(st=\{s1 = 101, s2 = 102\}\\) .*$gdb_prompt $" { pass "run to call5a" } -re "$gdb_prompt $" { fail "run to call5a" ; gdb_suppress_tests; } timeout { fail "(timeout) run to call5a" ; gdb_suppress_tests; } } gdb_test "print st" ".* = \{s1 = 101, s2 = 102\}" # Continue; should stop at call5b and print actual arguments. if { $target_sizeof_long == $target_sizeof_int } { gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \ "continue to call5b (sizeof long == sizeof int)" } elseif { ! $target_bigendian_p } { gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 2\}\\) .*" \ "continue to call5b (little-endian, sizeof long != sizeof int)" } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } { gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 8589934592\}\\) .*" \ "continue to call5b (big-endian, sizeof long == 8, sizeof int = 4)" } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } { gdb_test "cont" ".* call5b \\(un=\{u1 = 2, u2 = 131072\}\\) .*" \ "continue to call5b (big-endian, sizeof long == 4, sizeof int = 2)" } else { fail "continue to call5b (unknown case)" } # Try dereferencing the arguments. if { $target_sizeof_long == $target_sizeof_int } { gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}" \ "print un (sizeof long == sizeof int)" } elseif { ! $target_bigendian_p } { gdb_test "print un" ".* = \{u1 = 2, u2 = 2\}" \ "print un (little-endian, sizeof long != sizeof int)" } elseif { $target_sizeof_long == 8 && $target_sizeof_int == 4 } { gdb_test "print un" ".* = \{u1 = 2, u2 = 8589934592\}" \ "print un (big-endian, sizeof long == 8, sizeof int = 4)" } elseif { $target_sizeof_long == 4 && $target_sizeof_int == 2 } { gdb_test "print un" ".* = \{u1 = 2, u2 = 131072\}" \ "print un (big-endian, sizeof long == 4, sizeof int = 2)" } else { fail "print un (unknown case)" } gdb_stop_suppressing_tests;}## Locate actual args; discard, shuffle, and call#proc discard_and_shuffle {} { global gdb_prompt global hex global decimal global det_file global gcc_compiled global hp_cc_compiler delete_breakpoints gdb_breakpoint call6a gdb_breakpoint call6b gdb_breakpoint call6c gdb_breakpoint call6d gdb_breakpoint call6e gdb_breakpoint call6f gdb_breakpoint call6g gdb_breakpoint call6h # Run; should stop at call6a and print actual arguments. # Print backtrace. # The a29k fails all of these tests, perhaps because the prologue # code is broken. setup_xfail "a29k-*-udi" gdb_run_cmd gdb_expect { -re ".*Breakpoint $decimal, call6a .*$gdb_prompt $" { pass "run to call6a" } -re "$gdb_prompt $" { fail "run to call6a" ; gdb_suppress_tests; } timeout { fail "(timeout) run to call6a" ; gdb_suppress_tests; } } setup_xfail "rs6000-*-*" if {!$gcc_compiled} { setup_xfail "mips-sgi-irix5*" } # The debug info. for "f" is not correct. It's a known bug. if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" gdb_expect { -re "backtrace 100\[\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.* main \\(.*\\) .*\r$gdb_prompt $" { pass "backtrace from call6a" } -re "backtrace 100\[\r\n\]+.* call6a \\(c=97 'a', s=1, i=2, l=3, f=.*, d=5, uc=98 'b', us=6, ui=7, ul=8\\) .*\r.* main \\(.*\\) .*\r$gdb_prompt $" { xfail "backtrace from call6a" } -re "$gdb_prompt $" { fail "backtrace from call6a" gdb_suppress_tests } timeout { fail "(timeout) backtrace from call6a" gdb_suppress_tests } } # Continue; should stop at call6b and print actual arguments. # Print backtrace. gdb_continue call6b if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6b" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\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\\) " ".*\[\r\n\]#2 .* main \\(.*\\) " } ] { gdb_suppress_tests; } # Continue; should stop at call6c and print actual arguments. # Print backtrace. gdb_continue call6c if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6c" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#1 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\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\\) " ".*\[\r\n\]#3 .* main \\(.*\\) " } ] { gdb_suppress_tests; } # Continue; should stop at call6d and print actual arguments. # Print backtrace. gdb_continue call6d if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6d" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#1 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#2 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\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\\) " ".*\[\r\n\]#4 .* main \\(.*\\) " } ] { gdb_suppress_tests; } # Continue; should stop at call6e and print actual arguments. # Print backtrace. gdb_continue call6e if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6e" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#1 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#2 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#3 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\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\\) " ".*\[\r\n\]#5 .* main \\(.*\\) " } ] { gdb_suppress_tests; } # Continue; should stop at call6f and print actual arguments. # Print backtrace. gdb_continue call6f if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6f" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#1 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#2 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#3 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#4 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\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\\) " ".*\[\r\n\]#6 .* main \\(.*\\) " } ] { gdb_suppress_tests; } # Continue; should stop at call6g and print actual arguments. # Print backtrace. gdb_continue call6g if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6g" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#1 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#2 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#3 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#4 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#5 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\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\\) " ".*\[\r\n\]#7 .* main \\(.*\\) " } ] { gdb_suppress_tests; } # Continue; should stop at call6h and print actual arguments. # Print backtrace. gdb_continue call6h if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6h" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6h \\(us=6, ui=7, ul=8\\) " ".*\[\r\n\]#1 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#2 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#3 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#4 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#5 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\r\n\]#6 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " ".*\[\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\\) " ".*\[\r\n\]#8 .* main \\(.*\\) " } ] { gdb_suppress_tests;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -