Split size in regset section iterators
[deliverable/binutils-gdb.git] / gdb / i386-tdep.c
index 60dc8013a23b503190c86d5bed26bf19fad12473..a6994aaf1266ba4e47c06f694dad2d320c3c758f 100644 (file)
@@ -47,6 +47,7 @@
 #include "i386-tdep.h"
 #include "i387-tdep.h"
 #include "x86-xstate.h"
+#include "x86-tdep.h"
 
 #include "record.h"
 #include "record-full.h"
@@ -2754,10 +2755,10 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 
   /* Finally, update the stack pointer...  */
   store_unsigned_integer (buf, 4, byte_order, sp);
-  regcache_cooked_write (regcache, I386_ESP_REGNUM, buf);
+  regcache->cooked_write (I386_ESP_REGNUM, buf);
 
   /* ...and fake a frame pointer.  */
-  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
+  regcache->cooked_write (I386_EBP_REGNUM, buf);
 
   /* MarkK wrote: This "+ 8" is all over the place:
      (i386_frame_this_id, i386_sigtramp_frame_this_id,
@@ -2801,7 +2802,7 @@ i386_extract_return_value (struct gdbarch *gdbarch, struct type *type,
         its contents to the desired type.  This is probably not
         exactly how it would happen on the target itself, but it is
         the best we can do.  */
-      regcache_raw_read (regcache, I386_ST0_REGNUM, buf);
+      regcache->raw_read (I386_ST0_REGNUM, buf);
       target_float_convert (buf, i387_ext_type (gdbarch), valbuf, type);
     }
   else
