xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/func-ptrs.exp (revision 16dce51364ebe8aeafbae46bc5aa167b8115bc45)
1# Copyright 2014-2016 Free Software Foundation, Inc.
2
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.
7#
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.
12#
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/>.
15
16set testname func-ptrs
17set srcfile ${testname}.c
18if { [prepare_for_testing ${testname}.exp ${testname} ${srcfile}] } {
19    return -1
20}
21
22if { ![runto_main] } {
23    untested ${testname}.exp
24    return -1
25}
26
27
28# First set our breakpoints.
29
30set fp_breakpoint_re \
31    "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal\\."
32gdb_test "break sentinel if calc == decr" \
33    "${fp_breakpoint_re}" \
34    "breakpoint at sentinel"
35gdb_test "break incr" \
36    "${fp_breakpoint_re}" \
37    "breakpoint at incr"
38gdb_test "break decr" \
39    "${fp_breakpoint_re}" \
40    "breakpoint at decr"
41
42
43# Check if we run through to the breakpoint in incr.
44
45gdb_test "continue" \
46    "Breakpoint $decimal, incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
47    "continue to incr, first time"
48
49
50# Go back up, make sure the return value is 0.
51
52gdb_test "finish" \
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"
55
56
57# Redirect calc and see if we run to the breakpoint in decr instead.
58
59gdb_test_no_output "set calc = decr" "set calc to decr"
60gdb_test "continue" \
61    "Breakpoint $decimal, decr \\(i=0\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
62    "continue to decr"
63
64
65# Go back up, check if we stop in sentinel instead.
66
67gdb_test "finish" \
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\]+.*" \
69    "stop in sentinel"
70
71
72# Go back all the way up to main, make sure the return value is -1.
73
74gdb_test_no_output "up-silently" "move up to decr"
75gdb_test "finish" \
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"
78
79
80# Reset calc and see if we run to the breakpoint in incr again.
81
82gdb_test_no_output "set calc = incr" "set calc to incr"
83gdb_test "continue" \
84    "Breakpoint $decimal, incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
85    "continue to incr, second time"
86
87
88# Go back up again, make sure the return value is 0.
89
90gdb_test "finish" \
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"
93
94
95# All done!
96