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.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class TestObjCIvarStripped(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
19 # Call super's setUp().
21 # Find the line numbers to break inside main().
22 self.main_source = "main.m"
23 self.stop_line = line_number(
24 self.main_source, '// Set breakpoint here.')
28 debug_info=no_match("dsym"),
29 bugnumber="This test requires a stripped binary and a dSYM")
30 @add_test_categories(['pyapi'])
31 def test_with_python_api(self):
32 """Test that we can find stripped Objective-C ivars in the runtime"""
34 exe = os.path.join(os.getcwd(), "a.out.stripped")
36 target = self.dbg.CreateTarget(exe)
37 self.assertTrue(target, VALID_TARGET)
39 self.dbg.HandleCommand("add-dsym a.out.dSYM")
41 breakpoint = target.BreakpointCreateByLocation(
42 self.main_source, self.stop_line)
44 breakpoint.IsValid() and breakpoint.GetNumLocations() > 0,
47 process = target.LaunchSimple(
48 None, None, self.get_process_working_directory())
49 self.assertTrue(process, "Created a process.")
51 process.GetState() == lldb.eStateStopped,
54 thread_list = lldbutil.get_threads_stopped_at_breakpoint(
56 self.assertTrue(len(thread_list) == 1)
57 thread = thread_list[0]
59 frame = thread.GetFrameAtIndex(0)
60 self.assertTrue(frame, "frame 0 is valid")
62 # Test the expression for mc->_foo
64 error = lldb.SBError()
66 ivar = frame.EvaluateExpression("(mc->_foo)")
67 self.assertTrue(ivar, "Got result for mc->_foo")
68 ivar_value = ivar.GetValueAsSigned(error)
69 self.assertTrue(error.Success())
70 self.assertTrue(ivar_value == 3)