2014-07-03 02:44:43 +08:00
|
|
|
"""
|
|
|
|
Test SBBreakpoint APIs.
|
|
|
|
"""
|
|
|
|
|
2015-11-03 10:06:18 +08:00
|
|
|
import lldb
|
2016-02-05 07:04:17 +08:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 10:06:18 +08:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-05 07:04:17 +08:00
|
|
|
from lldbsuite.test import lldbutil
|
2014-07-03 02:44:43 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2014-07-03 02:44:43 +08:00
|
|
|
class BreakpointAPITestCase(TestBase):
|
|
|
|
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2017-02-27 19:05:34 +08:00
|
|
|
NO_DEBUG_INFO_TESTCASE = True
|
2014-07-03 02:44:43 +08:00
|
|
|
|
2015-09-30 18:12:40 +08:00
|
|
|
def test_breakpoint_is_valid(self):
|
2014-07-03 02:44:43 +08:00
|
|
|
"""Make sure that if an SBBreakpoint gets deleted its IsValid returns false."""
|
2015-09-30 18:12:40 +08:00
|
|
|
self.build()
|
2018-01-20 07:24:35 +08:00
|
|
|
exe = self.getBuildArtifact("a.out")
|
2014-07-03 02:44:43 +08:00
|
|
|
|
|
|
|
# Create a target by the debugger.
|
|
|
|
target = self.dbg.CreateTarget(exe)
|
|
|
|
self.assertTrue(target, VALID_TARGET)
|
|
|
|
|
|
|
|
# Now create a breakpoint on main.c by name 'AFunction'.
|
|
|
|
breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
|
2020-05-26 01:59:39 +08:00
|
|
|
self.trace("breakpoint:", breakpoint)
|
2014-07-03 02:44:43 +08:00
|
|
|
self.assertTrue(breakpoint and
|
|
|
|
breakpoint.GetNumLocations() == 1,
|
|
|
|
VALID_BREAKPOINT)
|
|
|
|
|
|
|
|
# Now delete it:
|
|
|
|
did_delete = target.BreakpointDelete(breakpoint.GetID())
|
|
|
|
self.assertTrue(
|
|
|
|
did_delete,
|
|
|
|
"Did delete the breakpoint we just created.")
|
|
|
|
|
|
|
|
# Make sure we can't find it:
|
|
|
|
del_bkpt = target.FindBreakpointByID(breakpoint.GetID())
|
|
|
|
self.assertTrue(not del_bkpt, "We did delete the breakpoint.")
|
|
|
|
|
|
|
|
# Finally make sure the original breakpoint is no longer valid.
|
|
|
|
self.assertTrue(
|
|
|
|
not breakpoint,
|
|
|
|
"Breakpoint we deleted is no longer valid.")
|
2017-02-27 19:05:34 +08:00
|
|
|
|
|
|
|
def test_target_delete(self):
|
|
|
|
"""Make sure that if an SBTarget gets deleted the associated
|
|
|
|
Breakpoint's IsValid returns false."""
|
|
|
|
|
|
|
|
self.build()
|
2018-01-20 07:24:35 +08:00
|
|
|
exe = self.getBuildArtifact("a.out")
|
2017-02-27 19:05:34 +08:00
|
|
|
|
|
|
|
# Create a target by the debugger.
|
|
|
|
target = self.dbg.CreateTarget(exe)
|
|
|
|
self.assertTrue(target, VALID_TARGET)
|
|
|
|
|
|
|
|
# Now create a breakpoint on main.c by name 'AFunction'.
|
|
|
|
breakpoint = target.BreakpointCreateByName('AFunction', 'a.out')
|
2020-05-26 01:59:39 +08:00
|
|
|
self.trace("breakpoint:", breakpoint)
|
2017-02-27 19:05:34 +08:00
|
|
|
self.assertTrue(breakpoint and
|
|
|
|
breakpoint.GetNumLocations() == 1,
|
|
|
|
VALID_BREAKPOINT)
|
2017-03-01 18:08:48 +08:00
|
|
|
location = breakpoint.GetLocationAtIndex(0)
|
|
|
|
self.assertTrue(location.IsValid())
|
2017-02-27 19:05:34 +08:00
|
|
|
|
2020-10-16 05:28:06 +08:00
|
|
|
# Make sure the breakpoint's target is right:
|
|
|
|
self.assertEqual(target, breakpoint.GetTarget(), "Breakpoint reports its target correctly")
|
|
|
|
|
2017-02-27 19:05:34 +08:00
|
|
|
self.assertTrue(self.dbg.DeleteTarget(target))
|
|
|
|
self.assertFalse(breakpoint.IsValid())
|
2017-03-01 18:08:48 +08:00
|
|
|
self.assertFalse(location.IsValid())
|