Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-finish-breakpoint.py
CommitLineData
88b9d363 1# Copyright (C) 2011-2022 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 python Finish
17# Breakpoints.
13123da8
SM
18
19
20class MyFinishBreakpoint(gdb.FinishBreakpoint):
21 def __init__(self, val, frame):
22 gdb.FinishBreakpoint.__init__(self, frame)
23 print("MyFinishBreakpoint init")
24 self.val = val
25
26 def stop(self):
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")
30 return True
31
32 def out_of_scope(self):
33 print("MyFinishBreakpoint out of scope")
34
cc72b2a2
KP
35
36class TestBreakpoint(gdb.Breakpoint):
37 def __init__(self):
13123da8 38 gdb.Breakpoint.__init__(self, spec="test_1", internal=1)
cc72b2a2
KP
39 self.silent = True
40 self.count = 0
13123da8
SM
41 print("TestBreakpoint init")
42
cc72b2a2 43 def stop(self):
9325cb04
PK
44 self.count += 1
45 try:
13123da8 46 TestFinishBreakpoint(gdb.newest_frame(), self.count)
cc72b2a2 47 except ValueError as e:
13123da8 48 print(e)
cc72b2a2
KP
49 return False
50
13123da8
SM
51
52class TestFinishBreakpoint(gdb.FinishBreakpoint):
53 def __init__(self, frame, count):
9325cb04 54 self.count = count
13123da8
SM
55 gdb.FinishBreakpoint.__init__(self, frame, internal=1)
56
cc72b2a2 57 def stop(self):
13123da8
SM
58 print("-->", self.number)
59 if self.count == 3:
60 print("test stop: %d" % self.count)
cc72b2a2
KP
61 return True
62 else:
13123da8
SM
63 print("test don't stop: %d" % self.count)
64 return False
65
cc72b2a2 66 def out_of_scope(self):
13123da8
SM
67 print("test didn't finish: %d" % self.count)
68
cc72b2a2
KP
69
70class TestExplicitBreakpoint(gdb.Breakpoint):
13123da8
SM
71 def stop(self):
72 try:
73 SimpleFinishBreakpoint(gdb.newest_frame())
74 except ValueError as e:
75 print(e)
76 return False
77
cc72b2a2
KP
78
79class SimpleFinishBreakpoint(gdb.FinishBreakpoint):
13123da8
SM
80 def __init__(self, frame):
81 gdb.FinishBreakpoint.__init__(self, frame)
82
83 print("SimpleFinishBreakpoint init")
84
85 def stop(self):
86 print("SimpleFinishBreakpoint stop")
87 return True
88
89 def out_of_scope(self):
90 print("SimpleFinishBreakpoint out of scope")
91
92
93print("Python script imported")
This page took 1.554351 seconds and 4 git commands to generate.