[Lldb-commits] [lldb] a890237 - [lldb] [Process/NetBSD] Set xs_xstate_bv correctly when setting regs

Michał Górny via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 26 03:56:19 PDT 2020


Author: Michał Górny
Date: 2020-10-26T11:54:40+01:00
New Revision: a8902376651a7adbacd0c1934d9f70bdb9fad7f0

URL: https://github.com/llvm/llvm-project/commit/a8902376651a7adbacd0c1934d9f70bdb9fad7f0
DIFF: https://github.com/llvm/llvm-project/commit/a8902376651a7adbacd0c1934d9f70bdb9fad7f0.diff

LOG: [lldb] [Process/NetBSD] Set xs_xstate_bv correctly when setting regs

Ensure that xs_xstate_bv is set correctly before calling
WriteRegisterSet().  The bit can be clear if the relevant registers
were at their initial state when they were read, and it needs to be set
in order to apply changes from the XState structure.

Differential Revision: https://reviews.llvm.org/D90105

Added: 
    

Modified: 
    lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
index fb8d64ffe997..2e2eacdfccef 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -754,6 +754,8 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
     return error;
   }
 
+  uint64_t new_xstate_bv = XCR0_X87;  // the most common case
+
   switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
   case llvm::Triple::x86_64:
     break;
@@ -918,9 +920,11 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
     break;
   case lldb_mxcsr_x86_64:
     m_xstate.xs_fxsave.fx_mxcsr = reg_value.GetAsUInt32();
+    new_xstate_bv = XCR0_SSE;
     break;
   case lldb_mxcsrmask_x86_64:
     m_xstate.xs_fxsave.fx_mxcsr_mask = reg_value.GetAsUInt32();
+    new_xstate_bv = XCR0_SSE;
     break;
   case lldb_st0_x86_64:
   case lldb_st1_x86_64:
@@ -966,6 +970,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
     } else {
       ::memcpy(&m_xstate.xs_fxsave.fx_xmm[reg - lldb_xmm0_x86_64],
                reg_value.GetBytes(), reg_value.GetByteSize());
+      new_xstate_bv = XCR0_SSE;
     }
     break;
   case lldb_ymm0_x86_64:
@@ -994,6 +999,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
       ::memcpy(ymm.bytes, reg_value.GetBytes(), reg_value.GetByteSize());
       YMMToXState(ymm, m_xstate.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
                   m_xstate.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
+      new_xstate_bv = XCR0_SSE | XCR0_YMM_Hi128;
     }
     break;
   case lldb_dr0_x86_64:
@@ -1010,6 +1016,9 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
     llvm_unreachable("Reading unknown/unsupported register");
   }
 
+  if (set == XStateRegSet)
+    m_xstate.xs_xstate_bv |= new_xstate_bv;
+
   return WriteRegisterSet(set);
 }
 


        


More information about the lldb-commits mailing list