[Lldb-commits] [lldb] r355526 - Fix core files for 32 bit architectures that are supported in ProcessELFCore.cpp

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 6 10:04:10 PST 2019


Author: gclayton
Date: Wed Mar  6 10:04:10 2019
New Revision: 355526

URL: http://llvm.org/viewvc/llvm-project?rev=355526&view=rev
Log:
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


Added:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.core   (with props)
Modified:
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
    lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=355526&r1=355525&r2=355526&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py Wed Mar  6 10:04:10 2019
@@ -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)

Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.core
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.core?rev=355526&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.core
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp?rev=355526&r1=355525&r2=355526&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/elf-core/ThreadElfCore.cpp Wed Mar  6 10:04:10 2019
@@ -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 l
     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;
   }
 }
 




More information about the lldb-commits mailing list