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