1 # Copyright (C) 2011-2023 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite. It tests python Finish
20 class MyFinishBreakpoint(gdb
.FinishBreakpoint
):
21 def __init__(self
, val
, frame
):
22 gdb
.FinishBreakpoint
.__init
__(self
, frame
)
23 print("MyFinishBreakpoint init")
27 print("MyFinishBreakpoint stop with %d" % int(self
.val
.dereference()))
28 print("return_value is: %d" % int(self
.return_value
))
29 gdb
.execute("where 1")
32 def out_of_scope(self
):
33 print("MyFinishBreakpoint out of scope")
36 class TestBreakpoint(gdb
.Breakpoint
):
38 gdb
.Breakpoint
.__init
__(self
, spec
="test_1", internal
=1)
41 print("TestBreakpoint init")
46 TestFinishBreakpoint(gdb
.newest_frame(), self
.count
)
47 except ValueError as e
:
52 class TestFinishBreakpoint(gdb
.FinishBreakpoint
):
53 def __init__(self
, frame
, count
):
55 gdb
.FinishBreakpoint
.__init
__(self
, frame
, internal
=1)
58 print("-->", self
.number
)
60 print("test stop: %d" % self
.count
)
63 print("test don't stop: %d" % self
.count
)
66 def out_of_scope(self
):
67 print("test didn't finish: %d" % self
.count
)
70 class TestExplicitBreakpoint(gdb
.Breakpoint
):
73 SimpleFinishBreakpoint(gdb
.newest_frame())
74 except ValueError as e
:
79 class SimpleFinishBreakpoint(gdb
.FinishBreakpoint
):
80 def __init__(self
, frame
):
81 gdb
.FinishBreakpoint
.__init
__(self
, frame
)
83 print("SimpleFinishBreakpoint init")
86 print("SimpleFinishBreakpoint stop")
89 def out_of_scope(self
):
90 print("SimpleFinishBreakpoint out of scope")
93 print("Python script imported")