]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2016-2024 Free Software Foundation, Inc. |
f4952523 PMR |
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 proper handling for | |
17 | # breakpoint creation failure. | |
18 | ||
19 | load_lib gdb-python.exp | |
20 | ||
d82e5429 | 21 | require allow_python_tests |
79749205 | 22 | |
f4952523 PMR |
23 | standard_testfile |
24 | ||
5b362f04 | 25 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { |
f4952523 PMR |
26 | return -1 |
27 | } | |
28 | ||
f4952523 PMR |
29 | clean_restart "${testfile}" |
30 | if ![runto_main] { | |
4dfef5be | 31 | return |
f4952523 PMR |
32 | } |
33 | ||
34 | # The following will create a breakpoint Python wrapper whose construction will | |
35 | # abort: the requested symbol is not defined. GDB should not keep a reference | |
36 | # to the wrapper; however it used to... | |
37 | gdb_test "source py-breakpoint-create-fail.py" | |
38 | ||
39 | # ... and when it did, as a result, the following breakpoint creation (not | |
40 | # initiated by the Python API) would dereference the already-freed Python | |
41 | # breakpoint wrapper, resulting in undefined behavior, sometimes observed as a | |
42 | # gdb crash, and other times causing the next stop to invoke the Python wrapper | |
43 | # "stop" method for the object that is not supposed to exist. | |
44 | gdb_test "break foo" | |
45 | ||
46 | set test "continuing to foo" | |
47 | gdb_test_multiple "continue" "$test" { | |
48 | -re "MyBP\.stop was invoked\!.*$gdb_prompt $" { | |
49 | fail "$test" | |
50 | } | |
51 | -re "Continuing.*Breakpoint 2, foo.*$gdb_prompt $" { | |
52 | pass "$test" | |
53 | } | |
54 | } |