📄 funcargs.exp
字号:
# Copyright (C) 1992, 1994, 1995, 1997 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 2 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, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # 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}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."}# 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. # The a29k fails all of these tests, perhaps because the prologue # code is broken. setup_xfail "a29k-*-udi" 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. # The a29k fails all of these tests, perhaps because the prologue # code is broken. setup_xfail "a29k-*-udi" 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 global hp_cc_compiler 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. setup_xfail "i960-*-*" 1813 # The a29k fails all of these tests, perhaps because the prologue # code is broken. setup_xfail "a29k-*-udi" if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } # The debug info. for "f" is not correct. It's a known bug. if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} 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" if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} 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" if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} 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 {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} 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; } if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # 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; } if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # 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; } if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # 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; } if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # 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; } if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # 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; } if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # 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 if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # 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. # The a29k fails all of these tests, perhaps because the prologue # code is broken. setup_xfail "a29k-*-udi" 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -