1""" 2Test the ptr_refs tool on Darwin with Objective-C 3""" 4 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class TestPtrRefsObjC(TestBase): 13 14 mydir = TestBase.compute_mydir(__file__) 15 16 @skipIfAsan # The output looks different under ASAN. 17 def test_ptr_refs(self): 18 """Test the ptr_refs tool on Darwin with Objective-C""" 19 self.build() 20 exe = self.getBuildArtifact("a.out") 21 22 target = self.dbg.CreateTarget(exe) 23 self.assertTrue(target, VALID_TARGET) 24 25 main_file_spec = lldb.SBFileSpec('main.m') 26 breakpoint = target.BreakpointCreateBySourceRegex( 27 'break', main_file_spec) 28 self.assertTrue(breakpoint and 29 breakpoint.GetNumLocations() == 1, 30 VALID_BREAKPOINT) 31 32 process = target.LaunchSimple( 33 None, None, self.get_process_working_directory()) 34 self.assertTrue(process, PROCESS_IS_VALID) 35 36 # Frame #0 should be on self.line1 and the break condition should hold. 37 thread = lldbutil.get_stopped_thread( 38 process, lldb.eStopReasonBreakpoint) 39 self.assertTrue( 40 thread.IsValid(), 41 "There should be a thread stopped due to breakpoint condition") 42 43 frame = thread.GetFrameAtIndex(0) 44 45 self.runCmd("command script import lldb.macosx.heap") 46 self.expect("ptr_refs self", substrs=["malloc", "stack"]) 47 48