brintos

brintos / llvm-project-archived public Read only

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