Debian Codegraph @

lldb/test/API/commands/expression/expr-from-non-zero-frame/TestExprFromNonZeroFrame.py

raw
1 import lldb
2 from lldbsuite.test.decorators import *
3 from lldbsuite.test.lldbtest import *
4 from lldbsuite.test import lldbutil
5
6
7 class ExprFromNonZeroFrame(TestBase):
8 NO_DEBUG_INFO_TESTCASE = True
9
10 # Requires DWARF debug information.
11 @skipIfWindows
12 def test(self):
13 """
14 Tests that we can use SBFrame::EvaluateExpression on a frame
15 that we're not stopped in, even if thread-plans run as part of
16 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 we
26 # emit a ptrauth static initializer on arm64e into the JITted
27 # expression. The thread-plan that runs for this static
28 # initializer should save/restore the current execution context
29 # 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)