brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 4607308 Raw
33 lines · python
1import lldb2from lldbsuite.test.decorators import *3from lldbsuite.test.lldbtest import *4from lldbsuite.test import lldbutil5 6 7class ExprFromNonZeroFrame(TestBase):8    NO_DEBUG_INFO_TESTCASE = True9 10    # Requires DWARF debug information.11    @skipIfWindows12    def test(self):13        """14        Tests that we can use SBFrame::EvaluateExpression on a frame15        that we're not stopped in, even if thread-plans run as part of16        parsing the expression (e.g., when running static initializers).17        """18        self.build()19 20        (_, _, thread, _) = lldbutil.run_to_source_breakpoint(21            self, "return 5", lldb.SBFileSpec("main.c")22        )23        frame = thread.GetFrameAtIndex(1)24 25        # Using a function pointer inside the expression ensures we26        # emit a ptrauth static initializer on arm64e into the JITted27        # expression. The thread-plan that runs for this static28        # initializer should save/restore the current execution context29        # frame (which in this test is frame #1).30        result = frame.EvaluateExpression("int (*fptr)() = &func; fptr()")31        self.assertTrue(result.GetError().Success())32        self.assertEqual(result.GetValueAsSigned(), 5)33