+2017-03-23 Simon Marchi <simon.marchi@ericsson.com>
+
+ * 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.
+
2017-03-23 Alan Hayward <alan.hayward@arm.com>
* sol-thread.c (sol_thread_store_registers): Remove regcache calls.
fbsd_corefile_thread (struct thread_info *info,
struct fbsd_corefile_thread_data *args)
{
- struct cleanup *old_chain;
struct regcache *regcache;
regcache = get_thread_arch_regcache (info->ptid, args->gdbarch);
- old_chain = save_inferior_ptid ();
- inferior_ptid = info->ptid;
target_fetch_registers (regcache, -1);
- do_cleanups (old_chain);
args->note_data = fbsd_collect_thread_registers
(regcache, info->ptid, args->obfd, args->note_data,
ps_err_e
ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
{
- struct cleanup *old_chain = save_inferior_ptid ();
- struct regcache *regcache;
-
- inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
+ struct regcache *regcache
+ = get_thread_arch_regcache (ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
- do_cleanups (old_chain);
return PS_OK;
}
ps_err_e
ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset)
{
- struct cleanup *old_chain = save_inferior_ptid ();
- struct regcache *regcache;
-
- inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
+ struct regcache *regcache
+ = get_thread_arch_regcache (ptid, target_gdbarch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
target_store_registers (regcache, -1);
- do_cleanups (old_chain);
return PS_OK;
}
ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
gdb_prfpregset_t *fpregset)
{
- struct cleanup *old_chain = save_inferior_ptid ();
- struct regcache *regcache;
-
- inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
+ struct regcache *regcache
+ = get_thread_arch_regcache (ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
- do_cleanups (old_chain);
return PS_OK;
}
ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
const gdb_prfpregset_t *fpregset)
{
- struct cleanup *old_chain = save_inferior_ptid ();
- struct regcache *regcache;
-
- inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
+ struct regcache *regcache
+ = get_thread_arch_regcache (ptid, target_gdbarch ());
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
target_store_registers (regcache, -1);
- do_cleanups (old_chain);
return PS_OK;
}
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
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);
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
ps_err_e
ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
{
- struct cleanup *old_chain;
- struct regcache *regcache;
-
- old_chain = save_inferior_ptid ();
-
- inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ ptid_t ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
+ struct regcache *regcache
+ = get_thread_arch_regcache (ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
- do_cleanups (old_chain);
-
return PS_OK;
}
ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
const prgregset_t gregset)
{
- struct cleanup *old_chain;
- struct regcache *regcache;
-
- old_chain = save_inferior_ptid ();
-
- inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ ptid_t ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
+ struct regcache *regcache
+ = get_thread_arch_regcache (ptid, target_gdbarch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
target_store_registers (regcache, -1);
- do_cleanups (old_chain);
-
return PS_OK;
}
ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
prfpregset_t *fpregset)
{
- struct cleanup *old_chain;
- struct regcache *regcache;
-
- old_chain = save_inferior_ptid ();
-
- inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ ptid_t ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
+ struct regcache *regcache
+ = get_thread_arch_regcache (ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
- do_cleanups (old_chain);
-
return PS_OK;
}
ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
const prfpregset_t * fpregset)
{
- struct cleanup *old_chain;
- struct regcache *regcache;
-
- old_chain = save_inferior_ptid ();
-
- inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
+ ptid_t ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
+ struct regcache *regcache
+ = get_thread_arch_regcache (ptid, target_gdbarch ());
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
target_store_registers (regcache, -1);
- do_cleanups (old_chain);
-
return PS_OK;
}
void
target_fetch_registers (struct regcache *regcache, int regno)
{
- gdb_assert (ptid_equal (regcache_get_ptid (regcache), inferior_ptid));
-
current_target.to_fetch_registers (¤t_target, regcache, regno);
if (targetdebug)
debug_print_register ("target_fetch_registers", regcache, regno);
if (!may_write_registers)
error (_("Writing to registers is not allowed (regno %d)"), regno);
- gdb_assert (ptid_equal (regcache_get_ptid (regcache), inferior_ptid));
-
current_target.to_store_registers (¤t_target, regcache, regno);
if (targetdebug)
{