x86_64-windows GDB crash due to fs_base/gs_base registers
[deliverable/binutils-gdb.git] / gdb / amd64-tdep.c
index 0eac35e536bdf28036f1e860c0252c7b7b092e68..190e086ebfe3abcfd4346db4214d7b8d65607571 100644 (file)
@@ -426,8 +426,7 @@ amd64_pseudo_register_write (struct gdbarch *gdbarch,
          /* ... Modify ... (always little endian).  */
          memcpy (raw_buf + 1, buf, 1);
          /* ... Write.  */
-         regcache_raw_write (regcache,
-                             gpnum - AMD64_NUM_LOWER_BYTE_REGS, raw_buf);
+         regcache->raw_write (gpnum - AMD64_NUM_LOWER_BYTE_REGS, raw_buf);
        }
       else
        {
@@ -436,7 +435,7 @@ amd64_pseudo_register_write (struct gdbarch *gdbarch,
          /* ... Modify ... (always little endian).  */
          memcpy (raw_buf, buf, 1);
          /* ... Write.  */
-         regcache_raw_write (regcache, gpnum, raw_buf);
+         regcache->raw_write (gpnum, raw_buf);
        }
     }
   else if (i386_dword_regnum_p (gdbarch, regnum))
@@ -448,7 +447,7 @@ amd64_pseudo_register_write (struct gdbarch *gdbarch,
       /* ... Modify ... (always little endian).  */
       memcpy (raw_buf, buf, 4);
       /* ... Write.  */
-      regcache_raw_write (regcache, gpnum, raw_buf);
+      regcache->raw_write (gpnum, raw_buf);
     }
   else
     i386_pseudo_register_write (gdbarch, regcache, regnum, buf);
@@ -777,8 +776,8 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
       if (writebuf)
        {
          i387_return_value (gdbarch, regcache);
-         regcache_raw_write (regcache, AMD64_ST0_REGNUM, writebuf);
-         regcache_raw_write (regcache, AMD64_ST1_REGNUM, writebuf + 16);
+         regcache->raw_write (AMD64_ST0_REGNUM, writebuf);
+         regcache->raw_write (AMD64_ST1_REGNUM, writebuf + 16);
 
          /* Fix up the tag word such that both %st(0) and %st(1) are
             marked as valid.  */
@@ -845,11 +844,11 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
       gdb_assert (regnum != -1);
 
       if (readbuf)
-       regcache_raw_read_part (regcache, regnum, offset, std::min (len, 8),
-                               readbuf + i * 8);
+       regcache->raw_read_part (regnum, offset, std::min (len, 8),
+                                readbuf + i * 8);
       if (writebuf)
-       regcache_raw_write_part (regcache, regnum, offset, std::min (len, 8),
-                                writebuf + i * 8);
+       regcache->raw_write_part (regnum, offset, std::min (len, 8),
+                                 writebuf + i * 8);
     }
 
   return RETURN_VALUE_REGISTER_CONVENTION;
@@ -957,7 +956,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
              gdb_assert (regnum != -1);
              memset (buf, 0, sizeof buf);
              memcpy (buf, valbuf + j * 8, std::min (len, 8));
-             regcache_raw_write_part (regcache, regnum, offset, 8, buf);
+             regcache->raw_write_part (regnum, offset, 8, buf);
            }
        }
     }
@@ -1011,7 +1010,7 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   if (struct_return)
     {
       store_unsigned_integer (buf, 8, byte_order, struct_addr);
-      regcache_cooked_write (regcache, AMD64_RDI_REGNUM, buf);
+      regcache->cooked_write (AMD64_RDI_REGNUM, buf);
     }
 
   /* Store return address.  */
@@ -1021,10 +1020,10 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   /* Finally, update the stack pointer...  */
   store_unsigned_integer (buf, 8, byte_order, sp);
-  regcache_cooked_write (regcache, AMD64_RSP_REGNUM, buf);
+  regcache->cooked_write (AMD64_RSP_REGNUM, buf);
 
   /* ...and fake a frame pointer.  */
-  regcache_cooked_write (regcache, AMD64_RBP_REGNUM, buf);
+  regcache->cooked_write (AMD64_RBP_REGNUM, buf);
 
   return sp + 16;
 }
@@ -3226,7 +3225,8 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
 static void
 amd64_none_init_abi (gdbarch_info info, gdbarch *arch)
 {
-  amd64_init_abi (info, arch, amd64_target_description (X86_XSTATE_SSE_MASK));
+  amd64_init_abi (info, arch, amd64_target_description (X86_XSTATE_SSE_MASK,
+                                                       true));
 }
 
 static struct type *
