[Lldb-commits] [lldb] r246959 - Fix the handling of FPR offsets in Linux arm/aarch64 register contexts

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 7 03:11:24 PDT 2015


Author: tberghammer
Date: Mon Sep  7 05:11:23 2015
New Revision: 246959

URL: http://llvm.org/viewvc/llvm-project?rev=246959&view=rev
Log:
Fix the handling of FPR offsets in Linux arm/aarch64 register contexts

Differential revision: http://reviews.llvm.org/D12636

Modified:
    lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
    lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
    lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
    lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
    lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp?rev=246959&r1=246958&r2=246959&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp Mon Sep  7 05:11:23 2015
@@ -229,8 +229,9 @@ NativeRegisterContextLinux_arm::ReadRegi
     }
 
     // Get pointer to m_fpr variable and set the data from it.
-    assert (reg_info->byte_offset < sizeof m_fpr);
-    uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;
+    uint32_t fpr_offset = CalculateFprOffset(reg_info);
+    assert (fpr_offset < sizeof m_fpr);
+    uint8_t *src = (uint8_t *)&m_fpr + fpr_offset;
     switch (reg_info->byte_size)
     {
         case 2:
@@ -267,8 +268,9 @@ NativeRegisterContextLinux_arm::WriteReg
     if (IsFPR(reg_index))
     {
         // Get pointer to m_fpr variable and set the data to it.
-        assert (reg_info->byte_offset < sizeof(m_fpr));
-        uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;
+        uint32_t fpr_offset = CalculateFprOffset(reg_info);
+        assert (fpr_offset < sizeof m_fpr);
+        uint8_t *dst = (uint8_t *)&m_fpr + fpr_offset;
         switch (reg_info->byte_size)
         {
             case 2:
@@ -844,4 +846,11 @@ NativeRegisterContextLinux_arm::WriteHar
 
     return error;
 }
+
+uint32_t
+NativeRegisterContextLinux_arm::CalculateFprOffset(const RegisterInfo* reg_info) const
+{
+    return reg_info->byte_offset - GetRegisterInfoAtIndex(m_reg_info.first_fpr)->byte_offset;
+}
+
 #endif // defined(__arm__)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h?rev=246959&r1=246958&r2=246959&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h Mon Sep  7 05:11:23 2015
@@ -161,6 +161,9 @@ namespace process_linux {
 
         Error
         WriteHardwareDebugRegs(int hwbType, int hwb_index);
+
+        uint32_t
+        CalculateFprOffset(const RegisterInfo* reg_info) const;
     };
 
 } // namespace process_linux

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp?rev=246959&r1=246958&r2=246959&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp Mon Sep  7 05:11:23 2015
@@ -249,8 +249,9 @@ NativeRegisterContextLinux_arm64::ReadRe
     }
 
     // Get pointer to m_fpr variable and set the data from it.
-    assert (reg_info->byte_offset < sizeof m_fpr);
-    uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;
+    uint32_t fpr_offset = CalculateFprOffset(reg_info);
+    assert (fpr_offset < sizeof m_fpr);
+    uint8_t *src = (uint8_t *)&m_fpr + fpr_offset;
     reg_value.SetFromMemoryData(reg_info, src, reg_info->byte_size, eByteOrderLittle, error);
 
     return error;
@@ -272,8 +273,9 @@ NativeRegisterContextLinux_arm64::WriteR
     if (IsFPR(reg_index))
     {
         // Get pointer to m_fpr variable and set the data to it.
-        assert (reg_info->byte_offset < sizeof(m_fpr));
-        uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;
+        uint32_t fpr_offset = CalculateFprOffset(reg_info);
+        assert (fpr_offset < sizeof m_fpr);
+        uint8_t *dst = (uint8_t *)&m_fpr + fpr_offset;
         switch (reg_info->byte_size)
         {
             case 2:
@@ -980,4 +982,10 @@ NativeRegisterContextLinux_arm64::DoWrit
     return NativeProcessLinux::PtraceWrapper(PTRACE_SETREGSET, m_thread.GetID(), &regset, &ioVec, buf_size);
 }
 
+uint32_t
+NativeRegisterContextLinux_arm64::CalculateFprOffset(const RegisterInfo* reg_info) const
+{
+    return reg_info->byte_offset - GetRegisterInfoAtIndex(m_reg_info.first_fpr)->byte_offset;
+}
+
 #endif // defined (__arm64__) || defined (__aarch64__)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h?rev=246959&r1=246958&r2=246959&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h Mon Sep  7 05:11:23 2015
@@ -183,6 +183,9 @@ namespace process_linux {
 
         Error
         WriteHardwareDebugRegs(int hwbType);
+
+        uint32_t
+        CalculateFprOffset(const RegisterInfo* reg_info) const;
     };
 
 } // namespace process_linux

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp?rev=246959&r1=246958&r2=246959&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_arm64.cpp Mon Sep  7 05:11:23 2015
@@ -21,7 +21,7 @@
 #define GPR_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::GPR, reg))
 
 #define FPU_OFFSET(idx) ((idx) * 16 + sizeof (RegisterContextLinux_arm64::GPR))
-#define FPU_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::FPU, reg))
+#define FPU_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::FPU, reg) + sizeof (RegisterContextLinux_arm64::GPR))
 
 #define EXC_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::EXC, reg) + sizeof (RegisterContextLinux_arm64::GPR) + sizeof (RegisterContextLinux_arm64::FPU))
 #define DBG_OFFSET_NAME(reg) (LLVM_EXTENSION offsetof (RegisterContextLinux_arm64::DBG, reg) + sizeof (RegisterContextLinux_arm64::GPR) + sizeof (RegisterContextLinux_arm64::FPU) + sizeof (RegisterContextLinux_arm64::EXC))




More information about the lldb-commits mailing list