1 # Copyright 2014 Free Software Foundation, Inc.
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.
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.
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/>.
16 set testname func-ptrs
17 set srcfile ${testname}.c
18 if { [prepare_for_testing ${testname}.exp ${testname} ${srcfile}] } {
22 if { ![runto_main] } {
23 untested ${testname}.exp
28 # First set our breakpoints.
30 set fp_breakpoint_re \
31 "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal\\."
32 gdb_test "break sentinel if calc == decr" \
33 "${fp_breakpoint_re}" \
34 "breakpoint at sentinel"
35 gdb_test "break incr" \
36 "${fp_breakpoint_re}" \
38 gdb_test "break decr" \
39 "${fp_breakpoint_re}" \
43 # Check if we run through to the breakpoint in incr.
46 "Breakpoint $decimal, incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
47 "continue to incr, first time"
50 # Go back up, make sure the return value is 0.
53 "Run till exit from #0 +incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is \\$$decimal = 0" \
54 "go back to main from incr, first time"
57 # Redirect calc and see if we run to the breakpoint in decr instead.
59 gdb_test_no_output "set calc = decr" "set calc to decr"
61 "Breakpoint $decimal, decr \\(i=0\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
65 # Go back up, check if we stop in sentinel instead.
68 "Run till exit from #0 +decr \\(i=0\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+Breakpoint $decimal, sentinel \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
72 # Go back all the way up to main, make sure the return value is -1.
74 gdb_test_no_output "up-silently" "move up to decr"
76 "Run till exit from #1 +($hex in )?decr \\(i=0\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is \\$$decimal = -1" \
77 "go back to main from decr"
80 # Reset calc and see if we run to the breakpoint in incr again.
82 gdb_test_no_output "set calc = incr" "set calc to incr"
84 "Breakpoint $decimal, incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
85 "continue to incr, second time"
88 # Go back up again, make sure the return value is 0.
91 "Run till exit from #0 +incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+($hex in )?main \\(\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*Value returned is \\$$decimal = 0" \
92 "go back to main from incr, second time"