@@ -3267,25 +3267,27 @@ static void
 amd64_x32_none_init_abi (gdbarch_info info, gdbarch *arch)
 {
   amd64_x32_init_abi (info, arch,
-                     amd64_target_description (X86_XSTATE_SSE_MASK));
+                     amd64_target_description (X86_XSTATE_SSE_MASK, true));
 }
 
 /* Return the target description for a specified XSAVE feature mask.  */
 
 const struct target_desc *
-amd64_target_description (uint64_t xcr0)
+amd64_target_description (uint64_t xcr0, bool segments)
 {
   static target_desc *amd64_tdescs \
-    [2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/] = {};
+    [2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
   target_desc **tdesc;
 
   tdesc = &amd64_tdescs[(xcr0 & X86_XSTATE_AVX) ? 1 : 0]
     [(xcr0 & X86_XSTATE_MPX) ? 1 : 0]
     [(xcr0 & X86_XSTATE_AVX512) ? 1 : 0]
-    [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0];
+    [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]
+    [segments ? 1 : 0];
 
   if (*tdesc == NULL)
-    *tdesc = amd64_create_target_description (xcr0, false, false);
+    *tdesc = amd64_create_target_description (xcr0, false, false,
+                                             segments);
 
   return *tdesc;
 }
@@ -3315,7 +3317,7 @@ _initialize_amd64_tdep (void)
 
   for (auto &a : xml_masks)
     {
-      auto tdesc = amd64_target_description (a.mask);
+      auto tdesc = amd64_target_description (a.mask, true);
 
       selftests::record_xml_tdesc (a.xml, tdesc);
     }
@@ -3350,9 +3352,9 @@ amd64_supply_fxsave (struct regcache *regcache, int regnum,
       const gdb_byte *regs = (const gdb_byte *) fxsave;
 
       if (regnum == -1 || regnum == I387_FISEG_REGNUM (tdep))
-       regcache_raw_supply (regcache, I387_FISEG_REGNUM (tdep), regs + 12);
+       regcache->raw_supply (I387_FISEG_REGNUM (tdep), regs + 12);
       if (regnum == -1 || regnum == I387_FOSEG_REGNUM (tdep))
-       regcache_raw_supply (regcache, I387_FOSEG_REGNUM (tdep), regs + 20);
+       regcache->raw_supply (I387_FOSEG_REGNUM (tdep), regs + 20);
     }
 }
 
@@ -3382,11 +3384,9 @@ amd64_supply_xsave (struct regcache *regcache, int regnum,
       if (!(clear_bv & X86_XSTATE_X87))
        {
          if (regnum == -1 || regnum == I387_FISEG_REGNUM (tdep))
-           regcache_raw_supply (regcache, I387_FISEG_REGNUM (tdep),
-                                regs + 12);
+           regcache->raw_supply (I387_FISEG_REGNUM (tdep), regs + 12);
          if (regnum == -1 || regnum == I387_FOSEG_REGNUM (tdep))
-           regcache_raw_supply (regcache, I387_FOSEG_REGNUM (tdep),
-                                regs + 20);
+           regcache->raw_supply (I387_FOSEG_REGNUM (tdep), regs + 20);
        }
     }
 }
@@ -3409,9 +3409,9 @@ amd64_collect_fxsave (const struct regcache *regcache, int regnum,
   if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 64)
     {
       if (regnum == -1 || regnum == I387_FISEG_REGNUM (tdep))
-       regcache_raw_collect (regcache, I387_FISEG_REGNUM (tdep), regs + 12);
+       regcache->raw_collect (I387_FISEG_REGNUM (tdep), regs + 12);
       if (regnum == -1 || regnum == I387_FOSEG_REGNUM (tdep))
-       regcache_raw_collect (regcache, I387_FOSEG_REGNUM (tdep), regs + 20);
+       regcache->raw_collect (I387_FOSEG_REGNUM (tdep), regs + 20);
     }
 }
 
@@ -3430,10 +3430,10 @@ amd64_collect_xsave (const struct regcache *regcache, int regnum,
   if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 64)
     {
       if (regnum == -1 || regnum == I387_FISEG_REGNUM (tdep))
-       regcache_raw_collect (regcache, I387_FISEG_REGNUM (tdep),
+       regcache->raw_collect (I387_FISEG_REGNUM (tdep),
                              regs + 12);
       if (regnum == -1 || regnum == I387_FOSEG_REGNUM (tdep))
-       regcache_raw_collect (regcache, I387_FOSEG_REGNUM (tdep),
+       regcache->raw_collect (I387_FOSEG_REGNUM (tdep),
                              regs + 20);
     }
 }
This page took 0.026793 seconds and 4 git commands to generate.