]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/func-ptrs.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / func-ptrs.exp
1 # Copyright 2014-2023 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
16 set testname func-ptrs
17 set srcfile ${testname}.c
18 if { [prepare_for_testing "failed to prepare" ${testname} ${srcfile}] } {
19 return -1
20 }
21
22 if { ![runto_main] } {
23 return -1
24 }
25
26
27 # First set our breakpoints.
28
29 set fp_breakpoint_re \
30 "Breakpoint $decimal at $hex: file .*${srcfile}, line $decimal\\."
31 gdb_test "break sentinel if calc == decr" \
32 "${fp_breakpoint_re}" \
33 "breakpoint at sentinel"
34 gdb_test "break incr" \
35 "${fp_breakpoint_re}" \
36 "breakpoint at incr"
37 gdb_test "break decr" \
38 "${fp_breakpoint_re}" \
39 "breakpoint at decr"
40
41
42 # Check if we run through to the breakpoint in incr.
43
44 gdb_test "continue" \
45 "Breakpoint $decimal, incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
46 "continue to incr, first time"
47
48
49 # Go back up, make sure the return value is 0.
50
51 gdb_test "finish" \
52 "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" \
53 "go back to main from incr, first time"
54
55
56 # Redirect calc and see if we run to the breakpoint in decr instead.
57
58 gdb_test_no_output "set calc = decr" "set calc to decr"
59 gdb_test "continue" \
60 "Breakpoint $decimal, decr \\(i=0\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
61 "continue to decr"
62
63
64 # Go back up, check if we stop in sentinel instead.
65
66 gdb_test "finish" \
67 "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\]+.*" \
68 "stop in sentinel"
69
70
71 # Go back all the way up to main, make sure the return value is -1.
72
73 gdb_test_no_output "up-silently" "move up to decr"
74 gdb_test "finish" \
75 "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" \
76 "go back to main from decr"
77
78
79 # Reset calc and see if we run to the breakpoint in incr again.
80
81 gdb_test_no_output "set calc = incr" "set calc to incr"
82 gdb_test "continue" \
83 "Breakpoint $decimal, incr \\(i=-1\\)\[ \r\n\]+at .*${srcfile}:$decimal\[\r\n\]+.*" \
84 "continue to incr, second time"
85
86
87 # Go back up again, make sure the return value is 0.
88
89 gdb_test "finish" \
90 "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" \
91 "go back to main from incr, second time"
92
93
94 # All done!