]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2011-2024 Free Software Foundation, Inc. |
cc72b2a2 KP |
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 | ||
cc72b2a2 KP |
19 | load_lib gdb-python.exp |
20 | ||
d82e5429 | 21 | require allow_python_tests |
79749205 | 22 | |
b4a58790 | 23 | standard_testfile .cc |
cc72b2a2 | 24 | |
5b362f04 | 25 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { |
cc72b2a2 KP |
26 | return -1 |
27 | } | |
28 | ||
b0e16ca5 | 29 | if {![runto_main]} { |
cc72b2a2 KP |
30 | return 0 |
31 | } | |
32 | ||
7c343b48 YQ |
33 | set pyfile [gdb_remote_download host \ |
34 | ${srcdir}/${subdir}/${testfile}.py] | |
35 | ||
cc72b2a2 KP |
36 | # |
37 | # Check FinishBreakpoints against C++ exceptions | |
38 | # | |
39 | ||
64760036 | 40 | gdb_breakpoint [gdb_get_line_number "Break before exception"] |
cc72b2a2 KP |
41 | gdb_breakpoint [gdb_get_line_number "Break after exception 2"] |
42 | ||
43 | gdb_test "source $pyfile" ".*Python script imported.*" \ | |
44 | "import python scripts" | |
45 | ||
46 | gdb_breakpoint "throw_exception_1" | |
64760036 TV |
47 | |
48 | # | |
49 | # Part 1. | |
50 | # | |
51 | ||
cc72b2a2 KP |
52 | gdb_test "continue" "Breakpoint .*throw_exception_1.*" "run to exception 1" |
53 | ||
64760036 TV |
54 | # Count breakpoints before setting finishbreakpoint. |
55 | gdb_test "python print (len(gdb.breakpoints()))" "4" "check BP count" | |
56 | ||
7f99d636 AB |
57 | gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" \ |
58 | "init ExceptionFinishBreakpoint" "set FinishBP after the exception" | |
cc72b2a2 | 59 | |
64760036 TV |
60 | gdb_test "continue" "Break before exception.*" \ |
61 | "break before exception" | |
62 | ||
63 | set need_continue 0 | |
64 | gdb_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. | |
80 | gdb_test "python print (len(gdb.breakpoints()))" "4" "check finish BP removal" | |
81 | ||
82 | # | |
83 | # Part 2. | |
84 | # | |
85 | ||
86 | if { $need_continue } { | |
87 | gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" \ | |
88 | "continue to second exception" | |
89 | } | |
7f99d636 AB |
90 | gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" \ |
91 | "init ExceptionFinishBreakpoint" "set FinishBP after the exception again" | |
64760036 TV |
92 | |
93 | gdb_test "continue" "Break before exception.*" \ | |
94 | "break before exception again" | |
95 | ||
cc72b2a2 | 96 | gdb_test "continue" ".*exception did not finish.*" "FinishBreakpoint with exception thrown not caught" |