gdb/doc/ChangeLog:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / nextoverthrow.exp
CommitLineData
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
17if { [skip_cplus_tests] } { continue }
18
19set testfile "nextoverthrow"
20set srcfile ${testfile}.cc
21set binfile $objdir/$subdir/$testfile
22
23# Create and source the file that provides information about the compiler
24# used to compile the test case.
25if [get_compiler_info ${binfile} "c++"] {
26 untested nextoverthrow.exp
27 return -1
28}
29
30if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
31 return -1
32}
33
34if ![runto_main] then {
35 perror "couldn't run to main"
36 continue
37}
38
39# See whether we have the needed unwinder hooks.
40set ok 1
41gdb_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
56if {!$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
67if {!$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.
74proc 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.
83proc 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.
95tbreak_and_cont "Start: first test"
96gdb_test "next" ".*" "next over a throw 1"
97tbreak_and_cont "End: first test"
98verify_testval "pre-check - next over a throw 1" -1
99
100tbreak_and_cont "Start: nested throw"
101verify_testval "post-check - next over a throw 1" 0
102gdb_test "next" ".*" "next over a throw 2"
103tbreak_and_cont "End: nested throw"
104verify_testval "pre-check - next over a throw 2" 0
105
106tbreak_and_cont "Start: step in test"
107verify_testval "post-check - next over a throw 2" 1
108gdb_test "step" "function1().*" "step into function2 1"
109gdb_test "next" ".*" "next over a throw 3"
110tbreak_and_cont "End: step in test"
111verify_testval "pre-check - next over a throw 3" 1
112
113tbreak_and_cont "Start: next past catch"
114verify_testval "post-check - next over a throw 3" 2
115gdb_test "next" ".*" "next past catch"
116tbreak_and_cont "End: next past catch"
117verify_testval "pre-check - next past catch" 2
118
119tbreak_and_cont "Start: rethrow"
120verify_testval "post-check - next past catch" 3
121gdb_test "next" ".*" "next over a throw 4"
122tbreak_and_cont "End: rethrow"
123verify_testval "pre-check - next over a throw 4" 3
124
125tbreak_and_cont "Start: first finish"
126verify_testval "post-check - next over a throw 4" 4
127gdb_test "step" "function1().*" "step into function2 2"
128gdb_test "finish" ".*" "finish 1"
129tbreak_and_cont "End: first finish"
130verify_testval "pre-check - finish 1" 4
131
132tbreak_and_cont "Start: second finish"
133verify_testval "post-check - finish 1" 5
134gdb_test "step" "function1 ().*" "step into finish method"
135gdb_test "finish" ".*" "finish 2"
136tbreak_and_cont "End: second finish"
137verify_testval "pre-check - finish 2" 5
138
139tbreak_and_cont "Start: first until"
140verify_testval "post-check - finish 2" 6
141gdb_test "step" ".*" "step into finish, for until"
142gdb_test "until" ".*" "until with no argument 1"
143set line [gdb_get_line_number "marker for until" $testfile.cc]
144gdb_test "until $line" "function1 ().*" "next past catch 6"
145gdb_test "until" ".*" "until with no argument 2"
146tbreak_and_cont "End: first until"
147verify_testval "pre-check - until 1" 6
148
149tbreak_and_cont "Start: second until"
150verify_testval "post-check - until 1" 7
151set line [gdb_get_line_number "until here" $testfile.cc]
152gdb_test "step" "function1 ().*" "step into until"
153gdb_test "until $line" ".*" "until-over-throw"
154tbreak_and_cont "End: second until"
155verify_testval "pre-check - until 2" 7
156
157tbreak_and_cont "Start: advance"
158verify_testval "post-check - until 2" 8
159gdb_test "step" "function1 ().*" "step into until, for advance"
160gdb_test "advance $line" ".*" "advance-over-throw"
161tbreak_and_cont "End: advance"
162verify_testval "pre-check - advance" 8
163
5b79abe7
TT
164tbreak_and_cont "Start: resumebpt"
165gdb_test "tbreak _Unwind_RaiseException"
166gdb_test "continue" "Temporary breakpoint.*" "continuing to _Unwind_RaiseException"
167gdb_test "finish" "Run till exit .*"
168gdb_test {set $retpc=$pc}
169gdb_test {break *$retpc if dummy ()}
170tbreak_and_cont "Second: resumebpt"
171gdb_test "next"
172
186c406b 173tbreak_and_cont "done"
5b79abe7 174verify_testval "post-check - advance" 10
This page took 0.387079 seconds and 4 git commands to generate.