@@ -2811,14 +2812,14 @@ i386_extract_return_value (struct gdbarch *gdbarch, struct type *type,
 
       if (len <= low_size)
        {
-         regcache_raw_read (regcache, LOW_RETURN_REGNUM, buf);
+         regcache->raw_read (LOW_RETURN_REGNUM, buf);
          memcpy (valbuf, buf, len);
        }
       else if (len <= (low_size + high_size))
        {
-         regcache_raw_read (regcache, LOW_RETURN_REGNUM, buf);
+         regcache->raw_read (LOW_RETURN_REGNUM, buf);
          memcpy (valbuf, buf, low_size);
-         regcache_raw_read (regcache, HIGH_RETURN_REGNUM, buf);
+         regcache->raw_read (HIGH_RETURN_REGNUM, buf);
          memcpy (valbuf + low_size, buf, len - low_size);
        }
       else
@@ -2858,7 +2859,7 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
         not exactly how it would happen on the target itself, but
         it is the best we can do.  */
       target_float_convert (valbuf, type, buf, i387_ext_type (gdbarch));
-      regcache_raw_write (regcache, I386_ST0_REGNUM, buf);
+      regcache->raw_write (I386_ST0_REGNUM, buf);
 
       /* Set the top of the floating-point register stack to 7.  The
          actual value doesn't really matter, but 7 is what a normal
@@ -2879,12 +2880,12 @@ i386_store_return_value (struct gdbarch *gdbarch, struct type *type,
       int high_size = register_size (gdbarch, HIGH_RETURN_REGNUM);
 
       if (len <= low_size)
-       regcache_raw_write_part (regcache, LOW_RETURN_REGNUM, 0, len, valbuf);
+       regcache->raw_write_part (LOW_RETURN_REGNUM, 0, len, valbuf);
       else if (len <= (low_size + high_size))
        {
-         regcache_raw_write (regcache, LOW_RETURN_REGNUM, valbuf);
-         regcache_raw_write_part (regcache, HIGH_RETURN_REGNUM, 0,
-                                  len - low_size, valbuf + low_size);
+         regcache->raw_write (LOW_RETURN_REGNUM, valbuf);
+         regcache->raw_write_part (HIGH_RETURN_REGNUM, 0, len - low_size,
+                                   valbuf + low_size);
        }
       else
        internal_error (__FILE__, __LINE__,
@@ -3473,11 +3474,11 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
       int fpnum = i386_mmx_regnum_to_fp_regnum (regcache, regnum);
 
       /* Read ...  */
-      regcache_raw_read (regcache, fpnum, raw_buf);
+      regcache->raw_read (fpnum, raw_buf);
       /* ... Modify ... (always little endian).  */
       memcpy (raw_buf, buf, register_size (gdbarch, regnum));
       /* ... Write.  */
-      regcache_raw_write (regcache, fpnum, raw_buf);
+      regcache->raw_write (fpnum, raw_buf);
     }
   else
     {
@@ -3495,9 +3496,8 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
          upper = extract_unsigned_integer (buf + size, size, byte_order);
 
          /* Fetching register buffer.  */
-         regcache_raw_read (regcache,
-                            I387_BND0R_REGNUM (tdep) + regnum,
-                            raw_buf);
+         regcache->raw_read (I387_BND0R_REGNUM (tdep) + regnum,
+                             raw_buf);
 
          upper = ~upper;
 
@@ -3505,18 +3505,13 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
          memcpy (raw_buf, &lower, 8);
          memcpy (raw_buf + 8, &upper, 8);
 
-
-         regcache_raw_write (regcache,
-                             I387_BND0R_REGNUM (tdep) + regnum,
-                             raw_buf);
+         regcache->raw_write (I387_BND0R_REGNUM (tdep) + regnum, raw_buf);
        }
       else if (i386_k_regnum_p (gdbarch, regnum))
        {
          regnum -= tdep->k0_regnum;
 
-         regcache_raw_write (regcache,
-                             tdep->k0_regnum + regnum,
-                             buf);
+         regcache->raw_write (tdep->k0_regnum + regnum, buf);
        }
       else if (i386_zmm_regnum_p (gdbarch, regnum))
        {
@@ -3525,82 +3520,64 @@ i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
          if (regnum < num_lower_zmm_regs)
            {
              /* Write lower 128bits.  */
-             regcache_raw_write (regcache,
-                                 I387_XMM0_REGNUM (tdep) + regnum,
-                                 buf);
+             regcache->raw_write (I387_XMM0_REGNUM (tdep) + regnum, buf);
              /* Write upper 128bits.  */
-             regcache_raw_write (regcache,
-                                 I387_YMM0_REGNUM (tdep) + regnum,
-                                 buf + 16);
+             regcache->raw_write (I387_YMM0_REGNUM (tdep) + regnum, buf + 16);
            }
          else
            {
              /* Write lower 128bits.  */
-             regcache_raw_write (regcache,
-                                 I387_XMM16_REGNUM (tdep) + regnum
-                                 - num_lower_zmm_regs,
-                                 buf);
+             regcache->raw_write (I387_XMM16_REGNUM (tdep) + regnum
+                                  - num_lower_zmm_regs, buf);
              /* Write upper 128bits.  */
-             regcache_raw_write (regcache,
-                                 I387_YMM16H_REGNUM (tdep) + regnum
-                                 - num_lower_zmm_regs,
-                                 buf + 16);
+             regcache->raw_write (I387_YMM16H_REGNUM (tdep) + regnum
+                                  - num_lower_zmm_regs, buf + 16);
            }
          /* Write upper 256bits.  */
-         regcache_raw_write (regcache,
-                             tdep->zmm0h_regnum + regnum,
-                             buf + 32);
+         regcache->raw_write (tdep->zmm0h_regnum + regnum, buf + 32);
        }
       else if (i386_ymm_regnum_p (gdbarch, regnum))
        {
          regnum -= tdep->ymm0_regnum;
 
          /* ... Write lower 128bits.  */
-         regcache_raw_write (regcache,
-                            I387_XMM0_REGNUM (tdep) + regnum,
-                            buf);
+         regcache->raw_write (I387_XMM0_REGNUM (tdep) + regnum, buf);
          /* ... Write upper 128bits.  */
-         regcache_raw_write (regcache,
-                            tdep->ymm0h_regnum + regnum,
-                            buf + 16);
+         regcache->raw_write (tdep->ymm0h_regnum + regnum, buf + 16);
        }
       else if (i386_ymm_avx512_regnum_p (gdbarch, regnum))
        {
          regnum -= tdep->ymm16_regnum;
 
          /* ... Write lower 128bits.  */
-         regcache_raw_write (regcache,
-                             I387_XMM16_REGNUM (tdep) + regnum,
-                             buf);
+         regcache->raw_write (I387_XMM16_REGNUM (tdep) + regnum, buf);
          /* ... Write upper 128bits.  */
-         regcache_raw_write (regcache,
-                             tdep->ymm16h_regnum + regnum,
-                             buf + 16);
+         regcache->raw_write (tdep->ymm16h_regnum + regnum, buf + 16);
        }
       else if (i386_word_regnum_p (gdbarch, regnum))
        {
          int gpnum = regnum - tdep->ax_regnum;
 
          /* Read ...  */
-         regcache_raw_read (regcache, gpnum, raw_buf);
+         regcache->raw_read (gpnum, raw_buf);
          /* ... Modify ... (always little endian).  */
          memcpy (raw_buf, buf, 2);
          /* ... Write.  */
-         regcache_raw_write (regcache, gpnum, raw_buf);
+         regcache->raw_write (gpnum, raw_buf);
        }
       else if (i386_byte_regnum_p (gdbarch, regnum))
        {
          int gpnum = regnum - tdep->al_regnum;
 
          /* Read ...  We read both lower and upper registers.  */
-         regcache_raw_read (regcache, gpnum % 4, raw_buf);
+         regcache->raw_read (gpnum % 4, raw_buf);
          /* ... Modify ... (always little endian).  */
          if (gpnum >= 4)
            memcpy (raw_buf + 1, buf, 1);
          else
            memcpy (raw_buf, buf, 1);
          /* ... Write.  */
-         regcache_raw_write (regcache, gpnum % 4, raw_buf);
+         regcache->raw_write (gpnum % 4, raw_buf);
        }
       else
        internal_error (__FILE__, __LINE__, _("invalid regnum"));
