brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 382b0e7 Raw
60 lines · python
1"""Test that SBValue clears non-addressable bits"""2 3import lldb4from lldbsuite.test.decorators import *5from lldbsuite.test.lldbtest import *6from lldbsuite.test import lldbutil7 8 9class TestClearSBValueNonAddressableBits(TestBase):10    NO_DEBUG_INFO_TESTCASE = True11 12    # On AArch64 systems, the top bits that are not used for13    # addressing may be used for TBI, MTE, and/or pointer14    # authentication.15    @skipIf(archs=no_match(["aarch64", "arm64", "arm64e"]))16 17    # Only run this test on systems where TBI is known to be18    # enabled, so the address mask will clear the TBI bits.19    @skipUnlessPlatform(["linux"] + lldbplatformutil.getDarwinOSTriples())20    def test(self):21        self.source = "main.c"22        self.build()23        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(24            self, "break here", lldb.SBFileSpec(self.source, False)25        )26 27        if self.TraceOn():28            self.runCmd("frame variable")29            self.runCmd("frame variable &count &global")30 31        frame = thread.GetFrameAtIndex(0)32 33        count_p = frame.FindVariable("count_p")34        count_invalid_p = frame.FindVariable("count_invalid_p")35        self.assertEqual(36            count_p.GetValueAsUnsigned(), count_invalid_p.GetValueAsAddress()37        )38        self.assertNotEqual(39            count_invalid_p.GetValueAsUnsigned(), count_invalid_p.GetValueAsAddress()40        )41        self.assertEqual(5, count_p.Dereference().GetValueAsUnsigned())42        self.assertEqual(5, count_invalid_p.Dereference().GetValueAsUnsigned())43 44        global_p = frame.FindVariable("global_p")45        global_invalid_p = frame.FindVariable("global_invalid_p")46        self.assertEqual(47            global_p.GetValueAsUnsigned(), global_invalid_p.GetValueAsAddress()48        )49        self.assertNotEqual(50            global_invalid_p.GetValueAsUnsigned(), global_invalid_p.GetValueAsAddress()51        )52        self.assertEqual(10, global_p.Dereference().GetValueAsUnsigned())53        self.assertEqual(10, global_invalid_p.Dereference().GetValueAsUnsigned())54 55        main_p = frame.FindVariable("main_p")56        main_invalid_p = frame.FindVariable("main_invalid_p")57        self.assertEqual(58            main_p.GetValueAsUnsigned(), main_invalid_p.GetValueAsAddress()59        )60