2 Test that we can backtrace correctly with 'sigtramp' functions on the stack
5 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
16 class SigtrampUnwind(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
19 # On different platforms the "_sigtramp" and "__kill" frames are likely to be different.
20 # This test could probably be adapted to run on linux/*bsd easily enough.
23 """Test that we can backtrace correctly with _sigtramp on the stack"""
25 self.setTearDownCleanup()
27 exe = os.path.join(os.getcwd(), "a.out")
28 target = self.dbg.CreateTarget(exe)
29 self.assertTrue(target, VALID_TARGET)
31 lldbutil.run_break_set_by_file_and_line(self, "main.c", line_number(
32 'main.c', '// Set breakpoint here'), num_expected_locations=1)
34 process = target.LaunchSimple(
35 None, None, self.get_process_working_directory())
38 self.fail("SBTarget.Launch() failed")
40 if process.GetState() != lldb.eStateStopped:
41 self.fail("Process should be in the 'stopped' state, "
42 "instead the actual state is: '%s'" %
43 lldbutil.state_type_to_str(process.GetState()))
46 "pro handle -n false -p true -s false SIGUSR1",
47 "Have lldb pass SIGUSR1 signals",
54 lldbutil.run_break_set_by_symbol(
57 num_expected_locations=1,
60 self.runCmd("continue")
62 thread = process.GetThreadAtIndex(0)
65 found_sigtramp = False
69 for f in thread.frames:
70 if f.GetFunctionName() == "handler":
72 if f.GetFunctionName() == "_sigtramp":
74 if f.GetFunctionName() == "__kill":
76 if f.GetFunctionName() == "main":
80 print("Backtrace once we're stopped:")
81 for f in thread.frames:
82 print(" %d %s" % (f.GetFrameID(), f.GetFunctionName()))
85 self.fail("Unable to find handler() in backtrace.")
87 if not found_sigtramp:
88 self.fail("Unable to find _sigtramp() in backtrace.")
91 self.fail("Unable to find kill() in backtrace.")
94 self.fail("Unable to find main() in backtrace.")