1 """Test printing ObjC objects that use unbacked properties - so that the static ivar offsets are incorrect."""
3 from __future__ import print_function
9 from lldbsuite.test.lldbtest import *
10 import lldbsuite.test.lldbutil as lldbutil
12 class TestObjCIvarStripped(TestBase):
14 mydir = TestBase.compute_mydir(__file__)
17 # Call super's setUp().
19 # Find the line numbers to break inside main().
20 self.main_source = "main.m"
21 self.stop_line = line_number(self.main_source, '// Set breakpoint here.')
24 @skipIfDwarf # This test requires a stripped binary and a dSYM
25 @skipIfDWO # 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"""
30 exe = os.path.join(os.getcwd(), "a.out.stripped")
32 target = self.dbg.CreateTarget(exe)
33 self.assertTrue(target, VALID_TARGET)
35 self.dbg.HandleCommand("add-dsym a.out.dSYM")
37 breakpoint = target.BreakpointCreateByLocation(self.main_source, self.stop_line)
38 self.assertTrue(breakpoint.IsValid() and breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT)
40 process = target.LaunchSimple (None, None, self.get_process_working_directory())
41 self.assertTrue (process, "Created a process.")
42 self.assertTrue (process.GetState() == lldb.eStateStopped, "Stopped it too.")
44 thread_list = lldbutil.get_threads_stopped_at_breakpoint (process, breakpoint)
45 self.assertTrue (len(thread_list) == 1)
46 thread = thread_list[0]
48 frame = thread.GetFrameAtIndex(0)
49 self.assertTrue (frame, "frame 0 is valid")
51 # Test the expression for mc->_foo
53 error = lldb.SBError()
55 ivar = frame.EvaluateExpression ("(mc->_foo)")
56 self.assertTrue(ivar, "Got result for mc->_foo")
57 ivar_value = ivar.GetValueAsSigned (error)
58 self.assertTrue (error.Success())
59 self.assertTrue (ivar_value == 3)