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 @skipIfAsan # The output looks different under ASAN. 14 def test_ptr_refs(self): 15 """Test the ptr_refs tool on Darwin with Objective-C""" 16 self.build() 17 exe = self.getBuildArtifact("a.out") 18 19 target = self.dbg.CreateTarget(exe) 20 self.assertTrue(target, VALID_TARGET) 21 22 main_file_spec = lldb.SBFileSpec("main.m") 23 breakpoint = target.BreakpointCreateBySourceRegex("break", main_file_spec) 24 self.assertTrue( 25 breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT 26 ) 27 28 process = target.LaunchSimple(None, None, self.get_process_working_directory()) 29 self.assertTrue(process, PROCESS_IS_VALID) 30 31 # Frame #0 should be on self.line1 and the break condition should hold. 32 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) 33 self.assertTrue( 34 thread.IsValid(), 35 "There should be a thread stopped due to breakpoint condition", 36 ) 37 38 frame = thread.GetFrameAtIndex(0) 39 40 self.runCmd("command script import lldb.macosx.heap") 41 self.expect("ptr_refs self", substrs=["malloc", "stack"]) 42