Simplify regcache_restore
This patches removes the 2nd argument of regcache_restore, because it is only called by regcache_cpy. In regcache_cpy, if regcache_restore is called, dst is not readonly, but src is readonly. So this patch adds an assert that src is readonly in regcache_restore. regcache_cook_read read everything from a readonly regcache cache (src)'s register_buffer, and register status is from ->register_status. gdb: 2017-04-21 Yao Qi <yao.qi@linaro.org> * regcache.c (regcache_restore): Remove argument 2. Replace argument 3 with regcache. Get register status from src->register_status and get register contents from register_buffer (src, regnum). (regcache_cpy): Update.
This commit is contained in:
parent
3ab87b6883
commit
4daf993d4d
|
@ -1,3 +1,11 @@
|
||||||
|
2017-04-21 Yao Qi <yao.qi@linaro.org>
|
||||||
|
|
||||||
|
* regcache.c (regcache_restore): Remove argument 2. Replace
|
||||||
|
argument 3 with regcache. Get register status from
|
||||||
|
src->register_status and get register contents from
|
||||||
|
register_buffer (src, regnum).
|
||||||
|
(regcache_cpy): Update.
|
||||||
|
|
||||||
2017-04-19 Pedro Alves <palves@redhat.com>
|
2017-04-19 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* gdbthread.h (thread): Add missing closing parenthesis in
|
* gdbthread.h (thread): Add missing closing parenthesis in
|
||||||
|
|
|
@ -374,17 +374,15 @@ regcache_save (struct regcache *dst, regcache_cooked_read_ftype *cooked_read,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
regcache_restore (struct regcache *dst,
|
regcache_restore (struct regcache *dst, struct regcache *src)
|
||||||
regcache_cooked_read_ftype *cooked_read,
|
|
||||||
void *cooked_read_context)
|
|
||||||
{
|
{
|
||||||
struct gdbarch *gdbarch = dst->descr->gdbarch;
|
struct gdbarch *gdbarch = dst->descr->gdbarch;
|
||||||
gdb_byte buf[MAX_REGISTER_SIZE];
|
|
||||||
int regnum;
|
int regnum;
|
||||||
|
|
||||||
/* The dst had better not be read-only. If it is, the `restore'
|
/* The dst had better not be read-only. If it is, the `restore'
|
||||||
doesn't make much sense. */
|
doesn't make much sense. */
|
||||||
gdb_assert (!dst->readonly_p);
|
gdb_assert (!dst->readonly_p);
|
||||||
|
gdb_assert (src->readonly_p);
|
||||||
/* Copy over any registers, being careful to only restore those that
|
/* Copy over any registers, being careful to only restore those that
|
||||||
were both saved and need to be restored. The full [0 .. gdbarch_num_regs
|
were both saved and need to be restored. The full [0 .. gdbarch_num_regs
|
||||||
+ gdbarch_num_pseudo_regs) range is checked since some architectures need
|
+ gdbarch_num_pseudo_regs) range is checked since some architectures need
|
||||||
|
@ -393,11 +391,8 @@ regcache_restore (struct regcache *dst,
|
||||||
{
|
{
|
||||||
if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup))
|
if (gdbarch_register_reggroup_p (gdbarch, regnum, restore_reggroup))
|
||||||
{
|
{
|
||||||
enum register_status status;
|
if (src->register_status[regnum] == REG_VALID)
|
||||||
|
regcache_cooked_write (dst, regnum, register_buffer (src, regnum));
|
||||||
status = cooked_read (cooked_read_context, regnum, buf);
|
|
||||||
if (status == REG_VALID)
|
|
||||||
regcache_cooked_write (dst, regnum, buf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,7 +419,7 @@ regcache_cpy (struct regcache *dst, struct regcache *src)
|
||||||
if (!src->readonly_p)
|
if (!src->readonly_p)
|
||||||
regcache_save (dst, do_cooked_read, src);
|
regcache_save (dst, do_cooked_read, src);
|
||||||
else if (!dst->readonly_p)
|
else if (!dst->readonly_p)
|
||||||
regcache_restore (dst, do_cooked_read, src);
|
regcache_restore (dst, src);
|
||||||
else
|
else
|
||||||
regcache_cpy_no_passthrough (dst, src);
|
regcache_cpy_no_passthrough (dst, src);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue