""" Test basics of linux core file debugging. """ from __future__ import print_function import shutil import struct import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil class LinuxCoreTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) _i386_pid = 32306 _x86_64_pid = 32259 _s390x_pid = 1045 _i386_regions = 4 _x86_64_regions = 5 _s390x_regions = 2 @skipIf(bugnumber="llvm.org/pr26947") def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" self.do_test("i386", self._i386_pid, self._i386_regions) def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("x86_64", self._x86_64_pid, self._x86_64_regions) # This seems to hang on non-s390x platforms for some reason. Disabling for now. @skipIf(archs=no_match(['s390x'])) def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" self.do_test("s390x", self._s390x_pid, self._s390x_regions) def test_same_pid_running(self): """Test that we read the information from the core correctly even if we have a running process with the same PID around""" try: shutil.copyfile("x86_64.out", "x86_64-pid.out") shutil.copyfile("x86_64.core", "x86_64-pid.core") with open("x86_64-pid.core", "r+b") as f: # These are offsets into the NT_PRSTATUS and NT_PRPSINFO structures in the note # segment of the core file. If you update the file, these offsets may need updating # as well. (Notes can be viewed with readelf --notes.) for pid_offset in [0x1c4, 0x320]: f.seek(pid_offset) self.assertEqual(struct.unpack("