2012-01-04 08:28:28 +00:00
|
|
|
# Copyright (C) 2011-2012 Free Software Foundation, Inc.
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# This file is part of the GDB testsuite. It tests python Finish
|
|
|
|
# Breakpoints.
|
2012-12-10 21:22:21 +00:00
|
|
|
|
2011-12-23 17:06:16 +00:00
|
|
|
class MyFinishBreakpoint (gdb.FinishBreakpoint):
|
2012-12-10 21:22:21 +00:00
|
|
|
def __init__(self, val, frame):
|
|
|
|
gdb.FinishBreakpoint.__init__ (self, frame)
|
|
|
|
print ("MyFinishBreakpoint init")
|
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
print ("MyFinishBreakpoint stop with %d" % int (self.val.dereference ()))
|
|
|
|
print ("return_value is: %d" % int (self.return_value))
|
|
|
|
gdb.execute ("where 1")
|
|
|
|
return True
|
|
|
|
|
|
|
|
def out_of_scope(self):
|
|
|
|
print ("MyFinishBreakpoint out of scope")
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
class TestBreakpoint(gdb.Breakpoint):
|
|
|
|
def __init__(self):
|
|
|
|
gdb.Breakpoint.__init__ (self, spec="test_1", internal=1)
|
|
|
|
self.silent = True
|
|
|
|
self.count = 0
|
2012-12-10 21:22:21 +00:00
|
|
|
print ("TestBreakpoint init")
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
def stop(self):
|
2012-12-10 21:22:21 +00:00
|
|
|
self.count += 1
|
|
|
|
try:
|
|
|
|
TestFinishBreakpoint (gdb.newest_frame (), self.count)
|
2011-12-23 17:06:16 +00:00
|
|
|
except ValueError as e:
|
2012-12-10 21:22:21 +00:00
|
|
|
print (e)
|
2011-12-23 17:06:16 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
class TestFinishBreakpoint (gdb.FinishBreakpoint):
|
|
|
|
def __init__ (self, frame, count):
|
2012-12-10 21:22:21 +00:00
|
|
|
self.count = count
|
2011-12-23 17:06:16 +00:00
|
|
|
gdb.FinishBreakpoint.__init__ (self, frame, internal=1)
|
|
|
|
|
|
|
|
|
|
|
|
def stop(self):
|
2012-12-10 21:22:21 +00:00
|
|
|
print ("-->", self.number)
|
2011-12-23 17:06:16 +00:00
|
|
|
if (self.count == 3):
|
2012-12-10 21:22:21 +00:00
|
|
|
print ("test stop: %d" % self.count)
|
2011-12-23 17:06:16 +00:00
|
|
|
return True
|
|
|
|
else:
|
2012-12-10 21:22:21 +00:00
|
|
|
print ("test don't stop: %d" % self.count)
|
2011-12-23 17:06:16 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def out_of_scope(self):
|
2012-12-10 21:22:21 +00:00
|
|
|
print ("test didn't finish: %d" % self.count)
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
class TestExplicitBreakpoint(gdb.Breakpoint):
|
2012-12-10 21:22:21 +00:00
|
|
|
def stop(self):
|
|
|
|
try:
|
|
|
|
SimpleFinishBreakpoint (gdb.newest_frame ())
|
|
|
|
except ValueError as e:
|
|
|
|
print (e)
|
|
|
|
return False
|
2011-12-23 17:06:16 +00:00
|
|
|
|
|
|
|
class SimpleFinishBreakpoint(gdb.FinishBreakpoint):
|
2012-12-10 21:22:21 +00:00
|
|
|
def __init__(self, frame):
|
|
|
|
gdb.FinishBreakpoint.__init__ (self, frame)
|
|
|
|
|
|
|
|
print ("SimpleFinishBreakpoint init")
|
|
|
|
|
|
|
|
def stop(self):
|
|
|
|
print ("SimpleFinishBreakpoint stop" )
|
|
|
|
return True
|
|
|
|
|
|
|
|
def out_of_scope(self):
|
|
|
|
print ("SimpleFinishBreakpoint out of scope")
|
2011-12-23 17:06:16 +00:00
|
|
|
|
2012-12-10 21:22:21 +00:00
|
|
|
print ("Python script imported")
|