2 Test that we can backtrace correctly with 'sigtramp' functions on the stack
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import lldbutil
11 class SigtrampUnwind(TestBase
):
12 # On different platforms the "_sigtramp" and "__kill" frames are likely to be different.
13 # This test could probably be adapted to run on linux/*bsd easily enough.
16 archs
=["arm64"], bugnumber
="<rdar://problem/34006863>"
17 ) # lldb skips 1 frame on arm64 above _sigtramp
19 """Test that we can backtrace correctly with _sigtramp on the stack"""
21 self
.setTearDownCleanup()
23 exe
= self
.getBuildArtifact("a.out")
24 target
= self
.dbg
.CreateTarget(exe
)
25 self
.assertTrue(target
, VALID_TARGET
)
27 lldbutil
.run_break_set_by_file_and_line(
30 line_number("main.c", "// Set breakpoint here"),
31 num_expected_locations
=1,
34 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
37 self
.fail("SBTarget.Launch() failed")
39 if process
.GetState() != lldb
.eStateStopped
:
41 "Process should be in the 'stopped' state, "
42 "instead the actual state is: '%s'"
43 % lldbutil
.state_type_to_str(process
.GetState())
47 "pro handle -n false -p true -s false SIGUSR1",
48 "Have lldb pass SIGUSR1 signals",
49 substrs
=["SIGUSR1", "true", "false", "false"],
52 lldbutil
.run_break_set_by_symbol(
53 self
, "handler", num_expected_locations
=1, module_name
="a.out"
56 self
.runCmd("continue")
58 thread
= process
.GetThreadAtIndex(0)
61 found_sigtramp
= False
65 for f
in thread
.frames
:
66 if f
.GetFunctionName() == "handler":
68 if f
.GetFunctionName() == "_sigtramp":
70 if f
.GetFunctionName() == "__kill":
72 if f
.GetFunctionName() == "main":
76 print("Backtrace once we're stopped:")
77 for f
in thread
.frames
:
78 print(" %d %s" % (f
.GetFrameID(), f
.GetFunctionName()))
81 self
.fail("Unable to find handler() in backtrace.")
83 if not found_sigtramp
:
84 self
.fail("Unable to find _sigtramp() in backtrace.")
87 self
.fail("Unable to find kill() in backtrace.")
90 self
.fail("Unable to find main() in backtrace.")