[Lldb-commits] [PATCH] D58985: Fix core files for 32 bit architectures that are supported in ProcessELFCore.cpp

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 5 10:52:03 PST 2019


clayborg created this revision.
clayborg added reviewers: labath, hhellyer, omjavaid, tberghammer.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a reviewer: serge-sans-paille.

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).


https://reviews.llvm.org/D58985

Files:
  packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
  packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/linux-arm.core
  source/Plugins/Process/elf-core/ThreadElfCore.cpp


Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp
===================================================================
--- source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -266,15 +266,14 @@
     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) - 10 * 4;
   }
 }
 
Index: packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -217,6 +217,35 @@
 
         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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58985.189359.patch
Type: text/x-patch
Size: 2489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190305/8ea8dcd7/attachment.bin>


More information about the lldb-commits mailing list