summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2019-03-06 18:04:10 +0000
committerGreg Clayton <gclayton@apple.com>2019-03-06 18:04:10 +0000
commit6795eb388442469af74245545b445d9505fdc9d8 (patch)
tree019daf67b373f4acd9ed93cf33e927ffba206c74
parent641d0b8cee4529ed2dca697cb76de6ce4d800871 (diff)
downloadbcm5719-llvm-6795eb388442469af74245545b445d9505fdc9d8.tar.gz
bcm5719-llvm-6795eb388442469af74245545b445d9505fdc9d8.zip
Fix core files for 32 bit architectures that are supported in ProcessELFCore.cpp
Core files need to know the size of the PRSTATUS header so that we can grab the register values that follow it. The code that figure out this size was using a hard coded list of architecture cores instead of relying on 32 or 64 bit for most cores. The fix here fixes core files for 32 bit ARM. Prior to this the PRSTATUS header size was being returned as zero and the register values were being taken from the first bytes of the PRSTATUS struct (signo, etc). Differential Revision: https://reviews.llvm.org/D58985 llvm-svn: 355526
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py29
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.corebin0 -> 252 bytes
-rw-r--r--lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp10
3 files changed, 34 insertions, 5 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 e965817a820..c2746bf1a80 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
@@ -217,6 +217,35 @@ class LinuxCoreTestCase(TestBase):
self.dbg.DeleteTarget(target)
+ @skipIf(triple='^mips')
+ @skipIfLLVMTargetMissing("ARM")
+ def test_arm_core(self):
+ # check 32 bit ARM core file
+ target = self.dbg.CreateTarget(None)
+ self.assertTrue(target, VALID_TARGET)
+ process = target.LoadCore("linux-arm.core")
+
+ values = {}
+ values["r0"] = "0x00000000"
+ values["r1"] = "0x00000001"
+ values["r2"] = "0x00000002"
+ values["r3"] = "0x00000003"
+ values["r4"] = "0x00000004"
+ values["r5"] = "0x00000005"
+ values["r6"] = "0x00000006"
+ values["r7"] = "0x00000007"
+ values["r8"] = "0x00000008"
+ values["r9"] = "0x00000009"
+ values["r10"] = "0x0000000a"
+ values["r11"] = "0x0000000b"
+ values["r12"] = "0x0000000c"
+ values["sp"] = "0x0000000d"
+ values["lr"] = "0x0000000e"
+ values["pc"] = "0x0000000f"
+ values["cpsr"] = "0x00000010"
+ for regname, value in values.items():
+ self.expect("register read {}".format(regname), substrs=["{} = {}".format(regname, value)])
+
def check_memory_regions(self, process, region_count):
region_list = process.GetMemoryRegions()
self.assertEqual(region_list.GetSize(), region_count)
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.core b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.core
new file mode 100644
index 00000000000..a919a9d6ae6
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.core
Binary files differ
diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index 409163554d6..d76a8920fc3 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -255,6 +255,7 @@ ELFLinuxPrStatus::ELFLinuxPrStatus() {
size_t ELFLinuxPrStatus::GetSize(const lldb_private::ArchSpec &arch) {
constexpr size_t mips_linux_pr_status_size_o32 = 96;
constexpr size_t mips_linux_pr_status_size_n32 = 72;
+ constexpr size_t num_ptr_size_members = 10;
if (arch.IsMIPS()) {
std::string abi = arch.GetTargetABI();
assert(!abi.empty() && "ABI is not set");
@@ -266,15 +267,14 @@ size_t ELFLinuxPrStatus::GetSize(const lldb_private::ArchSpec &arch) {
return mips_linux_pr_status_size_n32;
}
switch (arch.GetCore()) {
- case lldb_private::ArchSpec::eCore_s390x_generic:
- case lldb_private::ArchSpec::eCore_x86_64_x86_64:
- case lldb_private::ArchSpec::eCore_ppc64le_generic:
- return sizeof(ELFLinuxPrStatus);
case lldb_private::ArchSpec::eCore_x86_32_i386:
case lldb_private::ArchSpec::eCore_x86_32_i486:
return 72;
default:
- return 0;
+ if (arch.GetAddressByteSize() == 8)
+ return sizeof(ELFLinuxPrStatus);
+ else
+ return sizeof(ELFLinuxPrStatus) - num_ptr_size_members * 4;
}
}
OpenPOWER on IntegriCloud