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