2014-07-02 18:44:43 +00:00
|
|
|
"""
|
|
|
|
|
Test SBBreakpoint APIs.
|
|
|
|
|
"""
|
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
import os
|
|
|
|
|
import time
|
2014-07-02 18:44:43 +00:00
|
|
|
import re
|
2015-11-03 02:06:18 +00:00
|
|
|
import lldb
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test import lldbutil
|
2014-07-02 18:44:43 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-07-02 18:44:43 +00:00
|
|
|
class BreakpointAPITestCase(TestBase):
|
|
|
|
|
|
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2017-02-27 11:05:34 +00:00
|
|
|
NO_DEBUG_INFO_TESTCASE = True
|
2014-07-02 18:44:43 +00:00
|
|
|
|
2015-10-26 09:28:32 +00:00
|
|
|
@add_test_categories(['pyapi'])
|
2015-09-30 10:12:40 +00:00
|
|
|
def test_breakpoint_is_valid(self):
|
2014-07-02 18:44:43 +00:00
|
|
|
"""Make sure that if an SBBreakpoint gets deleted its IsValid returns false."""
|
2015-09-30 10:12:40 +00:00
|
|
|
self.build()
|
2018-01-19 23:24:35 +00:00
|
|
|
exe = self.getBuildArtifact("a.out")
|
2014-07-02 18:44:43 +00: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')
|
2015-10-23 17:04:29 +00:00
|
|
|
#print("breakpoint:", breakpoint)
|
2014-07-02 18:44:43 +00:00
|
|
|
self.assertTrue(breakpoint and
|
|
|
|
|
breakpoint.GetNumLocations() == 1,
|
|
|
|
|
VALID_BREAKPOINT)
|
|
|
|
|
|
|
|
|
|
# Now delete it:
|
|
|
|
|
did_delete = target.BreakpointDelete(breakpoint.GetID())
|
2016-09-06 20:57:50 +00:00
|
|
|
self.assertTrue(
|
|
|
|
|
did_delete,
|
|
|
|
|
"Did delete the breakpoint we just created.")
|
2014-07-02 18:44:43 +00:00
|
|
|
|
|
|
|
|
# Make sure we can't find it:
|
2016-09-06 20:57:50 +00:00
|
|
|
del_bkpt = target.FindBreakpointByID(breakpoint.GetID())
|
|
|
|
|
self.assertTrue(not del_bkpt, "We did delete the breakpoint.")
|
2014-07-02 18:44:43 +00:00
|
|
|
|
|
|
|
|
# Finally make sure the original breakpoint is no longer valid.
|
2016-09-06 20:57:50 +00:00
|
|
|
self.assertTrue(
|
|
|
|
|
not breakpoint,
|
|
|
|
|
"Breakpoint we deleted is no longer valid.")
|
2017-02-27 11:05:34 +00:00
|
|
|
|
|
|
|
|
@add_test_categories(['pyapi'])
|
|
|
|
|
def test_target_delete(self):
|
|
|
|
|
"""Make sure that if an SBTarget gets deleted the associated
|
|
|
|
|
Breakpoint's IsValid returns false."""
|
|
|
|
|
|
|
|
|
|
self.build()
|
2018-01-19 23:24:35 +00:00
|
|
|
exe = self.getBuildArtifact("a.out")
|
2017-02-27 11:05:34 +00: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')
|
|
|
|
|
#print("breakpoint:", breakpoint)
|
|
|
|
|
self.assertTrue(breakpoint and
|
|
|
|
|
breakpoint.GetNumLocations() == 1,
|
|
|
|
|
VALID_BREAKPOINT)
|
2017-03-01 10:08:48 +00:00
|
|
|
location = breakpoint.GetLocationAtIndex(0)
|
|
|
|
|
self.assertTrue(location.IsValid())
|
2017-02-27 11:05:34 +00:00
|
|
|
|
|
|
|
|
self.assertTrue(self.dbg.DeleteTarget(target))
|
|
|
|
|
self.assertFalse(breakpoint.IsValid())
|
2017-03-01 10:08:48 +00:00
|
|
|
self.assertFalse(location.IsValid())
|