llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Igor Kudrin (igorkudrin)

<details>
<summary>Changes</summary>

This patch loads values of the VFP registers from the NT_ARM_VFP note. Note 
that a CORE/NT_FPREGSET note is typically present in core dump files and used 
to store the FPA registers. The FPA unit is rare and obsolete; however, Linux 
creates the note even if the unit is absent.

---
Full diff: https://github.com/llvm/llvm-project/pull/155956.diff


6 Files Affected:

- (modified) 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp (+21) 
- (modified) 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h (+1) 
- (modified) lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp (+1-1) 
- (modified) lldb/source/Plugins/Process/elf-core/RegisterUtilities.h (+4) 
- (modified) lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
(+21) 
- (modified) lldb/test/API/functionalities/postmortem/elf-core/linux-arm.core 
() 


``````````diff
diff --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
index 3a62081827c6a..acfa1103d62f0 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
@@ -23,6 +23,10 @@ RegisterContextCorePOSIX_arm::RegisterContextCorePOSIX_arm(
                                                   gpregset.GetByteSize());
   m_gpr.SetData(m_gpr_buffer);
   m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  const llvm::Triple &target_triple =
+      m_register_info_up->GetTargetArchitecture().GetTriple();
+  m_fpr = getRegset(notes, target_triple, ARM_VFP_Desc);
 }
 
 RegisterContextCorePOSIX_arm::~RegisterContextCorePOSIX_arm() = default;
@@ -51,6 +55,23 @@ bool RegisterContextCorePOSIX_arm::ReadRegister(const 
RegisterInfo *reg_info,
       return true;
     }
   }
+
+  const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+  if (reg == LLDB_INVALID_REGNUM)
+    return false;
+
+  if (IsFPR(reg)) {
+    assert(offset >= GetGPRSize());
+    offset -= GetGPRSize();
+    if (m_fpr.ValidOffsetForDataOfSize(offset, reg_info->byte_size)) {
+      Status error;
+      value.SetFromMemoryData(*reg_info, m_fpr.GetDataStart() + offset,
+                              reg_info->byte_size, lldb::eByteOrderLittle,
+                              error);
+      return error.Success();
+    }
+  }
+
   return false;
 }
 
diff --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
index 8d773a046bcac..e466ee242181b 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
@@ -48,6 +48,7 @@ class RegisterContextCorePOSIX_arm : public 
RegisterContextPOSIX_arm {
 private:
   lldb::DataBufferSP m_gpr_buffer;
   lldb_private::DataExtractor m_gpr;
+  lldb_private::DataExtractor m_fpr;
 };
 
 #endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_ARM_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp
index 7455d78774ee6..0100c2fdbd34b 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp
@@ -16,7 +16,7 @@ static std::optional<uint32_t>
 getNoteType(const llvm::Triple &Triple,
             llvm::ArrayRef<RegsetDesc> RegsetDescs) {
   for (const auto &Entry : RegsetDescs) {
-    if (Entry.OS != Triple.getOS())
+    if (Entry.OS != llvm::Triple::UnknownOS && Entry.OS != Triple.getOS())
       continue;
     if (Entry.Arch != llvm::Triple::UnknownArch &&
         Entry.Arch != Triple.getArch())
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h 
b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
index 59382a12cde0a..645ec363768e9 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -152,6 +152,10 @@ constexpr RegsetDesc AARCH64_GCS_Desc[] = {
     {llvm::Triple::Linux, llvm::Triple::aarch64, llvm::ELF::NT_ARM_GCS},
 };
 
+constexpr RegsetDesc ARM_VFP_Desc[] = {
+    {llvm::Triple::UnknownOS, llvm::Triple::arm, llvm::ELF::NT_ARM_VFP},
+};
+
 constexpr RegsetDesc PPC_VMX_Desc[] = {
     {llvm::Triple::FreeBSD, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX},
     {llvm::Triple::Linux, llvm::Triple::UnknownArch, llvm::ELF::NT_PPC_VMX},
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py 
b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index a68175dc4e4d7..d8b389fab0170 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -688,6 +688,27 @@ def test_arm_core(self):
         values["lr"] = "0x0000000e"
         values["pc"] = "0x0000000f"
         values["cpsr"] = "0x00000010"
+        for i in range(32):
+            values["s" + str(i)] = str(i)
+        values["fpscr"] = "0x12345678"
+        values["d0"] = "0.0078125"
+        values["d1"] = "32.000007629394531"
+        values["d2"] = "2048.0004920959473"
+        values["d3"] = "32768.007904052734"
+        values["d4"] = "262144.0634765625"
+        values["d5"] = "1048576.2543945313"
+        values["d6"] = "4194305.01953125"
+        values["d7"] = "16777220.0859375"
+        values["d8"] = "50331656.1875"
+        values["d9"] = "100663312.390625"
+        values["d10"] = "201326624.8125"
+        values["d11"] = "402653249.6875"
+        values["d12"] = "805306499.5"
+        values["d13"] = "1610612999.25"
+        values["d14"] = "3221225999"
+        values["d15"] = "6442451999"
+        for i in range(16, 32):
+            values["d" + str(i)] = str(i)
         for regname, value in values.items():
             self.expect(
                 "register read {}".format(regname),
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/linux-arm.core 
b/lldb/test/API/functionalities/postmortem/elf-core/linux-arm.core
index a919a9d6ae666..be501a56c1c8c 100644
Binary files a/lldb/test/API/functionalities/postmortem/elf-core/linux-arm.core 
and b/lldb/test/API/functionalities/postmortem/elf-core/linux-arm.core differ

``````````

</details>


https://github.com/llvm/llvm-project/pull/155956
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to