1 """Test that we can unwind out of a signal handler.
2 Which for AArch64 Linux requires a specific unwind plan."""
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import lldbutil
11 class UnwindSignalTestCase(TestBase
):
12 NO_DEBUG_INFO_TESTCASE
= True
14 @skipUnlessArch("aarch64")
15 @skipUnlessPlatform(["linux"])
16 def test_unwind_signal(self
):
17 """Inferior calls sigill() and handles the resultant SIGILL.
18 Stopped at a breakpoint in the handler, check that we can unwind
19 back to sigill() and get the expected register contents there."""
21 exe
= self
.getBuildArtifact("a.out")
23 target
= self
.dbg
.CreateTarget(exe
)
24 self
.assertTrue(target
, VALID_TARGET
)
26 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
27 self
.assertTrue(process
, PROCESS_IS_VALID
)
28 self
.assertState(process
.GetState(), lldb
.eStateStopped
)
29 signo
= process
.GetUnixSignals().GetSignalNumberFromName("SIGILL")
31 thread
= lldbutil
.get_stopped_thread(process
, lldb
.eStopReasonSignal
)
33 thread
and thread
.IsValid(), "Thread should be stopped due to a signal"
36 thread
.GetStopReasonDataCount() >= 1, "There should be data in the event."
39 thread
.GetStopReasonDataAtIndex(0),
41 "The stop signal should be SIGILL",
44 # Continue to breakpoint in sigill handler
45 bkpt
= target
.FindBreakpointByID(
46 lldbutil
.run_break_set_by_source_regexp(self
, "Set a breakpoint here")
48 threads
= lldbutil
.continue_to_breakpoint(process
, bkpt
)
49 self
.assertEqual(len(threads
), 1, "Expected single thread")
52 # Expect breakpoint in 'handler'
53 frame
= thread
.GetFrameAtIndex(0)
54 self
.assertEqual(frame
.GetDisplayFunctionName(), "handler", "Unexpected break?")
56 # Expect that unwinding should find 'sigill'
58 for frame
in thread
.get_thread_frames():
59 if frame
.GetDisplayFunctionName() == "sigill":
60 # We should have ascending values in the x registers
61 regs
= frame
.GetRegisters().GetValueAtIndex(0)
65 name
= "x{}".format(i
)
66 value
= regs
.GetChildMemberWithName(name
).GetValueAsUnsigned(err
)
67 self
.assertSuccess(err
, "Failed to get register {}".format(name
))
69 value
, i
, "Unexpected value for register {}".format(name
)
76 found_caller
, "Unwinding did not find func that caused the SIGILL"
79 # Continue until we exit.
81 self
.assertState(process
.GetState(), lldb
.eStateExited
)
82 self
.assertEqual(process
.GetExitStatus(), 0)