1 """Test that we can debug inferiors that handle SIGSEGV by themselves"""
3 from __future__ import print_function
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
12 from lldbsuite.test import lldbutil
15 class HandleSegvTestCase(TestBase):
17 mydir = TestBase.compute_mydir(__file__)
19 @skipIfWindows # signals do not exist on Windows
23 bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
24 def test_inferior_handle_sigsegv(self):
26 exe = os.path.join(os.getcwd(), "a.out")
28 # Create a target by the debugger.
29 target = self.dbg.CreateTarget(exe)
30 self.assertTrue(target, VALID_TARGET)
33 process = target.LaunchSimple(
34 None, None, self.get_process_working_directory())
35 self.assertTrue(process, PROCESS_IS_VALID)
36 self.assertEqual(process.GetState(), lldb.eStateStopped)
37 signo = process.GetUnixSignals().GetSignalNumberFromName("SIGSEGV")
39 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal)
41 thread and thread.IsValid(),
42 "Thread should be stopped due to a signal")
44 thread.GetStopReasonDataCount() >= 1,
45 "There was data in the event.")
46 self.assertEqual(thread.GetStopReasonDataAtIndex(0),
47 signo, "The stop signal was SIGSEGV")
49 # Continue until we exit.
51 self.assertEqual(process.GetState(), lldb.eStateExited)
52 self.assertEqual(process.GetExitStatus(), 0)