1 # Copyright
2008-2015 Free Software Foundation
, Inc.
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.
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.
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
/>.
17 if { [skip_cplus_tests
] } { continue }
21 # Create and source the file that provides information about the compiler
22 # used to
compile the test case.
23 if [get_compiler_info
"c++"] {
24 untested nextoverthrow.exp
28 if {[prepare_for_testing $testfile.exp $testfile $srcfile
{debug c
++}]} {
32 if ![runto_main
] then {
33 perror
"couldn't run to main"
37 if {![skip_unwinder_tests
]} {
38 unsupported
"nextoverthrow.exp could not find _Unwind_DebugHook"
42 #
Set a temporary breakpoint and
then continue to it.
43 # The breakpoint is
set according to a marker in the file.
44 proc tbreak_and_cont
{text} {
47 set line
[gdb_get_line_number $
text $testfile.cc
]
48 gdb_breakpoint
"$testfile.cc:$line" temporary
49 gdb_test
"continue" "Temporary breakpoint.*" "continuing to $text"
52 # Verify the value of testval.
53 proc verify_testval
{name value
} {
54 gdb_test
"print testval == $value" " = true" $name
57 # See http
://sourceware.org
/bugzilla
/show_bug.cgi?id
=9593
58 # Our general approach here is to
do some operation
, verify
59 # that testval has not changed
, continue to the location at
60 # which the next test starts
, and verify testval again.
61 # This works around platform differences in debuginfo that
62 # make looking at the source line unreliable.
64 # A simple test of next over a throw.
65 tbreak_and_cont
"Start: first test"
66 gdb_test
"next" ".*" "next over a throw 1"
67 tbreak_and_cont
"End: first test"
68 verify_testval
"pre-check - next over a throw 1" -1
70 tbreak_and_cont
"Start: nested throw"
71 verify_testval
"post-check - next over a throw 1" 0
72 gdb_test
"next" ".*" "next over a throw 2"
73 tbreak_and_cont
"End: nested throw"
74 verify_testval
"pre-check - next over a throw 2" 0
76 tbreak_and_cont
"Start: step in test"
77 verify_testval
"post-check - next over a throw 2" 1
78 gdb_test
"step" "function1().*" "step into function2 1"
79 gdb_test
"next" ".*" "next over a throw 3"
80 tbreak_and_cont
"End: step in test"
81 verify_testval
"pre-check - next over a throw 3" 1
83 tbreak_and_cont
"Start: next past catch"
84 verify_testval
"post-check - next over a throw 3" 2
85 gdb_test
"next" ".*" "next past catch"
86 tbreak_and_cont
"End: next past catch"
87 verify_testval
"pre-check - next past catch" 2
89 tbreak_and_cont
"Start: rethrow"
90 verify_testval
"post-check - next past catch" 3
91 gdb_test
"next" ".*" "next over a throw 4"
92 tbreak_and_cont
"End: rethrow"
93 verify_testval
"pre-check - next over a throw 4" 3
95 tbreak_and_cont
"Start: first finish"
96 verify_testval
"post-check - next over a throw 4" 4
97 gdb_test
"step" "function1().*" "step into function2 2"
98 gdb_test
"finish" ".*" "finish 1"
99 tbreak_and_cont
"End: first finish"
100 verify_testval
"pre-check - finish 1" 4
102 tbreak_and_cont
"Start: second finish"
103 verify_testval
"post-check - finish 1" 5
104 gdb_test
"step" "function1 ().*" "step into finish method"
105 gdb_test
"finish" ".*" "finish 2"
106 tbreak_and_cont
"End: second finish"
107 verify_testval
"pre-check - finish 2" 5
109 tbreak_and_cont
"Start: first until"
110 verify_testval
"post-check - finish 2" 6
111 gdb_test
"step" ".*" "step into finish, for until"
112 gdb_test
"until" ".*" "until with no argument 1"
113 set line
[gdb_get_line_number
"marker for until" $testfile.cc]
114 gdb_test
"until $line" "function1 ().*" "next past catch 6"
115 gdb_test
"until" ".*" "until with no argument 2"
116 tbreak_and_cont
"End: first until"
117 verify_testval
"pre-check - until 1" 6
119 tbreak_and_cont
"Start: second until"
120 verify_testval
"post-check - until 1" 7
121 set line
[gdb_get_line_number
"until here" $testfile.cc]
122 gdb_test
"step" "function1 ().*" "step into until"
123 gdb_test
"until $line" ".*" "until-over-throw"
124 tbreak_and_cont
"End: second until"
125 verify_testval
"pre-check - until 2" 7
127 tbreak_and_cont
"Start: advance"
128 verify_testval
"post-check - until 2" 8
129 gdb_test
"step" "function1 ().*" "step into until, for advance"
130 gdb_test
"advance $line" ".*" "advance-over-throw"
131 tbreak_and_cont
"End: advance"
132 verify_testval
"pre-check - advance" 8
134 tbreak_and_cont
"Start: resumebpt"
135 gdb_test
"tbreak _Unwind_RaiseException"
136 gdb_test
"continue" "Temporary breakpoint.*" "continuing to _Unwind_RaiseException"
137 gdb_test
"finish" "Run till exit .*"
138 gdb_test
{set $retpc
=$pc
}
139 gdb_test
{break *$retpc
if dummy
()}
140 tbreak_and_cont
"Second: resumebpt"
143 tbreak_and_cont
"done"
144 verify_testval
"post-check - advance" 10