brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · cc9ddca Raw
71 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 TestObjCIvarOffsets(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    @add_test_categories(["pyapi"])19    def test_with_python_api(self):20        """Test printing ObjC objects that use unbacked properties"""21        self.build()22        exe = self.getBuildArtifact("a.out")23 24        target = self.dbg.CreateTarget(exe)25        self.assertTrue(target, VALID_TARGET)26 27        breakpoint = target.BreakpointCreateByLocation(self.main_source, self.stop_line)28        self.assertTrue(breakpoint, VALID_BREAKPOINT)29 30        process = target.LaunchSimple(None, None, self.get_process_working_directory())31        self.assertTrue(process, "Created a process.")32        self.assertEqual(process.GetState(), lldb.eStateStopped, "Stopped it too.")33 34        thread_list = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint)35        self.assertEqual(len(thread_list), 1)36        thread = thread_list[0]37 38        frame = thread.GetFrameAtIndex(0)39        self.assertTrue(frame, "frame 0 is valid")40 41        mine = thread.GetFrameAtIndex(0).FindVariable("mine")42        self.assertTrue(mine, "Found local variable mine.")43 44        # Test the value object value for BaseClass->_backed_int45 46        error = lldb.SBError()47 48        mine_backed_int = mine.GetChildMemberWithName("_backed_int")49        self.assertTrue(mine_backed_int, "Found mine->backed_int local variable.")50        backed_value = mine_backed_int.GetValueAsSigned(error)51        self.assertSuccess(error)52        self.assertEqual(backed_value, 1111)53 54        # Test the value object value for DerivedClass->_derived_backed_int55 56        mine_derived_backed_int = mine.GetChildMemberWithName("_derived_backed_int")57        self.assertTrue(58            mine_derived_backed_int, "Found mine->derived_backed_int local variable."59        )60        derived_backed_value = mine_derived_backed_int.GetValueAsSigned(error)61        self.assertSuccess(error)62        self.assertEqual(derived_backed_value, 3333)63 64        # Make sure we also get bit-field offsets correct:65 66        mine_flag2 = mine.GetChildMemberWithName("flag2")67        self.assertTrue(mine_flag2, "Found mine->flag2 local variable.")68        flag2_value = mine_flag2.GetValueAsUnsigned(error)69        self.assertSuccess(error)70        self.assertEqual(flag2_value, 7)71