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 NO_DEBUG_INFO_TESTCASE = True 15 16 def test_bad_address_breakpoints(self): 17 """Test that breakpoints set on a bad address say they are bad.""" 18 self.build() 19 self.address_breakpoints() 20 21 def address_breakpoints(self): 22 """Test that breakpoints set on a bad address say they are bad.""" 23 target, process, thread, bkpt = \ 24 lldbutil.run_to_source_breakpoint(self, 25 "Set a breakpoint here", 26 lldb.SBFileSpec("main.c")) 27 28 29 30 # illegal_address will hold (optionally) an address that, if 31 # used as a breakpoint, will generate an unresolved breakpoint. 32 illegal_address = None 33 34 # Walk through all the memory regions in the process and 35 # find an address that is invalid. 36 regions = process.GetMemoryRegions() 37 for region_idx in range(regions.GetSize()): 38 region = lldb.SBMemoryRegionInfo() 39 regions.GetMemoryRegionAtIndex(region_idx, region) 40 if illegal_address == None or \ 41 region.GetRegionEnd() > illegal_address: 42 illegal_address = region.GetRegionEnd() 43 44 if illegal_address is not None: 45 # Now, set a breakpoint at the address we know is illegal. 46 bkpt = target.BreakpointCreateByAddress(illegal_address) 47 # Verify that breakpoint is not resolved. 48 for bp_loc in bkpt: 49 self.assertEquals(bp_loc.IsResolved(), False) 50 else: 51 self.fail( 52 "Could not find an illegal address at which to set a bad breakpoint.") 53