* gdb.cp/abstract-origin.exp: Use standard_testfile.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / nextoverthrow.exp
1 # Copyright 2008-2012 Free Software Foundation, Inc.
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
17 if { [skip_cplus_tests] } { continue }
18
19 standard_testfile .cc
20
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
25 return -1
26 }
27
28 if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
29 return -1
30 }
31
32 if ![runto_main] then {
33 perror "couldn't run to main"
34 continue
35 }
36
37 # See whether we have the needed unwinder hooks.
38 set ok 1
39 gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
40 -re "= .*no debug info.*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
41 # Pass the test so we don't get bogus fails in the results.
42 pass "check for unwinder hook"
43 set ok 0
44 }
45 -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
46 pass "check for unwinder hook"
47 }
48 -re "No symbol .* in current context.\r\n$gdb_prompt $" {
49 # Pass the test so we don't get bogus fails in the results.
50 pass "check for unwinder hook"
51 set ok 0
52 }
53 }
54 if {!$ok} {
55 gdb_test_multiple "info probe" "check for stap probe in unwinder" {
56 -re ".*libgcc.*unwind.*\r\n$gdb_prompt $" {
57 pass "check for stap probe in unwinder"
58 set ok 1
59 }
60 -re "\r\n$gdb_prompt $" {
61 }
62 }
63 }
64
65 if {!$ok} {
66 unsupported "nextoverthrow.exp could not find _Unwind_DebugHook"
67 return -1
68 }
69
70 # Set a temporary breakpoint and then continue to it.
71 # The breakpoint is set according to a marker in the file.
72 proc tbreak_and_cont {text} {
73 global testfile
74
75 set line [gdb_get_line_number $text $testfile.cc]
76 gdb_breakpoint "$testfile.cc:$line" temporary
77 gdb_test "continue" "Temporary breakpoint.*" "continuing to $text"
78 }
79
80 # Verify the value of testval.
81 proc verify_testval {name value} {
82 gdb_test "print testval == $value" " = true" $name
83 }
84
85 # See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
86 # Our general approach here is to do some operation, verify
87 # that testval has not changed, continue to the location at
88 # which the next test starts, and verify testval again.
89 # This works around platform differences in debuginfo that
90 # make looking at the source line unreliable.
91
92 # A simple test of next over a throw.
93 tbreak_and_cont "Start: first test"
94 gdb_test "next" ".*" "next over a throw 1"
95 tbreak_and_cont "End: first test"
96 verify_testval "pre-check - next over a throw 1" -1
97
98 tbreak_and_cont "Start: nested throw"
99 verify_testval "post-check - next over a throw 1" 0
100 gdb_test "next" ".*" "next over a throw 2"
101 tbreak_and_cont "End: nested throw"
102 verify_testval "pre-check - next over a throw 2" 0
103
104 tbreak_and_cont "Start: step in test"
105 verify_testval "post-check - next over a throw 2" 1
106 gdb_test "step" "function1().*" "step into function2 1"
107 gdb_test "next" ".*" "next over a throw 3"
108 tbreak_and_cont "End: step in test"
109 verify_testval "pre-check - next over a throw 3" 1
110
111 tbreak_and_cont "Start: next past catch"
112 verify_testval "post-check - next over a throw 3" 2
113 gdb_test "next" ".*" "next past catch"
114 tbreak_and_cont "End: next past catch"
115 verify_testval "pre-check - next past catch" 2
116
117 tbreak_and_cont "Start: rethrow"
118 verify_testval "post-check - next past catch" 3
119 gdb_test "next" ".*" "next over a throw 4"
120 tbreak_and_cont "End: rethrow"
121 verify_testval "pre-check - next over a throw 4" 3
122
123 tbreak_and_cont "Start: first finish"
124 verify_testval "post-check - next over a throw 4" 4
125 gdb_test "step" "function1().*" "step into function2 2"
126 gdb_test "finish" ".*" "finish 1"
127 tbreak_and_cont "End: first finish"
128 verify_testval "pre-check - finish 1" 4
129
130 tbreak_and_cont "Start: second finish"
131 verify_testval "post-check - finish 1" 5
132 gdb_test "step" "function1 ().*" "step into finish method"
133 gdb_test "finish" ".*" "finish 2"
134 tbreak_and_cont "End: second finish"
135 verify_testval "pre-check - finish 2" 5
136
137 tbreak_and_cont "Start: first until"
138 verify_testval "post-check - finish 2" 6
139 gdb_test "step" ".*" "step into finish, for until"
140 gdb_test "until" ".*" "until with no argument 1"
141 set line [gdb_get_line_number "marker for until" $testfile.cc]
142 gdb_test "until $line" "function1 ().*" "next past catch 6"
143 gdb_test "until" ".*" "until with no argument 2"
144 tbreak_and_cont "End: first until"
145 verify_testval "pre-check - until 1" 6
146
147 tbreak_and_cont "Start: second until"
148 verify_testval "post-check - until 1" 7
149 set line [gdb_get_line_number "until here" $testfile.cc]
150 gdb_test "step" "function1 ().*" "step into until"
151 gdb_test "until $line" ".*" "until-over-throw"
152 tbreak_and_cont "End: second until"
153 verify_testval "pre-check - until 2" 7
154
155 tbreak_and_cont "Start: advance"
156 verify_testval "post-check - until 2" 8
157 gdb_test "step" "function1 ().*" "step into until, for advance"
158 gdb_test "advance $line" ".*" "advance-over-throw"
159 tbreak_and_cont "End: advance"
160 verify_testval "pre-check - advance" 8
161
162 tbreak_and_cont "Start: resumebpt"
163 gdb_test "tbreak _Unwind_RaiseException"
164 gdb_test "continue" "Temporary breakpoint.*" "continuing to _Unwind_RaiseException"
165 gdb_test "finish" "Run till exit .*"
166 gdb_test {set $retpc=$pc}
167 gdb_test {break *$retpc if dummy ()}
168 tbreak_and_cont "Second: resumebpt"
169 gdb_test "next"
170
171 tbreak_and_cont "done"
172 verify_testval "post-check - advance" 10
This page took 0.03471 seconds and 5 git commands to generate.