py-finish-breakpoint2.exp revision 1.1.1.9
1# Copyright (C) 2011-2024 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# This file is part of the GDB testsuite. It tests the mechanism 17# exposing values to Python. 18 19load_lib gdb-python.exp 20 21require allow_python_tests 22 23standard_testfile .cc 24 25if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { 26 return -1 27} 28 29if {![runto_main]} { 30 return 0 31} 32 33set pyfile [gdb_remote_download host \ 34 ${srcdir}/${subdir}/${testfile}.py] 35 36# 37# Check FinishBreakpoints against C++ exceptions 38# 39 40gdb_breakpoint [gdb_get_line_number "Break before exception"] 41gdb_breakpoint [gdb_get_line_number "Break after exception 2"] 42 43gdb_test "source $pyfile" ".*Python script imported.*" \ 44 "import python scripts" 45 46gdb_breakpoint "throw_exception_1" 47 48# 49# Part 1. 50# 51 52gdb_test "continue" "Breakpoint .*throw_exception_1.*" "run to exception 1" 53 54# Count breakpoints before setting finishbreakpoint. 55gdb_test "python print (len(gdb.breakpoints()))" "4" "check BP count" 56 57gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" \ 58 "init ExceptionFinishBreakpoint" "set FinishBP after the exception" 59 60gdb_test "continue" "Break before exception.*" \ 61 "break before exception" 62 63set need_continue 0 64gdb_test_multiple "continue" "finishBP out-of-scope" { 65 -re -wrap "exception did not finish.*" { 66 # Out-of-scope. For instance on x86_64 with unix/-m32. 67 pass $gdb_test_name 68 } 69 -re -wrap "stopped at ExceptionFinishBreakpoint.*" { 70 # Triggered despite the fact that the function call never finished. 71 # It just so happens to be that the frame return address at which the 72 # breakpoint is set, is also the first instruction after the exception 73 # has been handled. For instance on x86_64 with unix/-m64. 74 kfail python/29909 $gdb_test_name 75 set need_continue 1 76 } 77} 78 79# Count breakpoints, check that the finishbreakpoint has been removed. 80gdb_test "python print (len(gdb.breakpoints()))" "4" "check finish BP removal" 81 82# 83# Part 2. 84# 85 86if { $need_continue } { 87 gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" \ 88 "continue to second exception" 89} 90gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" \ 91 "init ExceptionFinishBreakpoint" "set FinishBP after the exception again" 92 93gdb_test "continue" "Break before exception.*" \ 94 "break before exception again" 95 96gdb_test "continue" ".*exception did not finish.*" "FinishBreakpoint with exception thrown not caught" 97