]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/nextoverthrow.exp
gdb/testsuite: remove use of then keyword from gdb.cp/*.exp
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / nextoverthrow.exp
CommitLineData
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 17if { [skip_cplus_tests] } { return }
186c406b 18
f5f3a911 19standard_testfile .cc
186c406b 20
5b362f04 21if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
186c406b
TT
22 return -1
23}
24
95701cae 25if {![runto_main]} {
186c406b 26 perror "couldn't run to main"
cdd42066 27 return
186c406b
TT
28}
29
b4893d48 30if {![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.
37proc 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.
46proc 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.
58tbreak_and_cont "Start: first test"
59gdb_test "next" ".*" "next over a throw 1"
60tbreak_and_cont "End: first test"
61verify_testval "pre-check - next over a throw 1" -1
62
63tbreak_and_cont "Start: nested throw"
64verify_testval "post-check - next over a throw 1" 0
65gdb_test "next" ".*" "next over a throw 2"
66tbreak_and_cont "End: nested throw"
67verify_testval "pre-check - next over a throw 2" 0
68
69tbreak_and_cont "Start: step in test"
70verify_testval "post-check - next over a throw 2" 1
71gdb_test "step" "function1().*" "step into function2 1"
72gdb_test "next" ".*" "next over a throw 3"
73tbreak_and_cont "End: step in test"
74verify_testval "pre-check - next over a throw 3" 1
75
76tbreak_and_cont "Start: next past catch"
77verify_testval "post-check - next over a throw 3" 2
78gdb_test "next" ".*" "next past catch"
79tbreak_and_cont "End: next past catch"
80verify_testval "pre-check - next past catch" 2
81
82tbreak_and_cont "Start: rethrow"
83verify_testval "post-check - next past catch" 3
84gdb_test "next" ".*" "next over a throw 4"
85tbreak_and_cont "End: rethrow"
86verify_testval "pre-check - next over a throw 4" 3
87
88tbreak_and_cont "Start: first finish"
89verify_testval "post-check - next over a throw 4" 4
90gdb_test "step" "function1().*" "step into function2 2"
91gdb_test "finish" ".*" "finish 1"
92tbreak_and_cont "End: first finish"
93verify_testval "pre-check - finish 1" 4
94
95tbreak_and_cont "Start: second finish"
96verify_testval "post-check - finish 1" 5
97gdb_test "step" "function1 ().*" "step into finish method"
98gdb_test "finish" ".*" "finish 2"
99tbreak_and_cont "End: second finish"
100verify_testval "pre-check - finish 2" 5
101
102tbreak_and_cont "Start: first until"
103verify_testval "post-check - finish 2" 6
104gdb_test "step" ".*" "step into finish, for until"
105gdb_test "until" ".*" "until with no argument 1"
106set line [gdb_get_line_number "marker for until" $testfile.cc]
107gdb_test "until $line" "function1 ().*" "next past catch 6"
108gdb_test "until" ".*" "until with no argument 2"
109tbreak_and_cont "End: first until"
110verify_testval "pre-check - until 1" 6
111
112tbreak_and_cont "Start: second until"
113verify_testval "post-check - until 1" 7
114set line [gdb_get_line_number "until here" $testfile.cc]
115gdb_test "step" "function1 ().*" "step into until"
116gdb_test "until $line" ".*" "until-over-throw"
117tbreak_and_cont "End: second until"
118verify_testval "pre-check - until 2" 7
119
120tbreak_and_cont "Start: advance"
121verify_testval "post-check - until 2" 8
122gdb_test "step" "function1 ().*" "step into until, for advance"
123gdb_test "advance $line" ".*" "advance-over-throw"
124tbreak_and_cont "End: advance"
125verify_testval "pre-check - advance" 8
126
5b79abe7
TT
127tbreak_and_cont "Start: resumebpt"
128gdb_test "tbreak _Unwind_RaiseException"
129gdb_test "continue" "Temporary breakpoint.*" "continuing to _Unwind_RaiseException"
130gdb_test "finish" "Run till exit .*"
131gdb_test {set $retpc=$pc}
132gdb_test {break *$retpc if dummy ()}
133tbreak_and_cont "Second: resumebpt"
134gdb_test "next"
135
186c406b 136tbreak_and_cont "done"
5b79abe7 137verify_testval "post-check - advance" 10