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