📄 funcargs.exp
字号:
# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004,# 2007, 2008 Free Software Foundation, Inc.# This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 3 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program. If not, see <http://www.gnu.org/licenses/>.# Please email any bugs, comments, and/or additions to this file to:# bug-gdb@prep.ai.mit.edu# This file was written by Fred Fish. (fnf@cygnus.com)if $tracelevel { strace $tracelevel}set prms_id 0set bug_id 0set testfile "funcargs"set srcfile ${testfile}.cset binfile ${objdir}/${subdir}/${testfile}if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { untested funcargs.exp return -1}# Create and source the file that provides information about the compiler# used to compile the test case.if [get_compiler_info ${binfile}] { return -1;}## Locate actual args; integral types.#proc integral_args {} { global gdb_prompt global det_file global gcc_compiled delete_breakpoints gdb_breakpoint call0a gdb_breakpoint call0b gdb_breakpoint call0c gdb_breakpoint call0d gdb_breakpoint call0e # Run; should stop at call0a and print actual arguments. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_run_cmd gdb_expect { -re ".* call0a \\(c=97 'a', s=1, i=2, l=3\\) .*$gdb_prompt $" { pass "run to call0a" } -re "$gdb_prompt $" { fail "run to call0a" ; gdb_suppress_tests } timeout { fail "(timeout) run to call0a" ; gdb_suppress_tests } } # 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 after run to call0a" gdb_test "print s" ".* = 1" "print s after run to call0a" gdb_test "print i" ".* = 2" "print i after run to call0a" gdb_test "print l " ".* = 3" "print l after run to call0a" # Continue; should stop at call0b and print actual arguments. if [gdb_test "cont" ".* call0b \\(s=1, i=2, l=3, c=97 'a'\\) .*" "continue to call0b"] { gdb_suppress_tests; } # Continue; should stop at call0c and print actual arguments. if [gdb_test "cont" ".* call0c \\(i=2, l=3, c=97 'a', s=1\\) .*" "continue to call0c"] { gdb_suppress_tests; } # Continue; should stop at call0d and print actual arguments. if [gdb_test "cont" ".* call0d \\(l=3, c=97 'a', s=1, i=2\\) .*" "continue to call0d";] { gdb_suppress_tests; } # Continue; should stop at call0e and print actual arguments. 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" ] { gdb_suppress_tests; } gdb_stop_suppressing_tests;}## Locate actual args; unsigned integral types.#proc unsigned_integral_args {} { global gdb_prompt global det_file global gcc_compiled delete_breakpoints gdb_breakpoint call1a; gdb_breakpoint call1b; gdb_breakpoint call1c; gdb_breakpoint call1d; gdb_breakpoint call1e; # Run; should stop at call1a and print actual arguments. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" } gdb_run_cmd gdb_expect { -re ".* call1a \\(uc=98 'b', us=6, ui=7, ul=8\\) .*$gdb_prompt $" { pass "run to call1a" } -re "$gdb_prompt $" { fail "run to call1a" ; gdb_suppress_tests; } timeout { fail "(timeout) run to call1a" ; gdb_suppress_tests; } } # Print each arg as a double check to see if we can print # them here as well as with backtrace. gdb_test "print uc" ".* = 98 'b'" gdb_test "print us" ".* = 6" gdb_test "print ui" ".* = 7" gdb_test "print ul" ".* = 8" # Continue; should stop at call1b and print actual arguments. if [gdb_test "cont" ".* call1b \\(us=6, ui=7, ul=8, uc=98 'b'\\) .*" "continue to call1b"] { gdb_suppress_tests; } # Continue; should stop at call1c and print actual arguments. if [gdb_test "cont" ".* call1c \\(ui=7, ul=8, uc=98 'b', us=6\\) .*" "continue to call1c"] { gdb_suppress_tests; } # Continue; should stop at call1d and print actual arguments. if [gdb_test "cont" ".* call1d \\(ul=8, uc=98 'b', us=6, ui=7\\) .*" "continue to call1d"] { gdb_suppress_tests; } # Continue; should stop at call1e and print actual arguments. 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"] { gdb_suppress_tests; } gdb_stop_suppressing_tests;}## Locate actual args; integrals mixed with floating point.#proc float_and_integral_args {} { global gdb_prompt global det_file global gcc_compiled delete_breakpoints gdb_breakpoint call2a gdb_breakpoint call2b gdb_breakpoint call2c gdb_breakpoint call2d gdb_breakpoint call2e gdb_breakpoint call2f gdb_breakpoint call2g gdb_breakpoint call2h # Run; should stop at call2a and print actual arguments. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } gdb_run_cmd gdb_expect { -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" } -re ".* call2a \\(c=97 'a', f1=.*, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" { xfail "run to call2a" } -re "$gdb_prompt $" { fail "run to call2a" ; gdb_suppress_tests; } timeout { fail "(timeout) run to call2a" ; gdb_suppress_tests; } } # Print each arg as a double check to see if we can print gdb_test "print c" ".* = 97 'a'" "print c after run to call2a" gdb_test "print f1" ".* = 4" "print f1 after run to call2a" gdb_test "print s" ".* = 1" "print s after run to call2a" gdb_test "print d1" ".* = 5" "print d1 after run to call2a" gdb_test "print i" ".* = 2" "print i after run to call2a" gdb_test "print f2" ".* = 4" "print f2 after run to call2a" gdb_test "print l" ".* = 3" "print l after run to call2a" gdb_test "print d2" ".* = 5" "print d2 after run to call2a" setup_xfail "rs6000-*-*" if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" } # Continue; should stop at call2b and print actual arguments. 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"] { gdb_suppress_tests; } # Continue; should stop at call2c and print actual arguments. 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"] { gdb_suppress_tests; } # Continue; should stop at call2d and print actual arguments. 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"] { gdb_suppress_tests; } # Continue; should stop at call2e and print actual arguments. 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"] { gdb_suppress_tests; } # Continue; should stop at call2f and print actual arguments. 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"] { gdb_suppress_tests; } # Continue; should stop at call2g and print actual arguments. 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"] { gdb_suppress_tests; } # Continue; should stop at call2h and print actual arguments. 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"] { gdb_suppress_tests; } # monitor only allows 8 breakpoints; w89k board allows 10, so # break them up into two groups. delete_breakpoints gdb_breakpoint call2i # Continue; should stop at call2i and print actual arguments. 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"] { gdb_suppress_tests; } gdb_stop_suppressing_tests;}## Locate actual args; dereference pointers to ints and floats.#proc pointer_args {} { global gdb_prompt global hex global det_file delete_breakpoints gdb_breakpoint call3a gdb_breakpoint call3b gdb_breakpoint call3c # Run; should stop at call3a and print actual arguments. # Try dereferencing the arguments. gdb_run_cmd gdb_expect { -re ".* call3a \\(cp=$hex \"a.*\", sp=$hex, ip=$hex, lp=$hex\\) .*$gdb_prompt $" { pass "run to call3a" } -re "$gdb_prompt $" { fail "run to call3a" ; gdb_suppress_tests; } timeout { fail "(timeout) run to call3a" ; gdb_suppress_tests; } } gdb_test "print *cp" ".* = 97 'a'" gdb_test "print *sp" ".* = 1" gdb_test "print *ip" ".* = 2" gdb_test "print *lp" ".* = 3" # Continue; should stop at call3b and print actual arguments. # Try dereferencing the arguments. if [gdb_test "cont" ".* call3b \\(ucp=$hex \"b.*\", usp=$hex, uip=$hex, ulp=$hex\\) .*" "continue to call3b"] { gdb_suppress_tests; } gdb_test "print *ucp" ".* = 98 'b'" gdb_test "print *usp" ".* = 6" gdb_test "print *uip" ".* = 7" gdb_test "print *ulp" ".* = 8" # Continue; should stop at call3c and print actual arguments. # Try dereferencing the arguments. if [gdb_test "cont" ".* call3c \\(fp=$hex, dp=$hex\\) .*" "continue to call3c"] { gdb_suppress_tests; } gdb_test "print *fp" ".* = 4" gdb_test "print *dp" ".* = 5"# pass "locate actual args, pointer types" gdb_stop_suppressing_tests;}## 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. 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. 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 } {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -