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 14 mydir = TestBase.compute_mydir(__file__) 15 16 @skipIfAsan # The output looks different under ASAN. 17 @skipUnlessDarwin 18 @expectedFailureAll(oslist=["macosx"], debug_info=["dwarf", "gmodules"], bugnumber="llvm.org/pr45112") 19 def test_ptr_refs(self): 20 """Test format string functionality.""" 21 self.build() 22 exe = self.getBuildArtifact("a.out") 23 24 target = self.dbg.CreateTarget(exe) 25 self.assertTrue(target, VALID_TARGET) 26 27 main_file_spec = lldb.SBFileSpec('main.c') 28 breakpoint = target.BreakpointCreateBySourceRegex( 29 'break', main_file_spec) 30 self.assertTrue(breakpoint and 31 breakpoint.GetNumLocations() == 1, 32 VALID_BREAKPOINT) 33 34 process = target.LaunchSimple( 35 None, None, self.get_process_working_directory()) 36 self.assertTrue(process, PROCESS_IS_VALID) 37 38 # Frame #0 should be on self.line1 and the break condition should hold. 39 thread = lldbutil.get_stopped_thread( 40 process, lldb.eStopReasonBreakpoint) 41 self.assertTrue( 42 thread.IsValid(), 43 "There should be a thread stopped due to breakpoint condition") 44 45 frame = thread.GetFrameAtIndex(0) 46 47 self.runCmd("script import lldb.macosx.heap") 48 self.expect("ptr_refs my_ptr", substrs=["malloc", "stack"]) 49