@@ -380,9 +380,8 @@ amd64_pseudo_register_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
}
static void
-amd64_pseudo_register_write (struct gdbarch *gdbarch,
- struct regcache *regcache,
- int regnum, const gdb_byte *buf)
+amd64_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
+ int regnum, gdb::array_view<const gdb_byte> buf)
{
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
@@ -393,41 +392,18 @@ amd64_pseudo_register_write (struct gdbarch *gdbarch,
if (gpnum >= AMD64_NUM_LOWER_BYTE_REGS)
{
gpnum -= AMD64_NUM_LOWER_BYTE_REGS;
- gdb_byte raw_buf[register_size (gdbarch, gpnum)];
-
- /* Read ... AH, BH, CH, DH. */
- regcache->raw_read (gpnum, raw_buf);
- /* ... Modify ... (always little endian). */
- memcpy (raw_buf + 1, buf, 1);
- /* ... Write. */
- regcache->raw_write (gpnum, raw_buf);
+ pseudo_to_raw_part (next_frame, buf, gpnum, 1);
}
else
- {
- gdb_byte raw_buf[register_size (gdbarch, gpnum)];
-
- /* Read ... */
- regcache->raw_read (gpnum, raw_buf);
- /* ... Modify ... (always little endian). */
- memcpy (raw_buf, buf, 1);
- /* ... Write. */
- regcache->raw_write (gpnum, raw_buf);
- }
+ pseudo_to_raw_part (next_frame, buf, gpnum, 0);
}
else if (i386_dword_regnum_p (gdbarch, regnum))
{
int gpnum = regnum - tdep->eax_regnum;
- gdb_byte raw_buf[register_size (gdbarch, gpnum)];
-
- /* Read ... */
- regcache->raw_read (gpnum, raw_buf);
- /* ... Modify ... (always little endian). */
- memcpy (raw_buf, buf, 4);
- /* ... Write. */
- regcache->raw_write (gpnum, raw_buf);
+ pseudo_to_raw_part (next_frame, buf, gpnum, 0);
}
else
- i386_pseudo_register_write (gdbarch, regcache, regnum, buf);
+ i386_pseudo_register_write (gdbarch, next_frame, regnum, buf);
}
/* Implement the 'ax_pseudo_register_collect' gdbarch method. */
@@ -3205,8 +3181,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
set_gdbarch_pseudo_register_read_value (gdbarch,
amd64_pseudo_register_read_value);
- set_gdbarch_deprecated_pseudo_register_write (gdbarch,
- amd64_pseudo_register_write);
+ set_gdbarch_pseudo_register_write (gdbarch, amd64_pseudo_register_write);
set_gdbarch_ax_pseudo_register_collect (gdbarch,
amd64_ax_pseudo_register_collect);
@@ -3391,26 +3391,6 @@ i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
internal_error (_("invalid regnum"));
}
-/* Map a cooked register onto a raw register or memory. For the i386,
- the MMX registers need to be mapped onto floating point registers. */
-
-static int
-i386_mmx_regnum_to_fp_regnum (readable_regcache *regcache, int regnum)
-{
- gdbarch *arch = regcache->arch ();
- i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
- int mmxreg, fpreg;
- ULONGEST fstat;
- int tos;
-
- mmxreg = regnum - tdep->mm0_regnum;
- regcache->raw_read (I387_FSTAT_REGNUM (tdep), &fstat);
- tos = (fstat >> 11) & 0x7;
- fpreg = (mmxreg + tos) % 8;
-
- return (I387_ST0_REGNUM (tdep) + fpreg);
-}
-
/* Map a cooked register onto a raw register or memory. For the i386,
the MMX registers need to be mapped onto floating point registers. */
@@ -3537,115 +3517,92 @@ i386_pseudo_register_read_value (gdbarch *gdbarch, frame_info_ptr next_frame,
}
void
-i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
- int regnum, const gdb_byte *buf)
+i386_pseudo_register_write (gdbarch *gdbarch, frame_info_ptr next_frame,
+ const int pseudo_reg_num,
+ gdb::array_view<const gdb_byte> buf)
{
- gdb_byte raw_buf[I386_MAX_REGISTER_SIZE];
-
- if (i386_mmx_regnum_p (gdbarch, regnum))
+ if (i386_mmx_regnum_p (gdbarch, pseudo_reg_num))
{
- int fpnum = i386_mmx_regnum_to_fp_regnum (regcache, regnum);
+ int fpnum = i386_mmx_regnum_to_fp_regnum (next_frame, pseudo_reg_num);
- /* Read ... */
- regcache->raw_read (fpnum, raw_buf);
- /* ... Modify ... (always little endian). */
- memcpy (raw_buf, buf, register_size (gdbarch, regnum));
- /* ... Write. */
- regcache->raw_write (fpnum, raw_buf);
+ pseudo_to_raw_part (next_frame, buf, fpnum, 0);
}
else
{
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
- if (i386_bnd_regnum_p (gdbarch, regnum))
+ if (i386_bnd_regnum_p (gdbarch, pseudo_reg_num))
{
- ULONGEST upper, lower;
int size = builtin_type (gdbarch)->builtin_data_ptr->length ();
bfd_endian byte_order
= gdbarch_byte_order (current_inferior ()->arch ());
/* New values from input value. */
- regnum -= tdep->bnd0_regnum;
- lower = extract_unsigned_integer (buf, size, byte_order);
- upper = extract_unsigned_integer (buf + size, size, byte_order);
+ int reg_index = pseudo_reg_num - tdep->bnd0_regnum;
+ int raw_regnum = I387_BND0R_REGNUM (tdep) + reg_index;
- /* Fetching register buffer. */
- regcache->raw_read (I387_BND0R_REGNUM (tdep) + regnum,
- raw_buf);
+ value *bndr_value = value_of_register (raw_regnum, next_frame);
+ gdb::array_view<gdb_byte> bndr_view
+ = bndr_value->contents_writeable ();
- upper = ~upper;
+ /* Copy lower bytes directly. */
+ copy (buf.slice (0, size), bndr_view.slice (0, size));
- /* Set register bits. */
- memcpy (raw_buf, &lower, 8);
- memcpy (raw_buf + 8, &upper, 8);
+ /* Convert and then copy upper bytes. */
+ ULONGEST upper
+ = extract_unsigned_integer (buf.slice (size, size), byte_order);
+ upper = ~upper;
+ store_unsigned_integer (bndr_view.slice (8, size), byte_order,
+ upper);
- regcache->raw_write (I387_BND0R_REGNUM (tdep) + regnum, raw_buf);
+ put_frame_register (next_frame, raw_regnum, bndr_view);
}
- else if (i386_zmm_regnum_p (gdbarch, regnum))
+ else if (i386_zmm_regnum_p (gdbarch, pseudo_reg_num))
{
- regnum -= tdep->zmm0_regnum;
+ /* Which register is it, relative to zmm0. */
+ int reg_index_0 = pseudo_reg_num - tdep->zmm0_regnum;
- if (regnum < num_lower_zmm_regs)
- {
- /* Write lower 128bits. */
- regcache->raw_write (I387_XMM0_REGNUM (tdep) + regnum, buf);
- /* Write upper 128bits. */
- regcache->raw_write (I387_YMM0_REGNUM (tdep) + regnum, buf + 16);
- }
+ if (reg_index_0 < num_lower_zmm_regs)
+ pseudo_to_concat_raw (next_frame, buf,
+ I387_XMM0_REGNUM (tdep) + reg_index_0,
+ I387_YMM0_REGNUM (tdep) + reg_index_0,
+ tdep->zmm0h_regnum + reg_index_0);
else
{
- /* Write lower 128bits. */
- regcache->raw_write (I387_XMM16_REGNUM (tdep) + regnum
- - num_lower_zmm_regs, buf);
- /* Write upper 128bits. */
- regcache->raw_write (I387_YMM16H_REGNUM (tdep) + regnum
- - num_lower_zmm_regs, buf + 16);
+ /* Which register is it, relative to zmm16. */
+ int reg_index_16 = reg_index_0 - num_lower_zmm_regs;
+
+ pseudo_to_concat_raw (next_frame, buf,
+ I387_XMM16_REGNUM (tdep) + reg_index_16,
+ I387_YMM16H_REGNUM (tdep) + reg_index_16,
+ tdep->zmm0h_regnum + +reg_index_0);
}
- /* Write upper 256bits. */
- regcache->raw_write (tdep->zmm0h_regnum + regnum, buf + 32);
}
- else if (i386_ymm_regnum_p (gdbarch, regnum))
+ else if (i386_ymm_regnum_p (gdbarch, pseudo_reg_num))
{
- regnum -= tdep->ymm0_regnum;
+ int i = pseudo_reg_num - tdep->ymm0_regnum;
- /* ... Write lower 128bits. */
- regcache->raw_write (I387_XMM0_REGNUM (tdep) + regnum, buf);
- /* ... Write upper 128bits. */
- regcache->raw_write (tdep->ymm0h_regnum + regnum, buf + 16);
+ pseudo_to_concat_raw (next_frame, buf, I387_XMM0_REGNUM (tdep) + i,
+ tdep->ymm0h_regnum + i);
}
- else if (i386_ymm_avx512_regnum_p (gdbarch, regnum))
+ else if (i386_ymm_avx512_regnum_p (gdbarch, pseudo_reg_num))
{
- regnum -= tdep->ymm16_regnum;
+ int i = pseudo_reg_num - tdep->ymm16_regnum;
- /* ... Write lower 128bits. */
- regcache->raw_write (I387_XMM16_REGNUM (tdep) + regnum, buf);
- /* ... Write upper 128bits. */
- regcache->raw_write (tdep->ymm16h_regnum + regnum, buf + 16);
+ pseudo_to_concat_raw (next_frame, buf, I387_XMM16_REGNUM (tdep) + i,
+ tdep->ymm16h_regnum + i);
}
- else if (i386_word_regnum_p (gdbarch, regnum))
+ else if (i386_word_regnum_p (gdbarch, pseudo_reg_num))
{
- int gpnum = regnum - tdep->ax_regnum;
+ int gpnum = pseudo_reg_num - tdep->ax_regnum;
- /* Read ... */
- regcache->raw_read (gpnum, raw_buf);
- /* ... Modify ... (always little endian). */
- memcpy (raw_buf, buf, 2);
- /* ... Write. */
- regcache->raw_write (gpnum, raw_buf);
+ pseudo_to_raw_part (next_frame, buf, gpnum, 0);
}
- else if (i386_byte_regnum_p (gdbarch, regnum))
+ else if (i386_byte_regnum_p (gdbarch, pseudo_reg_num))
{
- int gpnum = regnum - tdep->al_regnum;
+ int gpnum = pseudo_reg_num - tdep->al_regnum;
- /* Read ... We read both lower and upper registers. */
- 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 (gpnum % 4, raw_buf);
+ pseudo_to_raw_part (next_frame, buf, gpnum % 4, gpnum >= 4 ? 1 : 0);
}
else
internal_error (_("invalid regnum"));
@@ -8603,8 +8560,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Pseudo registers may be changed by amd64_init_abi. */
set_gdbarch_pseudo_register_read_value (gdbarch,
i386_pseudo_register_read_value);
- set_gdbarch_deprecated_pseudo_register_write (gdbarch,
- i386_pseudo_register_write);
+ set_gdbarch_pseudo_register_write (gdbarch, i386_pseudo_register_write);
set_gdbarch_ax_pseudo_register_collect (gdbarch,
i386_ax_pseudo_register_collect);
@@ -380,9 +380,9 @@ extern value *i386_pseudo_register_read_value (gdbarch *gdbarch,
frame_info_ptr next_frame,
int regnum);
-extern void i386_pseudo_register_write (struct gdbarch *gdbarch,
- struct regcache *regcache,
- int regnum, const gdb_byte *buf);
+extern void i386_pseudo_register_write (gdbarch *gdbarch,
+ frame_info_ptr next_frame, int regnum,
+ gdb::array_view<const gdb_byte> buf);
extern int i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
struct agent_expr *ax,