diff options
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py | 4 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp | 157 |
2 files changed, 58 insertions, 103 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py index ed46ef1c847..19b779ff53f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py @@ -38,9 +38,7 @@ class LinuxCoreTestCase(TestBase): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("linux-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'])) + @skipIf(oslist=['windows']) @skipIf(triple='^mips') def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp index 86b15c0d2fb..bdf0c69bef2 100644 --- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -202,7 +202,6 @@ ELFLinuxPrStatus::ELFLinuxPrStatus() { Error ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch) { Error error; - ByteOrder byteorder = data.GetByteOrder(); if (GetSize(arch) > data.GetByteSize()) { error.SetErrorStringWithFormat( "NT_PRSTATUS size should be %zu, but the remaining bytes are: %" PRIu64, @@ -210,50 +209,36 @@ Error ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch) { return error; } - switch (arch.GetCore()) { - case ArchSpec::eCore_s390x_generic: - case ArchSpec::eCore_x86_64_x86_64: - data.ExtractBytes(0, sizeof(ELFLinuxPrStatus), byteorder, this); - break; - case ArchSpec::eCore_x86_32_i386: - case ArchSpec::eCore_x86_32_i486: { - // Parsing from a 32 bit ELF core file, and populating/reusing the structure - // properly, because the struct is for the 64 bit version - offset_t offset = 0; - si_signo = data.GetU32(&offset); - si_code = data.GetU32(&offset); - si_errno = data.GetU32(&offset); + // Read field by field to correctly account for endianess + // of both the core dump and the platform running lldb. + offset_t offset = 0; + si_signo = data.GetU32(&offset); + si_code = data.GetU32(&offset); + si_errno = data.GetU32(&offset); - pr_cursig = data.GetU16(&offset); - offset += 2; // pad + pr_cursig = data.GetU16(&offset); + offset += 2; // pad - pr_sigpend = data.GetU32(&offset); - pr_sighold = data.GetU32(&offset); + pr_sigpend = data.GetPointer(&offset); + pr_sighold = data.GetPointer(&offset); - pr_pid = data.GetU32(&offset); - pr_ppid = data.GetU32(&offset); - pr_pgrp = data.GetU32(&offset); - pr_sid = data.GetU32(&offset); + pr_pid = data.GetU32(&offset); + pr_ppid = data.GetU32(&offset); + pr_pgrp = data.GetU32(&offset); + pr_sid = data.GetU32(&offset); - pr_utime.tv_sec = data.GetU32(&offset); - pr_utime.tv_usec = data.GetU32(&offset); + pr_utime.tv_sec = data.GetPointer(&offset); + pr_utime.tv_usec = data.GetPointer(&offset); - pr_stime.tv_sec = data.GetU32(&offset); - pr_stime.tv_usec = data.GetU32(&offset); + pr_stime.tv_sec = data.GetPointer(&offset); + pr_stime.tv_usec = data.GetPointer(&offset); - pr_cutime.tv_sec = data.GetU32(&offset); - pr_cutime.tv_usec = data.GetU32(&offset); + pr_cutime.tv_sec = data.GetPointer(&offset); + pr_cutime.tv_usec = data.GetPointer(&offset); - pr_cstime.tv_sec = data.GetU32(&offset); - pr_cstime.tv_usec = data.GetU32(&offset); + pr_cstime.tv_sec = data.GetPointer(&offset); + pr_cstime.tv_usec = data.GetPointer(&offset); - break; - } - default: - error.SetErrorStringWithFormat("ELFLinuxPrStatus::%s Unknown architecture", - __FUNCTION__); - break; - } return error; } @@ -274,49 +259,37 @@ Error ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch) { GetSize(arch), data.GetByteSize()); return error; } - - switch (arch.GetCore()) { - case ArchSpec::eCore_s390x_generic: - case ArchSpec::eCore_x86_64_x86_64: - data.ExtractBytes(0, sizeof(ELFLinuxPrPsInfo), byteorder, this); - break; - case ArchSpec::eCore_x86_32_i386: - case ArchSpec::eCore_x86_32_i486: { - // Parsing from a 32 bit ELF core file, and populating/reusing the structure - // properly, because the struct is for the 64 bit version - size_t size = 0; - offset_t offset = 0; - - pr_state = data.GetU8(&offset); - pr_sname = data.GetU8(&offset); - pr_zomb = data.GetU8(&offset); - pr_nice = data.GetU8(&offset); - - pr_flag = data.GetU32(&offset); - pr_uid = data.GetU16(&offset); - pr_gid = data.GetU16(&offset); - - pr_pid = data.GetU32(&offset); - pr_ppid = data.GetU32(&offset); - pr_pgrp = data.GetU32(&offset); - pr_sid = data.GetU32(&offset); - - size = 16; - data.ExtractBytes(offset, size, byteorder, pr_fname); - offset += size; - - size = 80; - data.ExtractBytes(offset, size, byteorder, pr_psargs); - offset += size; - - break; - } - default: - error.SetErrorStringWithFormat("ELFLinuxPrPsInfo::%s Unknown architecture", - __FUNCTION__); - break; + size_t size = 0; + offset_t offset = 0; + + pr_state = data.GetU8(&offset); + pr_sname = data.GetU8(&offset); + pr_zomb = data.GetU8(&offset); + pr_nice = data.GetU8(&offset); + if (data.GetAddressByteSize() == 8) { + // Word align the next field on 64 bit. + offset += 4; } + pr_flag = data.GetPointer(&offset); + + // 16 bit on 32 bit platforms, 32 bit on 64 bit platforms + pr_uid = data.GetMaxU64(&offset, data.GetAddressByteSize() >> 1); + pr_gid = data.GetMaxU64(&offset, data.GetAddressByteSize() >> 1); + + pr_pid = data.GetU32(&offset); + pr_ppid = data.GetU32(&offset); + pr_pgrp = data.GetU32(&offset); + pr_sid = data.GetU32(&offset); + + size = 16; + data.ExtractBytes(offset, size, byteorder, pr_fname); + offset += size; + + size = 80; + data.ExtractBytes(offset, size, byteorder, pr_psargs); + offset += size; + return error; } @@ -329,7 +302,6 @@ ELFLinuxSigInfo::ELFLinuxSigInfo() { Error ELFLinuxSigInfo::Parse(DataExtractor &data, const ArchSpec &arch) { Error error; - ByteOrder byteorder = data.GetByteOrder(); if (GetSize(arch) > data.GetByteSize()) { error.SetErrorStringWithFormat( "NT_SIGINFO size should be %zu, but the remaining bytes are: %" PRIu64, @@ -337,27 +309,12 @@ Error ELFLinuxSigInfo::Parse(DataExtractor &data, const ArchSpec &arch) { return error; } - switch (arch.GetCore()) { - case ArchSpec::eCore_x86_64_x86_64: - data.ExtractBytes(0, sizeof(ELFLinuxPrStatus), byteorder, this); - break; - case ArchSpec::eCore_s390x_generic: - case ArchSpec::eCore_x86_32_i386: - case ArchSpec::eCore_x86_32_i486: { - // Parsing from a 32 bit ELF core file, and populating/reusing the structure - // properly, because the struct is for the 64 bit version - offset_t offset = 0; - si_signo = data.GetU32(&offset); - si_code = data.GetU32(&offset); - si_errno = data.GetU32(&offset); - - break; - } - default: - error.SetErrorStringWithFormat("ELFLinuxSigInfo::%s Unknown architecture", - __FUNCTION__); - break; - } + // Parsing from a 32 bit ELF core file, and populating/reusing the structure + // properly, because the struct is for the 64 bit version + offset_t offset = 0; + si_signo = data.GetU32(&offset); + si_code = data.GetU32(&offset); + si_errno = data.GetU32(&offset); return error; } |