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