@@ -3838,7 +3815,7 @@ i386_supply_gregset (const struct regset *regset, struct regcache *regcache,
     {
       if ((regnum == i || regnum == -1)
          && tdep->gregset_reg_offset[i] != -1)
-       regcache_raw_supply (regcache, i, regs + tdep->gregset_reg_offset[i]);
+       regcache->raw_supply (i, regs + tdep->gregset_reg_offset[i]);
     }
 }
 
@@ -3863,7 +3840,7 @@ i386_collect_gregset (const struct regset *regset,
     {
       if ((regnum == i || regnum == -1)
          && tdep->gregset_reg_offset[i] != -1)
-       regcache_raw_collect (regcache, i, regs + tdep->gregset_reg_offset[i]);
+       regcache->raw_collect (i, regs + tdep->gregset_reg_offset[i]);
     }
 }
 
@@ -3933,9 +3910,11 @@ i386_iterate_over_regset_sections (struct gdbarch *gdbarch,
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-  cb (".reg", tdep->sizeof_gregset, &i386_gregset, NULL, cb_data);
+  cb (".reg", tdep->sizeof_gregset, tdep->sizeof_gregset, &i386_gregset, NULL,
+      cb_data);
   if (tdep->sizeof_fpregset)
-    cb (".reg2", tdep->sizeof_fpregset, tdep->fpregset, NULL, cb_data);
+    cb (".reg2", tdep->sizeof_fpregset, tdep->sizeof_fpregset, tdep->fpregset,
+       NULL, cb_data);
 }
 \f
 
@@ -4421,6 +4400,15 @@ i386_gnu_triplet_regexp (struct gdbarch *gdbarch)
 
 \f
 
+/* Implement the "in_indirect_branch_thunk" gdbarch function.  */
+
+static bool
+i386_in_indirect_branch_thunk (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+  return x86_in_indirect_branch_thunk (pc, i386_register_names,
+                                      I386_EAX_REGNUM, I386_EIP_REGNUM);
+}
+
 /* Generic ELF.  */
 
 void
@@ -4447,6 +4435,9 @@ i386_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
                                      i386_stap_is_single_operand);
   set_gdbarch_stap_parse_special_token (gdbarch,
                                        i386_stap_parse_special_token);
+
+  set_gdbarch_in_indirect_branch_thunk (gdbarch,
+                                       i386_in_indirect_branch_thunk);
 }
 
 /* System V Release 4 (SVR4).  */
@@ -7117,6 +7108,7 @@ Do you want to stop the program?"),
              else if (ir.rm == 1)
                break;
            }
+         /* Fall through.  */
        case 3:  /* lidt */
          if (ir.mod == 3)
            {
@@ -8333,6 +8325,31 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep,
   return valid_p;
 }
 
+\f
+
+/* Implement the type_align gdbarch function.  */
+
+static ULONGEST
+i386_type_align (struct gdbarch *gdbarch, struct type *type)
+{
+  type = check_typedef (type);
+
+  if (gdbarch_ptr_bit (gdbarch) == 32)
+    {
+      if ((TYPE_CODE (type) == TYPE_CODE_INT
+          || TYPE_CODE (type) == TYPE_CODE_FLT)
+         && TYPE_LENGTH (type) > 4)
+       return 4;
+
+      /* Handle x86's funny long double.  */
+      if (TYPE_CODE (type) == TYPE_CODE_FLT
+         && gdbarch_long_double_bit (gdbarch) == TYPE_LENGTH (type) * 8)
+       return 4;
+    }
+
+  return TYPE_LENGTH (type);
+}
+
 \f
 /* Note: This is called for both i386 and amd64.  */
 
@@ -8391,7 +8408,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   tdep->record_regmap = i386_record_regmap;
 
-  set_gdbarch_long_long_align_bit (gdbarch, 32);
+  set_gdbarch_type_align (gdbarch, i386_type_align);
 
   /* The format used for `long double' on almost all i386 targets is
      the i387 extended floating-point format.  In fact, of all targets
This page took 0.03013 seconds and 4 git commands to generate.