]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / signal / handle-segv / TestHandleSegv.py
1 """Test that we can debug inferiors that handle SIGSEGV by themselves"""
2
3 from __future__ import print_function
4
5
6 import os
7 import re
8
9 import lldb
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
12 from lldbsuite.test import lldbutil
13
14
15 class HandleSegvTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     @skipIfWindows  # signals do not exist on Windows
20     @skipIfDarwin
21     @expectedFailureAll(
22         oslist=['freebsd'],
23         bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
24     def test_inferior_handle_sigsegv(self):
25         self.build()
26         exe = os.path.join(os.getcwd(), "a.out")
27
28         # Create a target by the debugger.
29         target = self.dbg.CreateTarget(exe)
30         self.assertTrue(target, VALID_TARGET)
31
32         # launch
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")
38
39         thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal)
40         self.assertTrue(
41             thread and thread.IsValid(),
42             "Thread should be stopped due to a signal")
43         self.assertTrue(
44             thread.GetStopReasonDataCount() >= 1,
45             "There was data in the event.")
46         self.assertEqual(thread.GetStopReasonDataAtIndex(0),
47                          signo, "The stop signal was SIGSEGV")
48
49         # Continue until we exit.
50         process.Continue()
51         self.assertEqual(process.GetState(), lldb.eStateExited)
52         self.assertEqual(process.GetExitStatus(), 0)