2 Test address breakpoints set with shared library of SBAddress work correctly.
8 import lldbsuite.test.lldbutil as lldbutil
9 from lldbsuite.test.lldbtest import *
12 class AddressBreakpointTestCase(TestBase):
14 mydir = TestBase.compute_mydir(__file__)
16 NO_DEBUG_INFO_TESTCASE = True
18 def test_address_breakpoints(self):
19 """Test address breakpoints set with shared library of SBAddress work correctly."""
21 self.address_breakpoints()
23 def address_breakpoints(self):
24 """Test address breakpoints set with shared library of SBAddress work correctly."""
25 exe = self.getBuildArtifact("a.out")
27 # Create a target by the debugger.
28 target = self.dbg.CreateTarget(exe)
29 self.assertTrue(target, VALID_TARGET)
31 # Now create a breakpoint on main.c by name 'c'.
32 breakpoint = target.BreakpointCreateBySourceRegex(
33 "Set a breakpoint here", lldb.SBFileSpec("main.c"))
34 self.assertTrue(breakpoint and
35 breakpoint.GetNumLocations() >= 1,
38 # Get the breakpoint location from breakpoint after we verified that,
39 # indeed, it has one location.
40 location = breakpoint.GetLocationAtIndex(0)
41 self.assertTrue(location and
43 VALID_BREAKPOINT_LOCATION)
45 # Next get the address from the location, and create an address breakpoint using
48 address = location.GetAddress()
49 target.BreakpointDelete(breakpoint.GetID())
51 breakpoint = target.BreakpointCreateBySBAddress(address)
53 # Disable ASLR. This will allow us to actually test (on platforms that support this flag)
54 # that the breakpoint was able to track the module.
56 launch_info = lldb.SBLaunchInfo(None)
57 flags = launch_info.GetLaunchFlags()
58 flags &= ~lldb.eLaunchFlagDisableASLR
59 launch_info.SetLaunchFlags(flags)
61 error = lldb.SBError()
63 process = target.Launch(launch_info, error)
64 self.assertTrue(process, PROCESS_IS_VALID)
66 # Did we hit our breakpoint?
67 from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
68 threads = get_threads_stopped_at_breakpoint(process, breakpoint)
71 "There should be a thread stopped at our breakpoint")
73 # The hit count for the breakpoint should be 1.
74 self.assertTrue(breakpoint.GetHitCount() == 1)
78 # Now re-launch and see that we hit the breakpoint again:
80 launch_info.SetLaunchFlags(flags)
82 process = target.Launch(launch_info, error)
83 self.assertTrue(process, PROCESS_IS_VALID)
85 thread = get_threads_stopped_at_breakpoint(process, breakpoint)
88 "There should be a thread stopped at our breakpoint")
90 # The hit count for the breakpoint should now be 2.
91 self.assertTrue(breakpoint.GetHitCount() == 2)