]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2008-2024 Free Software Foundation, Inc. |
186c406b TT |
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 | ||
0b94d2b9 | 17 | require allow_cplus_tests |
186c406b | 18 | |
f5f3a911 | 19 | standard_testfile .cc |
186c406b | 20 | |
5b362f04 | 21 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { |
186c406b TT |
22 | return -1 |
23 | } | |
24 | ||
95701cae | 25 | if {![runto_main]} { |
cdd42066 | 26 | return |
186c406b TT |
27 | } |
28 | ||
b4893d48 | 29 | if {![skip_unwinder_tests]} { |
186c406b TT |
30 | unsupported "nextoverthrow.exp could not find _Unwind_DebugHook" |
31 | return -1 | |
32 | } | |
33 | ||
34 | # Set a temporary breakpoint and then continue to it. | |
35 | # The breakpoint is set according to a marker in the file. | |
36 | proc tbreak_and_cont {text} { | |
37 | global testfile | |
38 | ||
39 | set line [gdb_get_line_number $text $testfile.cc] | |
40 | gdb_breakpoint "$testfile.cc:$line" temporary | |
41 | gdb_test "continue" "Temporary breakpoint.*" "continuing to $text" | |
42 | } | |
43 | ||
44 | # Verify the value of testval. | |
45 | proc verify_testval {name value} { | |
46 | gdb_test "print testval == $value" " = true" $name | |
47 | } | |
48 | ||
49 | # See http://sourceware.org/bugzilla/show_bug.cgi?id=9593 | |
50 | # Our general approach here is to do some operation, verify | |
51 | # that testval has not changed, continue to the location at | |
52 | # which the next test starts, and verify testval again. | |
53 | # This works around platform differences in debuginfo that | |
54 | # make looking at the source line unreliable. | |
55 | ||
56 | # A simple test of next over a throw. | |
57 | tbreak_and_cont "Start: first test" | |
58 | gdb_test "next" ".*" "next over a throw 1" | |
59 | tbreak_and_cont "End: first test" | |
60 | verify_testval "pre-check - next over a throw 1" -1 | |
61 | ||
62 | tbreak_and_cont "Start: nested throw" | |
63 | verify_testval "post-check - next over a throw 1" 0 | |
64 | gdb_test "next" ".*" "next over a throw 2" | |
65 | tbreak_and_cont "End: nested throw" | |
66 | verify_testval "pre-check - next over a throw 2" 0 | |
67 | ||
68 | tbreak_and_cont "Start: step in test" | |
69 | verify_testval "post-check - next over a throw 2" 1 | |
70 | gdb_test "step" "function1().*" "step into function2 1" | |
71 | gdb_test "next" ".*" "next over a throw 3" | |
72 | tbreak_and_cont "End: step in test" | |
73 | verify_testval "pre-check - next over a throw 3" 1 | |
74 | ||
75 | tbreak_and_cont "Start: next past catch" | |
76 | verify_testval "post-check - next over a throw 3" 2 | |
77 | gdb_test "next" ".*" "next past catch" | |
78 | tbreak_and_cont "End: next past catch" | |
79 | verify_testval "pre-check - next past catch" 2 | |
80 | ||
81 | tbreak_and_cont "Start: rethrow" | |
82 | verify_testval "post-check - next past catch" 3 | |
83 | gdb_test "next" ".*" "next over a throw 4" | |
84 | tbreak_and_cont "End: rethrow" | |
85 | verify_testval "pre-check - next over a throw 4" 3 | |
86 | ||
87 | tbreak_and_cont "Start: first finish" | |
88 | verify_testval "post-check - next over a throw 4" 4 | |
89 | gdb_test "step" "function1().*" "step into function2 2" | |
90 | gdb_test "finish" ".*" "finish 1" | |
91 | tbreak_and_cont "End: first finish" | |
92 | verify_testval "pre-check - finish 1" 4 | |
93 | ||
94 | tbreak_and_cont "Start: second finish" | |
95 | verify_testval "post-check - finish 1" 5 | |
96 | gdb_test "step" "function1 ().*" "step into finish method" | |
97 | gdb_test "finish" ".*" "finish 2" | |
98 | tbreak_and_cont "End: second finish" | |
99 | verify_testval "pre-check - finish 2" 5 | |
100 | ||
101 | tbreak_and_cont "Start: first until" | |
102 | verify_testval "post-check - finish 2" 6 | |
103 | gdb_test "step" ".*" "step into finish, for until" | |
104 | gdb_test "until" ".*" "until with no argument 1" | |
105 | set line [gdb_get_line_number "marker for until" $testfile.cc] | |
106 | gdb_test "until $line" "function1 ().*" "next past catch 6" | |
107 | gdb_test "until" ".*" "until with no argument 2" | |
108 | tbreak_and_cont "End: first until" | |
109 | verify_testval "pre-check - until 1" 6 | |
110 | ||
111 | tbreak_and_cont "Start: second until" | |
112 | verify_testval "post-check - until 1" 7 | |
113 | set line [gdb_get_line_number "until here" $testfile.cc] | |
114 | gdb_test "step" "function1 ().*" "step into until" | |
115 | gdb_test "until $line" ".*" "until-over-throw" | |
116 | tbreak_and_cont "End: second until" | |
117 | verify_testval "pre-check - until 2" 7 | |
118 | ||
119 | tbreak_and_cont "Start: advance" | |
120 | verify_testval "post-check - until 2" 8 | |
121 | gdb_test "step" "function1 ().*" "step into until, for advance" | |
122 | gdb_test "advance $line" ".*" "advance-over-throw" | |
123 | tbreak_and_cont "End: advance" | |
124 | verify_testval "pre-check - advance" 8 | |
125 | ||
5b79abe7 TT |
126 | tbreak_and_cont "Start: resumebpt" |
127 | gdb_test "tbreak _Unwind_RaiseException" | |
128 | gdb_test "continue" "Temporary breakpoint.*" "continuing to _Unwind_RaiseException" | |
129 | gdb_test "finish" "Run till exit .*" | |
130 | gdb_test {set $retpc=$pc} | |
131 | gdb_test {break *$retpc if dummy ()} | |
132 | tbreak_and_cont "Second: resumebpt" | |
133 | gdb_test "next" | |
134 | ||
186c406b | 135 | tbreak_and_cont "done" |
5b79abe7 | 136 | verify_testval "post-check - advance" 10 |