aboutsummaryrefslogtreecommitdiff
path: root/gdb/regcache.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@ericsson.com>2017-03-23 13:37:06 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2017-03-23 13:37:06 -0400
commit3e00d44febb8093d8dc0e6842b975afb194c4fd1 (patch)
tree328c147408e951650ebe8247a794592bcb6e8625 /gdb/regcache.c
parent077ae656a69fcf144f68848a3f6f2cb559b62987 (diff)
downloadgdb-3e00d44febb8093d8dc0e6842b975afb194c4fd1.zip
gdb-3e00d44febb8093d8dc0e6842b975afb194c4fd1.tar.gz
gdb-3e00d44febb8093d8dc0e6842b975afb194c4fd1.tar.bz2
Remove some unnecessary inferior_ptid setting/restoring when fetching/storing registers
Now that the to_fetch_registers, to_store_registers and to_prepare_to_store target methods don't rely on the value of inferior_ptid anymore, we can remove a bunch of now unnecessary setting and restoring of inferior_ptid. The asserts added recently in target_fetch_registers and target_store_registers, which validate that inferior_ptid matches the regcache's ptid, must go away. It's the whole point of this effort, to not require inferior_ptid to have a particular value when calling these functions. One thing that I noticed is how sol-thread.c's ps_lgetregs and friends use the current value of inferior_ptid instead of what's passed as argument (ph->ptid), unlike proc-service.c's versions of the same functions. Is it expected? I left it like this in the current patch, but unless there's a good reason for it to be that way, I guess we should make it use the parameter. gdb/ChangeLog: * fbsd-tdep.c (fbsd_corefile_thread): Don't set/restore inferior_ptid. * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * regcache.c (regcache_raw_update, regcache_raw_write): Likewise. * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs): Likewise. * target.c (target_fetch_registers, target_store_registers): Remove asserts.
Diffstat (limited to 'gdb/regcache.c')
-rw-r--r--gdb/regcache.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 58d4f56..71223a1 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -666,11 +666,7 @@ regcache_raw_update (struct regcache *regcache, int regnum)
if (!regcache->readonly_p
&& regcache_register_status (regcache, regnum) == REG_UNKNOWN)
{
- struct cleanup *old_chain = save_inferior_ptid ();
-
- inferior_ptid = regcache->ptid;
target_fetch_registers (regcache, regnum);
- do_cleanups (old_chain);
/* A number of targets can't access the whole set of raw
registers (because the debug API provides no means to get at
@@ -937,8 +933,7 @@ void
regcache_raw_write (struct regcache *regcache, int regnum,
const gdb_byte *buf)
{
- struct cleanup *chain_before_save_inferior;
- struct cleanup *chain_before_invalidate_register;
+ struct cleanup *old_chain;
gdb_assert (regcache != NULL && buf != NULL);
gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
@@ -956,24 +951,18 @@ regcache_raw_write (struct regcache *regcache, int regnum,
regcache->descr->sizeof_register[regnum]) == 0))
return;
- chain_before_save_inferior = save_inferior_ptid ();
- inferior_ptid = regcache->ptid;
-
target_prepare_to_store (regcache);
regcache_raw_set_cached_value (regcache, regnum, buf);
/* Register a cleanup function for invalidating the register after it is
written, in case of a failure. */
- chain_before_invalidate_register
- = make_cleanup_regcache_invalidate (regcache, regnum);
+ old_chain = make_cleanup_regcache_invalidate (regcache, regnum);
target_store_registers (regcache, regnum);
/* The target did not throw an error so we can discard invalidating the
register and restore the cleanup chain to what it was. */
- discard_cleanups (chain_before_invalidate_register);
-
- do_cleanups (chain_before_save_inferior);
+ discard_cleanups (old_chain);
}
void