1"""Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect.""" 2 3 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class TestObjCIvarStripped(TestBase): 12 13 mydir = TestBase.compute_mydir(__file__) 14 15 def setUp(self): 16 # Call super's setUp(). 17 TestBase.setUp(self) 18 # Find the line numbers to break inside main(). 19 self.main_source = "main.m" 20 self.stop_line = line_number( 21 self.main_source, '// Set breakpoint here.') 22 23 @skipUnlessDarwin 24 @skipIf( 25 debug_info=no_match("dsym"), 26 bugnumber="This test requires a stripped binary and a dSYM") 27 @add_test_categories(['pyapi']) 28 def test_with_python_api(self): 29 """Test that we can find stripped Objective-C ivars in the runtime""" 30 self.build() 31 exe = self.getBuildArtifact("a.out.stripped") 32 33 target = self.dbg.CreateTarget(exe) 34 self.assertTrue(target, VALID_TARGET) 35 36 self.dbg.HandleCommand("add-dsym "+self.getBuildArtifact("a.out.dSYM")) 37 38 breakpoint = target.BreakpointCreateByLocation( 39 self.main_source, self.stop_line) 40 self.assertTrue( 41 breakpoint.IsValid() and breakpoint.GetNumLocations() > 0, 42 VALID_BREAKPOINT) 43 44 process = target.LaunchSimple( 45 None, None, self.get_process_working_directory()) 46 self.assertTrue(process, "Created a process.") 47 self.assertTrue( 48 process.GetState() == lldb.eStateStopped, 49 "Stopped it too.") 50 51 thread_list = lldbutil.get_threads_stopped_at_breakpoint( 52 process, breakpoint) 53 self.assertEquals(len(thread_list), 1) 54 thread = thread_list[0] 55 56 frame = thread.GetFrameAtIndex(0) 57 self.assertTrue(frame, "frame 0 is valid") 58 59 # Test the expression for mc->_foo 60 61 error = lldb.SBError() 62 63 ivar = frame.EvaluateExpression("(mc->_foo)") 64 self.assertTrue(ivar, "Got result for mc->_foo") 65 ivar_value = ivar.GetValueAsSigned(error) 66 self.assertTrue(error.Success()) 67 self.assertEquals(ivar_value, 3) 68