Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2014-2016 Free Software Foundation, Inc. |
3e29f34a MR |
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 | |
5b362f04 | 18 | if { [prepare_for_testing "failed to prepare" ${testname} ${srcfile}] } { |
3e29f34a MR |
19 | return -1 |
20 | } | |
21 | ||
22 | if { ![runto_main] } { | |
5b362f04 | 23 | untested "could not run to main" |
3e29f34a MR |
24 | return -1 |
25 | } | |
26 | ||
27 | ||
28 | # First set our breakpoints. | |
29 | ||
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}" \ | |
37 | "breakpoint at incr" | |
38 | gdb_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 | ||
45 | gdb_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 | ||
52 | gdb_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 | ||
59 | gdb_test_no_output "set calc = decr" "set calc to decr" | |
60 | gdb_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 | ||
67 | gdb_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 | ||
74 | gdb_test_no_output "up-silently" "move up to decr" | |
75 | gdb_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 | ||
82 | gdb_test_no_output "set calc = incr" "set calc to incr" | |
83 | gdb_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 | ||
90 | gdb_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! |