4be7ebe3122efa5eacf9d3e781e69ea972385a2b
[openbsd] /
1 """
2 Test signal reporting when debugging with linux core files.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class LinuxCoreThreadsTestCase(TestBase):
14     NO_DEBUG_INFO_TESTCASE = True
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def setUp(self):
19         super(LinuxCoreThreadsTestCase, self).setUp()
20         self._initial_platform = lldb.DBG.GetSelectedPlatform()
21
22     def tearDown(self):
23         lldb.DBG.SetSelectedPlatform(self._initial_platform)
24         super(LinuxCoreThreadsTestCase, self).tearDown()
25
26     _i386_pid = 5193
27     _x86_64_pid = 5222
28
29     # Thread id for the failing thread.
30     _i386_tid = 5195
31     _x86_64_tid = 5250
32
33     @skipIf(oslist=['windows'])
34     @skipIf(triple='^mips')
35     def test_i386(self):
36         """Test that lldb can read the process information from an i386 linux core file."""
37         self.do_test("linux-i386", self._i386_pid, self._i386_tid)
38
39     @skipIf(oslist=['windows'])
40     @skipIf(triple='^mips')
41     def test_x86_64(self):
42         """Test that lldb can read the process information from an x86_64 linux core file."""
43         self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_tid)
44
45     def do_test(self, filename, pid, tid):
46         target = self.dbg.CreateTarget("")
47         process = target.LoadCore(filename + ".core")
48         self.assertTrue(process, PROCESS_IS_VALID)
49         self.assertEqual(process.GetNumThreads(), 3)
50         self.assertEqual(process.GetProcessID(), pid)
51
52         for thread in process:
53             # Verify that if we try to read memory from a PT_LOAD that has
54             # p_filesz of zero that we don't get bytes from the next section
55             # that actually did have bytes. The addresses below were found by
56             # dumping the program headers of linux-i386.core and
57             # linux-x86_64.core and verifying that they had a p_filesz of zero.
58             mem_err = lldb.SBError()
59             if process.GetAddressByteSize() == 4:
60                 bytes_read = process.ReadMemory(0x8048000, 4, mem_err)
61             else:
62                 bytes_read = process.ReadMemory(0x400000, 4, mem_err)
63             self.assertEqual(bytes_read, None)
64             reason = thread.GetStopReason()
65             if( thread.GetThreadID() == tid ):
66                 self.assertEqual(reason, lldb.eStopReasonSignal)
67                 signal = thread.GetStopReasonDataAtIndex(1)
68                 # Check we got signal 4 (SIGILL)
69                 self.assertEqual(signal, 4)
70             else:
71                 signal = thread.GetStopReasonDataAtIndex(1)
72                 # Check we got no signal on the other threads
73                 self.assertEqual(signal, 0)
74
75         self.dbg.DeleteTarget(target)