]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
Vendor import of lldb trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / postmortem / elf-core / thread_crash / TestLinuxCoreThreads.py
1 """
2 Test signal reporting when debugging with linux core files.
3 """
4
5 from __future__ import print_function
6
7 import shutil
8 import struct
9
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15
16 class LinuxCoreThreadsTestCase(TestBase):
17     NO_DEBUG_INFO_TESTCASE = True
18
19     mydir = TestBase.compute_mydir(__file__)
20     _initial_platform = lldb.DBG.GetSelectedPlatform()
21
22     _i386_pid = 5193
23     _x86_64_pid = 5222
24
25     # Thread id for the failing thread.
26     _i386_tid = 5195
27     _x86_64_tid = 5250
28
29     @skipIf(oslist=['windows'])
30     @skipIf(triple='^mips')
31     def test_i386(self):
32         """Test that lldb can read the process information from an i386 linux core file."""
33         self.do_test("linux-i386", self._i386_pid, self._i386_tid)
34
35     @skipIf(oslist=['windows'])
36     @skipIf(triple='^mips')
37     def test_x86_64(self):
38         """Test that lldb can read the process information from an x86_64 linux core file."""
39         self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_tid)
40
41     def do_test(self, filename, pid, tid):
42         target = self.dbg.CreateTarget("")
43         process = target.LoadCore(filename + ".core")
44         self.assertTrue(process, PROCESS_IS_VALID)
45         self.assertEqual(process.GetNumThreads(), 3)
46         self.assertEqual(process.GetProcessID(), pid)
47
48         for thread in process:
49             reason = thread.GetStopReason()
50             if( thread.GetThreadID() == tid ):
51                 self.assertEqual(reason, lldb.eStopReasonSignal)
52                 signal = thread.GetStopReasonDataAtIndex(1)
53                 # Check we got signal 4 (SIGILL)
54                 self.assertEqual(signal, 4)
55             else:
56                 signal = thread.GetStopReasonDataAtIndex(1)
57                 # Check we got no signal on the other threads
58                 self.assertEqual(signal, 0)
59
60         self.dbg.DeleteTarget(target)
61         lldb.DBG.SetSelectedPlatform(self._initial_platform)