2 Test signal reporting when debugging with linux core files.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class LinuxCoreThreadsTestCase(TestBase):
14 NO_DEBUG_INFO_TESTCASE = True
16 mydir = TestBase.compute_mydir(__file__)
19 super(LinuxCoreThreadsTestCase, self).setUp()
20 self._initial_platform = lldb.DBG.GetSelectedPlatform()
23 lldb.DBG.SetSelectedPlatform(self._initial_platform)
24 super(LinuxCoreThreadsTestCase, self).tearDown()
29 # Thread id for the failing thread.
33 @skipIf(oslist=['windows'])
34 @skipIf(triple='^mips')
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)
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)
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)
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)
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)
71 signal = thread.GetStopReasonDataAtIndex(1)
72 # Check we got no signal on the other threads
73 self.assertEqual(signal, 0)
75 self.dbg.DeleteTarget(target)