Same issue as in D8685 but for i386.
authorChaoren Lin <chaorenl@google.com>
Tue, 21 Apr 2015 23:00:58 +0000 (23:00 +0000)
committerChaoren Lin <chaorenl@google.com>
Tue, 21 Apr 2015 23:00:58 +0000 (23:00 +0000)
llvm-svn: 235454

lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
lldb/source/Plugins/Process/Utility/RegisterInfos_x86_64.h

index 185ba26..0171da6 100644 (file)
@@ -45,6 +45,13 @@ struct dbreg {
                          /* Index 7: debug control */
 };
 
+using FPR_i386 = FXSAVE;
+
+struct UserArea
+{
+    GPR gpr;
+    FPR_i386 i387;
+};
 
 #define DR_SIZE sizeof(uint32_t)
 #define DR_OFFSET(reg_index) \
index a503ef8..4f6bbc8 100644 (file)
@@ -66,7 +66,7 @@ struct UserArea
 {
     GPR      regs;          // General purpose registers.
     int32_t  fpvalid;       // True if FPU is being used.
-    FPR_i386   i387;        // FPU registers.
+    FPR_i386 i387;          // FPU registers.
     uint32_t tsize;         // Text segment size.
     uint32_t dsize;         // Data segment size.
     uint32_t ssize;         // Stack segment size.
index fc94b8b..6982536 100644 (file)
 
 // Computes the offset of the given FPR in the extended data area.
 #define FPR_OFFSET(regname)  \
-    (LLVM_EXTENSION offsetof(FPR, xstate) + \
-     LLVM_EXTENSION offsetof(FXSAVE, regname))
+    (LLVM_EXTENSION offsetof(UserArea, i387) + \
+     LLVM_EXTENSION offsetof(FPR_i386, regname))
 
 // Computes the offset of the YMM register assembled from register halves.
-#define YMM_OFFSET(regname) \
-    (LLVM_EXTENSION offsetof(YMM, regname))
+// Based on DNBArchImplI386.cpp from debugserver
+#define YMM_OFFSET(reg_index) \
+    (LLVM_EXTENSION offsetof(UserArea, i387) + \
+     LLVM_EXTENSION offsetof(FPR, xstate) + \
+     LLVM_EXTENSION offsetof(FXSAVE, xmm[7]) + \
+     sizeof(XMMReg) + (32 * reg_index))
 
 // Number of bytes needed to represent a FPR.
 #if !defined(FPR_SIZE)
@@ -70,7 +74,7 @@
 
 // I believe the YMM registers use dwarf_xmm_%_i386 register numbers and then differentiate based on register size.
 #define DEFINE_YMM(reg, i)                                         \
-    { #reg#i, NULL, YMM_SIZE, LLVM_EXTENSION YMM_OFFSET(reg[i]),   \
+    { #reg#i, NULL, YMM_SIZE, LLVM_EXTENSION YMM_OFFSET(i),        \
       eEncodingVector, eFormatVectorOfUInt8,                       \
       { LLDB_INVALID_REGNUM, dwarf_xmm##i##_i386, LLDB_INVALID_REGNUM, gdb_##reg##i##h_i386, lldb_##reg##i##_i386 }, \
       NULL, NULL }
index f7e3292..5da74ff 100644 (file)
      LLVM_EXTENSION offsetof(FXSAVE, regname))
 
 // Computes the offset of the YMM register assembled from register halves.
+// Based on DNBArchImplX86_64.cpp from debugserver
 #define YMM_OFFSET(reg_index) \
     (LLVM_EXTENSION offsetof(UserArea, fpr) + \
      LLVM_EXTENSION offsetof(FPR, xstate) + \
-     LLVM_EXTENSION offsetof(XSAVE, ymmh[reg_index]) + \
+     LLVM_EXTENSION offsetof(XSAVE, ymmh[0]) + \
      (32 * reg_index))
 
 #ifdef DECLARE_REGISTER_INFOS_X86_64_STRUCT