@@ -337,7 +337,6 @@ regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read,
void *src)
{
struct gdbarch *gdbarch = dst->descr->gdbarch;
- gdb_byte buf[MAX_REGISTER_SIZE];
int regnum;
/* The DST should be `read-only', if it wasn't then the save would
@@ -356,17 +355,13 @@ regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read,
{
if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup))
{
- enum register_status status = cooked_read (src, regnum, buf);
+ gdb_byte *dst_buf = register_buffer (dst, regnum);
+ enum register_status status = cooked_read (src, regnum, dst_buf);
- if (status == REG_VALID)
- memcpy (register_buffer (dst, regnum), buf,
- register_size (gdbarch, regnum));
- else
+ if (status != REG_VALID)
{
gdb_assert (status != REG_UNKNOWN);
-
- memset (register_buffer (dst, regnum), 0,
- register_size (gdbarch, regnum));
+ memset (dst_buf, 0, register_size (gdbarch, regnum));
}
dst->register_status[regnum] = status;
}
@@ -1334,7 +1329,6 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
int footnote_register_offset = 0;
int footnote_register_type_name_null = 0;
long register_offset = 0;
- gdb_byte buf[MAX_REGISTER_SIZE];
#if 0
fprintf_unfiltered (file, "nr_raw_registers %d\n",
@@ -1461,8 +1455,8 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
fprintf_unfiltered (file, "<unavailable>");
else
{
- regcache_raw_read (regcache, regnum, buf);
- print_hex_chars (file, buf,
+ regcache_raw_update (regcache, regnum);
+ print_hex_chars (file, register_buffer (regcache, regnum),
regcache->descr->sizeof_register[regnum],
gdbarch_byte_order (gdbarch));
}
@@ -1475,9 +1469,30 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
fprintf_unfiltered (file, "Cooked value");
else
{
+ const gdb_byte *buf = NULL;
enum register_status status;
+ struct value *value = NULL;
+
+ if (regnum < regcache->descr->nr_raw_registers)
+ {
+ regcache_raw_update (regcache, regnum);
+ status = regcache_register_status (regcache, regnum);
+ buf = register_buffer (regcache, regnum);
+ }
+ else
+ {
+ value = regcache_cooked_read_value (regcache, regnum);
+
+ if (!value_optimized_out (value)
+ && value_entirely_available (value))
+ {
+ status = REG_VALID;
+ buf = value_contents_all (value);
+ }
+ else
+ status = REG_UNAVAILABLE;
+ }
- status = regcache_cooked_read (regcache, regnum, buf);
if (status == REG_UNKNOWN)
fprintf_unfiltered (file, "<invalid>");
else if (status == REG_UNAVAILABLE)
@@ -1486,6 +1501,12 @@ regcache_dump (struct regcache *regcache, struct ui_file *file,
print_hex_chars (file, buf,
regcache->descr->sizeof_register[regnum],
gdbarch_byte_order (gdbarch));
+
+ if (value != NULL)
+ {
+ release_value (value);
+ value_free (value);
+ }
}
}