diff options
Diffstat (limited to 'gdb/testsuite/gdb.cp/nextoverthrow.exp')
-rw-r--r-- | gdb/testsuite/gdb.cp/nextoverthrow.exp | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/nextoverthrow.exp b/gdb/testsuite/gdb.cp/nextoverthrow.exp new file mode 100644 index 0000000..960ea0d --- /dev/null +++ b/gdb/testsuite/gdb.cp/nextoverthrow.exp @@ -0,0 +1,153 @@ +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set testfile "nextoverthrow" +set srcfile ${testfile}.cc +set binfile $objdir/$subdir/$testfile + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info ${binfile} "c++"] { + untested nextoverthrow.exp + return -1 +} + +if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { + return -1 +} + +if ![runto_main] then { + perror "couldn't run to main" + continue +} + +# See whether we have the needed unwinder hooks. +set ok 1 +gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" { + -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" { + pass "check for unwinder hook" + } + -re "No symbol .* in current context.\r\n$gdb_prompt $" { + # Pass the test so we don't get bogus fails in the results. + pass "check for unwinder hook" + set ok 0 + } +} +if {!$ok} { + unsupported "nextoverthrow.exp could not find _Unwind_DebugHook" + return -1 +} + +# Set a temporary breakpoint and then continue to it. +# The breakpoint is set according to a marker in the file. +proc tbreak_and_cont {text} { + global testfile + + set line [gdb_get_line_number $text $testfile.cc] + gdb_breakpoint "$testfile.cc:$line" temporary + gdb_test "continue" "Temporary breakpoint.*" "continuing to $text" +} + +# Verify the value of testval. +proc verify_testval {name value} { + gdb_test "print testval == $value" " = true" $name +} + +# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593 +# Our general approach here is to do some operation, verify +# that testval has not changed, continue to the location at +# which the next test starts, and verify testval again. +# This works around platform differences in debuginfo that +# make looking at the source line unreliable. + +# A simple test of next over a throw. +tbreak_and_cont "Start: first test" +gdb_test "next" ".*" "next over a throw 1" +tbreak_and_cont "End: first test" +verify_testval "pre-check - next over a throw 1" -1 + +tbreak_and_cont "Start: nested throw" +verify_testval "post-check - next over a throw 1" 0 +gdb_test "next" ".*" "next over a throw 2" +tbreak_and_cont "End: nested throw" +verify_testval "pre-check - next over a throw 2" 0 + +tbreak_and_cont "Start: step in test" +verify_testval "post-check - next over a throw 2" 1 +gdb_test "step" "function1().*" "step into function2 1" +gdb_test "next" ".*" "next over a throw 3" +tbreak_and_cont "End: step in test" +verify_testval "pre-check - next over a throw 3" 1 + +tbreak_and_cont "Start: next past catch" +verify_testval "post-check - next over a throw 3" 2 +gdb_test "next" ".*" "next past catch" +tbreak_and_cont "End: next past catch" +verify_testval "pre-check - next past catch" 2 + +tbreak_and_cont "Start: rethrow" +verify_testval "post-check - next past catch" 3 +gdb_test "next" ".*" "next over a throw 4" +tbreak_and_cont "End: rethrow" +verify_testval "pre-check - next over a throw 4" 3 + +tbreak_and_cont "Start: first finish" +verify_testval "post-check - next over a throw 4" 4 +gdb_test "step" "function1().*" "step into function2 2" +gdb_test "finish" ".*" "finish 1" +tbreak_and_cont "End: first finish" +verify_testval "pre-check - finish 1" 4 + +tbreak_and_cont "Start: second finish" +verify_testval "post-check - finish 1" 5 +gdb_test "step" "function1 ().*" "step into finish method" +gdb_test "finish" ".*" "finish 2" +tbreak_and_cont "End: second finish" +verify_testval "pre-check - finish 2" 5 + +tbreak_and_cont "Start: first until" +verify_testval "post-check - finish 2" 6 +gdb_test "step" ".*" "step into finish, for until" +gdb_test "until" ".*" "until with no argument 1" +set line [gdb_get_line_number "marker for until" $testfile.cc] +gdb_test "until $line" "function1 ().*" "next past catch 6" +gdb_test "until" ".*" "until with no argument 2" +tbreak_and_cont "End: first until" +verify_testval "pre-check - until 1" 6 + +tbreak_and_cont "Start: second until" +verify_testval "post-check - until 1" 7 +set line [gdb_get_line_number "until here" $testfile.cc] +gdb_test "step" "function1 ().*" "step into until" +gdb_test "until $line" ".*" "until-over-throw" +tbreak_and_cont "End: second until" +verify_testval "pre-check - until 2" 7 + +tbreak_and_cont "Start: advance" +verify_testval "post-check - until 2" 8 +gdb_test "step" "function1 ().*" "step into until, for advance" +gdb_test "advance $line" ".*" "advance-over-throw" +tbreak_and_cont "End: advance" +verify_testval "pre-check - advance" 8 + +tbreak_and_cont "done" +verify_testval "post-check - advance" 9 |