2 Test that breakpoints set on a bad address say they are bad.
5 from __future__ import print_function
12 import lldbsuite.test.lldbutil as lldbutil
13 from lldbsuite.test.lldbtest import *
16 class BadAddressBreakpointTestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
20 NO_DEBUG_INFO_TESTCASE = True
22 def test_bad_address_breakpoints(self):
23 """Test that breakpoints set on a bad address say they are bad."""
25 self.address_breakpoints()
28 # Call super's setUp().
31 def address_breakpoints(self):
32 """Test that breakpoints set on a bad address say they are bad."""
33 exe = os.path.join(os.getcwd(), "a.out")
35 # Create a target by the debugger.
36 target = self.dbg.CreateTarget(exe)
37 self.assertTrue(target, VALID_TARGET)
39 # Now create a breakpoint on main.c by name 'c'.
40 breakpoint = target.BreakpointCreateBySourceRegex(
41 "Set a breakpoint here", lldb.SBFileSpec("main.c"))
42 self.assertTrue(breakpoint and
43 breakpoint.GetNumLocations() == 1,
46 # Get the breakpoint location from breakpoint after we verified that,
47 # indeed, it has one location.
48 location = breakpoint.GetLocationAtIndex(0)
49 self.assertTrue(location and
51 VALID_BREAKPOINT_LOCATION)
53 launch_info = lldb.SBLaunchInfo(None)
55 error = lldb.SBError()
57 process = target.Launch(launch_info, error)
58 self.assertTrue(process, PROCESS_IS_VALID)
60 # Did we hit our breakpoint?
61 from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
62 threads = get_threads_stopped_at_breakpoint(process, breakpoint)
65 "There should be a thread stopped at our breakpoint")
67 # The hit count for the breakpoint should be 1.
68 self.assertTrue(breakpoint.GetHitCount() == 1)
70 # Now see if we can read from 0. If I can't do that, I don't have a good way to know
71 # what an illegal address is...
74 ptr = process.ReadPointerFromMemory(0x0, error)
76 if not error.Success():
77 bkpt = target.BreakpointCreateByAddress(0x0)
79 self.assertTrue(bp_loc.IsResolved() == False)
82 "Could not find an illegal address at which to set a bad breakpoint.")