1""" 2Test that breakpoints set on a bad address say they are bad. 3""" 4 5 6 7import lldb 8import lldbsuite.test.lldbutil as lldbutil 9from lldbsuite.test.lldbtest import * 10 11 12class BadAddressBreakpointTestCase(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 NO_DEBUG_INFO_TESTCASE = True 17 18 def test_bad_address_breakpoints(self): 19 """Test that breakpoints set on a bad address say they are bad.""" 20 self.build() 21 self.address_breakpoints() 22 23 def address_breakpoints(self): 24 """Test that breakpoints set on a bad address say they are bad.""" 25 target, process, thread, bkpt = \ 26 lldbutil.run_to_source_breakpoint(self, 27 "Set a breakpoint here", 28 lldb.SBFileSpec("main.c")) 29 30 31 32 # illegal_address will hold (optionally) an address that, if 33 # used as a breakpoint, will generate an unresolved breakpoint. 34 illegal_address = None 35 36 # Walk through all the memory regions in the process and 37 # find an address that is invalid. 38 regions = process.GetMemoryRegions() 39 for region_idx in range(regions.GetSize()): 40 region = lldb.SBMemoryRegionInfo() 41 regions.GetMemoryRegionAtIndex(region_idx, region) 42 if illegal_address == None or \ 43 region.GetRegionEnd() > illegal_address: 44 illegal_address = region.GetRegionEnd() 45 46 if illegal_address is not None: 47 # Now, set a breakpoint at the address we know is illegal. 48 bkpt = target.BreakpointCreateByAddress(illegal_address) 49 # Verify that breakpoint is not resolved. 50 for bp_loc in bkpt: 51 self.assertEquals(bp_loc.IsResolved(), False) 52 else: 53 self.fail( 54 "Could not find an illegal address at which to set a bad breakpoint.") 55