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