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