2 Test that we can backtrace correctly when AArch64 PAC is enabled
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import lldbutil
11 class AArch64UnwindPAC(TestBase
):
12 @skipIf(archs
=no_match(["aarch64"]))
13 @skipIf(oslist
=no_match(["linux"]))
15 """Test that we can backtrace correctly when AArch64 PAC is enabled"""
16 if not self
.isAArch64PAuth():
17 self
.skipTest("Target must support Pointer Authentication.")
21 self
.line
= line_number("main.c", "// Frame func_c")
23 exe
= self
.getBuildArtifact("a.out")
24 self
.runCmd("file " + exe
, CURRENT_EXECUTABLE_SET
)
26 lldbutil
.run_break_set_by_file_and_line(
27 self
, "main.c", self
.line
, num_expected_locations
=1
29 self
.runCmd("run", RUN_SUCCEEDED
)
32 STOPPED_DUE_TO_BREAKPOINT
,
33 substrs
=["stop reason = breakpoint 1."],
36 target
= self
.dbg
.GetSelectedTarget()
37 process
= target
.GetProcess()
38 thread
= process
.GetThreadAtIndex(0)
52 self
.assertGreaterEqual(
53 thread
.GetNumFrames(), len(backtrace
) + len(libc_backtrace
)
56 # Strictly check frames that are in the test program's source.
57 for frame_idx
, frame
in enumerate(thread
.frames
[: len(backtrace
)]):
58 self
.assertTrue(frame
)
59 self
.assertEqual(frame
.GetFunctionName(), backtrace
[frame_idx
])
61 frame
.GetLineEntry().GetLine(),
62 line_number("main.c", "Frame " + backtrace
[frame_idx
]),
65 # After the program comes some libc frames. The number varies by
66 # system, so ensure we have at least these two in this order,
67 # skipping frames in between.
68 start_idx
= frame_idx
+ 1
69 for frame_idx
, frame
in enumerate(thread
.frames
[start_idx
:], start
=start_idx
):
70 self
.assertTrue(frame
)
71 if libc_backtrace
[0] == frame
.GetFunctionName():
74 self
.assertFalse(libc_backtrace
, "Did not find expected libc frames.")