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 @skipIf( 24 debug_info=no_match("dsym"), 25 bugnumber="This test requires a stripped binary and a dSYM") 26 @add_test_categories(['pyapi']) 27 def test_with_python_api(self): 28 """Test that we can find stripped Objective-C ivars in the runtime""" 29 self.build() 30 exe = self.getBuildArtifact("a.out.stripped") 31 32 target = self.dbg.CreateTarget(exe) 33 self.assertTrue(target, VALID_TARGET) 34 35 self.dbg.HandleCommand("add-dsym "+self.getBuildArtifact("a.out.dSYM")) 36 37 breakpoint = target.BreakpointCreateByLocation( 38 self.main_source, self.stop_line) 39 self.assertTrue( 40 breakpoint.IsValid() and breakpoint.GetNumLocations() > 0, 41 VALID_BREAKPOINT) 42 43 process = target.LaunchSimple( 44 None, None, self.get_process_working_directory()) 45 self.assertTrue(process, "Created a process.") 46 self.assertTrue( 47 process.GetState() == lldb.eStateStopped, 48 "Stopped it too.") 49 50 thread_list = lldbutil.get_threads_stopped_at_breakpoint( 51 process, breakpoint) 52 self.assertEquals(len(thread_list), 1) 53 thread = thread_list[0] 54 55 frame = thread.GetFrameAtIndex(0) 56 self.assertTrue(frame, "frame 0 is valid") 57 58 # Test the expression for mc->_foo 59 60 error = lldb.SBError() 61 62 ivar = frame.EvaluateExpression("(mc->_foo)") 63 self.assertTrue(ivar, "Got result for mc->_foo") 64 ivar_value = ivar.GetValueAsSigned(error) 65 self.assertTrue(error.Success()) 66 self.assertEquals(ivar_value, 3) 67