* [PATCH 5/7] Pass ptid to target_fetch_registers
2017-03-08 16:42 [PATCH 0/7] Pass ptid to target_ops register methods Simon Marchi
@ 2017-03-08 16:42 ` Simon Marchi
2017-03-08 21:08 ` Simon Marchi
2017-03-08 16:42 ` [PATCH 7/7] Pass ptid to to_prepare_to_store Simon Marchi
` (7 subsequent siblings)
8 siblings, 1 reply; 14+ messages in thread
From: Simon Marchi @ 2017-03-08 16:42 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
This patch adds a ptid parameter to the target_fetch_registers and the
to_fetch_registers method of target_ops. The implementations are
therefore expected to rely on this and not on inferior_ptid.
gdb/ChangeLog:
* target-delegates.c: Re-generate.
* target.h (struct target_ops) <to_fetch_registers>: Add ptid
parameter.
(target_fetch_registers): Likewise.
* target.c (target_fetch_registers): Likewise.
* aarch64-linux-nat.c (fetch_gregs_from_thread,
fetch_fpregs_from_thread,
aarch64_linux_fetch_inferior_registers): Add ptid parameter and
use it.
* aix-thread.c (aix_thread_fetch_registers): Likewise.
* alpha-bsd-nat.c (alphabsd_fetch_inferior_registers): Likewise.
* amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers):
Likewise.
* arm-linux-nat.c (fetch_fpregs, fetch_regs, fetch_wmmx_regs,
fetch_vfp_regs, arm_linux_fetch_inferior_registers): Likewise.
* arm-nbsd-nat.c (fetch_register, fetch_regs,
fetch_fp_register, fetch_fp_regs, armnbsd_fetch_registers):
Likewise.
* bsd-kvm.c (bsd_kvm_fetch_registers): Likewise.
* bsd-uthread.c (bsd_uthread_fetch_registers): Likewise.
* corelow.c (core_open): Pass inferior_ptid to
target_fetch_registers.
(get_core_registers): Add ptid parameter and use it.
* ctf.c (ctf_fetch_registers): Likewise.
* fbsd-tdep.c (fbsd_corefile_thread): Don't set/restore
inferior_ptid, pass ptid to target_fetch_registers.
* go32-nat.c (go32_fetch_registers): Add ptid parameter and use
it.
* hppa-linux-nat.c (fetch_register,
hppa_linux_fetch_inferior_registers): Likewise.
* hppa-nbsd-nat.c (hppanbsd_fetch_registers): Likewise.
* hppa-obsd-nat.c (hppaobsd_fetch_registers): Likewise.
* i386-bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise.
* i386-darwin-nat.c (i386_darwin_fetch_inferior_registers):
Likewise.
* i386-gnu-nat.c (gnu_fetch_registers): Likewise.
* i386-linux-nat.c (fetch_register,
i386_linux_fetch_inferior_registers): Likewise.
* ia64-linux-nat.c (ia64_linux_fetch_register,
ia64_linux_fetch_registers): Likewise.
* inf-child.c (inf_child_fetch_inferior_registers): Likewise.
* inf-ptrace.c (inf_ptrace_fetch_register,
inf_ptrace_fetch_registers): Likewise.
* linux-tdep.c (linux_corefile_thread): Pass ptid to
target_fetch_registers.
* m32r-linux-nat.c (m32r_linux_fetch_inferior_registers):
Add ptid parameter and use it.
* m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise.
* m68k-linux-nat.c (fetch_register,
old_fetch_inferior_register,
m68k_linux_fetch_inferior_registers): Likewise.
* m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise.
* mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers):
Likewise.
* mips-linux-nat.c (super_fetch_registers,
mips64_linux_regsets_fetch_registers,
mips64_linux_fetch_registers): Likewise.
* mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise.
* mips-obsd-nat.c (mips64obsd_fetch_inferior_registers):
Likewise.
* nto-procfs.c (procfs_fetch_registers): Likewise.
* ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers): Likewise.
* ppc-linux-nat.c (ppc_linux_fetch_inferior_registers):
Likewise.
* ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise.
* ppc-obsd-nat.c (ppcobsd_fetch_registers): Likewise.
* ppc-ravenscar-thread.c (ppc_ravenscar_generic_fetch_registers,
ppc_ravenscar_powerpc_fetch_registers,
ppc_ravenscar_e500_fetch_registers): Likewise.
* proc-service.c (ps_lgetregs, ps_lgetfpregs): Pass ptid directly
to target_fetch_registers, don't use inferior_ptid.
* procfs.c (procfs_fetch_registers): Add ptid parameter and use
it.
* ravenscar-thread.c (ravenscar_fetch_registers): Add ptid
parameter and use it. Remove declaration at top of file.
* ravenscar-thread.h (struct ravenscar_arch_ops)
<to_fetch_registers): Add ptid_t parameter.
* record-btrace.c (record_btrace_fetch_registers): Add ptid
parameter and use it.
* record-full.c (record_full_core_open_1): Pass inferior_ptid to
target_fetch_registers.
(record_full_core_fetch_registers): Add ptid parameter.
* regcache.c (regcache_raw_update): Pass inferior_ptid to
target_fetch_registers.
* remote.c (remote_fetch_registers): Add ptid parameter and use
it.
* remote-sim.c (gdbsim_fetch_register): Likewise.
* rs6000-nat.c (fetch_register,
rs6000_fetch_inferior_registers): Likewise.
* s390-linux-nat.c (s390_linux_fetch_inferior_registers):
Likewise.
* sh-nbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise.
* sol-thread.c (sol_thread_fetch_registers): Likewise.
* sparc-nat.c (sparc_fetch_inferior_registers): Likewise.
* sparc-nat.h (sparc_fetch_inferior_registers): Likewise.
* sparc-ravenscar-thread.c (sparc_ravenscar_fetch_registers):
Add ptid parameter and use it. Remove declaration at top of
file.
* spu-multiarch.c (spu_fetch_registers): Add ptid parameter and
use it.
* tilegx-linux-nat.c (fetch_inferior_registers): Likewise.
* tracefile-tfile.c (tfile_fetch_registers): Likewise.
* vax-bsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise.
* windows-nat.c (windows_fetch_inferior_registers): Likewise.
(windows_resume): Pass inferior_ptid to windows_resume.
* xtensa-linux-nat.c (fetch_gregs, fetch_xtregs,
xtensa_linux_fetch_inferior_registers): Add ptid parameter and
use it.
---
gdb/aarch64-linux-nat.c | 18 +++++++++---------
gdb/aix-thread.c | 13 +++++++------
gdb/alpha-bsd-nat.c | 18 ++++++++++--------
gdb/amd64-bsd-nat.c | 24 +++++++++++++-----------
gdb/amd64-linux-nat.c | 7 ++++---
gdb/arm-linux-nat.c | 35 ++++++++++++++++++-----------------
gdb/arm-nbsd-nat.c | 27 ++++++++++++++-------------
gdb/bsd-kvm.c | 3 ++-
gdb/bsd-uthread.c | 7 +++----
gdb/corelow.c | 6 +++---
gdb/ctf.c | 3 ++-
gdb/fbsd-tdep.c | 6 +-----
gdb/go32-nat.c | 6 ++++--
gdb/hppa-linux-nat.c | 13 +++++++------
gdb/hppa-nbsd-nat.c | 18 ++++++++++--------
gdb/hppa-obsd-nat.c | 18 ++++++++++--------
gdb/i386-bsd-nat.c | 30 ++++++++++++++++--------------
gdb/i386-darwin-nat.c | 10 ++++++----
gdb/i386-gnu-nat.c | 14 ++++++++------
gdb/i386-linux-nat.c | 17 +++++++++--------
gdb/ia64-linux-nat.c | 13 +++++++------
gdb/inf-child.c | 3 ++-
gdb/inf-ptrace.c | 14 +++++++-------
gdb/linux-tdep.c | 4 +++-
gdb/m32r-linux-nat.c | 14 ++++++++------
gdb/m68k-bsd-nat.c | 18 ++++++++++--------
gdb/m68k-linux-nat.c | 23 ++++++++++++-----------
gdb/m88k-bsd-nat.c | 12 +++++++-----
gdb/mips-fbsd-nat.c | 18 ++++++++++--------
gdb/mips-linux-nat.c | 23 +++++++++++++----------
gdb/mips-nbsd-nat.c | 18 ++++++++++--------
gdb/mips64-obsd-nat.c | 12 +++++++-----
gdb/nto-procfs.c | 12 +++++++-----
gdb/ppc-fbsd-nat.c | 18 ++++++++++--------
gdb/ppc-linux-nat.c | 7 ++++---
gdb/ppc-nbsd-nat.c | 7 ++++---
gdb/ppc-obsd-nat.c | 7 ++++---
gdb/ppc-ravenscar-thread.c | 15 +++++++++------
gdb/proc-service.c | 18 ++++++------------
gdb/procfs.c | 11 ++++++-----
gdb/ravenscar-thread.c | 14 ++++++--------
gdb/ravenscar-thread.h | 2 +-
gdb/record-btrace.c | 7 ++++---
gdb/record-full.c | 4 ++--
gdb/regcache.c | 2 +-
gdb/remote-sim.c | 8 +++++---
gdb/remote.c | 6 +++---
gdb/rs6000-nat.c | 33 +++++++++++++++++----------------
gdb/s390-linux-nat.c | 5 +++--
gdb/sh-nbsd-nat.c | 5 +++--
gdb/sol-thread.c | 11 ++++++-----
gdb/sparc-nat.c | 7 ++++---
gdb/sparc-nat.h | 2 +-
gdb/sparc-ravenscar-thread.c | 7 +++----
gdb/spu-multiarch.c | 8 ++++----
gdb/target-delegates.c | 14 ++++++++------
gdb/target.c | 4 ++--
gdb/target.h | 9 ++++++---
gdb/tilegx-linux-nat.c | 7 ++++---
gdb/tracefile-tfile.c | 4 ++--
gdb/vax-bsd-nat.c | 5 +++--
gdb/windows-nat.c | 7 ++++---
gdb/xtensa-linux-nat.c | 23 ++++++++++++-----------
63 files changed, 406 insertions(+), 348 deletions(-)
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 0d472e2e53..3fc340496c 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -152,7 +152,7 @@ aarch64_get_debug_reg_state (pid_t pid)
from the current thread. */
static void
-fetch_gregs_from_thread (struct regcache *regcache)
+fetch_gregs_from_thread (struct regcache *regcache, ptid_t ptid)
{
int ret, tid;
struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -163,7 +163,7 @@ fetch_gregs_from_thread (struct regcache *regcache)
and arm. */
gdb_static_assert (sizeof (regs) >= 18 * 4);
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
iovec.iov_base = ®s;
if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
@@ -233,7 +233,7 @@ store_gregs_to_thread (const struct regcache *regcache)
from the current thread. */
static void
-fetch_fpregs_from_thread (struct regcache *regcache)
+fetch_fpregs_from_thread (struct regcache *regcache, ptid_t ptid)
{
int ret, tid;
elf_fpregset_t regs;
@@ -244,7 +244,7 @@ fetch_fpregs_from_thread (struct regcache *regcache)
and arm. */
gdb_static_assert (sizeof regs >= VFP_REGS_SIZE);
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
iovec.iov_base = ®s;
@@ -347,17 +347,17 @@ store_fpregs_to_thread (const struct regcache *regcache)
static void
aarch64_linux_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache,
- int regno)
+ ptid_t ptid, int regno)
{
if (regno == -1)
{
- fetch_gregs_from_thread (regcache);
- fetch_fpregs_from_thread (regcache);
+ fetch_gregs_from_thread (regcache, ptid);
+ fetch_fpregs_from_thread (regcache, ptid);
}
else if (regno < AARCH64_V0_REGNUM)
- fetch_gregs_from_thread (regcache);
+ fetch_gregs_from_thread (regcache, ptid);
else
- fetch_fpregs_from_thread (regcache);
+ fetch_fpregs_from_thread (regcache, ptid);
}
/* Implement the "to_store_register" target_ops method. */
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index cf1a462216..b85c147f03 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1298,21 +1298,22 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
}
/* Fetch register REGNO if != -1 or all registers otherwise in the
- thread/process specified by inferior_ptid. */
+ thread/process specified by PTID. */
static void
aix_thread_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct thread_info *thread;
pthdb_tid_t tid;
struct target_ops *beneath = find_target_beneath (ops);
- if (!PD_TID (inferior_ptid))
- beneath->to_fetch_registers (beneath, regcache, regno);
+ if (!PD_TID (ptid))
+ beneath->to_fetch_registers (beneath, regcache, ptid, regno);
else
{
- thread = find_thread_ptid (inferior_ptid);
+ thread = find_thread_ptid (ptid);
tid = thread->priv->tid;
if (tid == PTHDB_INVALID_TID)
@@ -1652,7 +1653,7 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
}
/* Store gdb's current view of the register set into the
- thread/process specified by inferior_ptid. */
+ thread/process specified by PTID. */
static void
aix_thread_store_registers (struct target_ops *ops,
diff --git a/gdb/alpha-bsd-nat.c b/gdb/alpha-bsd-nat.c
index 5914d89882..4440b5539b 100644
--- a/gdb/alpha-bsd-nat.c
+++ b/gdb/alpha-bsd-nat.c
@@ -85,13 +85,14 @@ getregs_supplies (int regno)
static void
alphabsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (regno == -1 || getregs_supplies (regno))
{
struct reg gregs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &gregs, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -105,7 +106,7 @@ alphabsd_fetch_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
@@ -118,18 +119,19 @@ alphabsd_fetch_inferior_registers (struct target_ops *ops,
static void
alphabsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (regno == -1 || getregs_supplies (regno))
{
struct reg gregs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &gregs, 0) == -1)
perror_with_name (_("Couldn't get registers"));
alphabsd_fill_reg (regcache, (char *) &gregs, regno);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &gregs, 0) == -1)
perror_with_name (_("Couldn't write registers"));
@@ -142,13 +144,13 @@ alphabsd_store_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
alphabsd_fill_fpreg (regcache, (char *) &fpregs, regno);
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
diff --git a/gdb/amd64-bsd-nat.c b/gdb/amd64-bsd-nat.c
index 5678e94d11..1fd0e29610 100644
--- a/gdb/amd64-bsd-nat.c
+++ b/gdb/amd64-bsd-nat.c
@@ -40,7 +40,8 @@
static void
amd64bsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -48,7 +49,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
{
struct reg regs;
- if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -66,7 +67,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
if (x86bsd_xsave_len != 0)
{
xstateregs = alloca (x86bsd_xsave_len);
- if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETXSTATE, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
perror_with_name (_("Couldn't get extended state status"));
@@ -75,7 +76,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
}
#endif
- if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
@@ -88,7 +89,8 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops,
static void
amd64bsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -96,13 +98,13 @@ amd64bsd_store_inferior_registers (struct target_ops *ops,
{
struct reg regs;
- if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
amd64_collect_native_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
@@ -119,26 +121,26 @@ amd64bsd_store_inferior_registers (struct target_ops *ops,
if (x86bsd_xsave_len != 0)
{
xstateregs = alloca (x86bsd_xsave_len);
- if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETXSTATE, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
perror_with_name (_("Couldn't get extended state status"));
amd64_collect_xsave (regcache, regnum, xstateregs, 0);
- if (ptrace (PT_SETXSTATE, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETXSTATE, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1)
perror_with_name (_("Couldn't write extended state status"));
return;
}
#endif
- if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
amd64_collect_fxsave (regcache, regnum, &fpregs);
- if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 4a429ec2a1..a9f61cddac 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -132,15 +132,16 @@ fill_fpregset (const struct regcache *regcache,
static void
amd64_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int tid;
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
{
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index c8474a9f4f..86ac33d307 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -70,13 +70,13 @@ extern int arm_apcs_32;
into regcache. */
static void
-fetch_fpregs (struct regcache *regcache)
+fetch_fpregs (struct regcache *regcache, ptid_t ptid)
{
int ret, regno, tid;
gdb_byte fp[ARM_LINUX_SIZEOF_NWFPE];
/* Get the thread id for the ptrace call. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
/* Read the floating point state. */
if (have_ptrace_getregset == TRIBOOL_TRUE)
@@ -161,13 +161,13 @@ store_fpregs (const struct regcache *regcache)
regcache. */
static void
-fetch_regs (struct regcache *regcache)
+fetch_regs (struct regcache *regcache, ptid_t ptid)
{
int ret, regno, tid;
elf_gregset_t regs;
/* Get the thread id for the ptrace call. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
@@ -236,13 +236,13 @@ store_regs (const struct regcache *regcache)
#define IWMMXT_REGS_SIZE (16 * 8 + 6 * 4)
static void
-fetch_wmmx_regs (struct regcache *regcache)
+fetch_wmmx_regs (struct regcache *regcache, ptid_t ptid)
{
char regbuf[IWMMXT_REGS_SIZE];
int ret, regno, tid;
/* Get the thread id for the ptrace call. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
ret = ptrace (PTRACE_GETWMMXREGS, tid, 0, regbuf);
if (ret < 0)
@@ -299,7 +299,7 @@ store_wmmx_regs (const struct regcache *regcache)
}
static void
-fetch_vfp_regs (struct regcache *regcache)
+fetch_vfp_regs (struct regcache *regcache, ptid_t ptid)
{
gdb_byte regbuf[VFP_REGS_SIZE];
int ret, regno, tid;
@@ -307,7 +307,7 @@ fetch_vfp_regs (struct regcache *regcache)
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* Get the thread id for the ptrace call. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
@@ -376,34 +376,35 @@ store_vfp_regs (const struct regcache *regcache)
static void
arm_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (-1 == regno)
{
- fetch_regs (regcache);
+ fetch_regs (regcache, ptid);
if (tdep->have_wmmx_registers)
- fetch_wmmx_regs (regcache);
+ fetch_wmmx_regs (regcache, ptid);
if (tdep->vfp_register_count > 0)
- fetch_vfp_regs (regcache);
+ fetch_vfp_regs (regcache, ptid);
if (tdep->have_fpa_registers)
- fetch_fpregs (regcache);
+ fetch_fpregs (regcache, ptid);
}
else
{
if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM)
- fetch_regs (regcache);
+ fetch_regs (regcache, ptid);
else if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM)
- fetch_fpregs (regcache);
+ fetch_fpregs (regcache, ptid);
else if (tdep->have_wmmx_registers
&& regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
- fetch_wmmx_regs (regcache);
+ fetch_wmmx_regs (regcache, ptid);
else if (tdep->vfp_register_count > 0
&& regno >= ARM_D0_REGNUM
&& regno <= ARM_D0_REGNUM + tdep->vfp_register_count)
- fetch_vfp_regs (regcache);
+ fetch_vfp_regs (regcache, ptid);
}
}
diff --git a/gdb/arm-nbsd-nat.c b/gdb/arm-nbsd-nat.c
index 95bb1b2ad0..8857e37ce0 100644
--- a/gdb/arm-nbsd-nat.c
+++ b/gdb/arm-nbsd-nat.c
@@ -72,12 +72,12 @@ arm_supply_fparegset (struct regcache *regcache, struct fpreg *fparegset)
}
static void
-fetch_register (struct regcache *regcache, int regno)
+fetch_register (struct regcache *regcache, ptid_t ptid, int regno)
{
struct reg inferior_registers;
int ret;
- ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
@@ -124,13 +124,13 @@ fetch_register (struct regcache *regcache, int regno)
}
static void
-fetch_regs (struct regcache *regcache)
+fetch_regs (struct regcache *regcache, ptid_t ptid)
{
struct reg inferior_registers;
int ret;
int regno;
- ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
@@ -143,12 +143,12 @@ fetch_regs (struct regcache *regcache)
}
static void
-fetch_fp_register (struct regcache *regcache, int regno)
+fetch_fp_register (struct regcache *regcache, ptid_t ptid, int regno)
{
struct fpreg inferior_fp_registers;
int ret;
- ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
@@ -172,13 +172,13 @@ fetch_fp_register (struct regcache *regcache, int regno)
}
static void
-fetch_fp_regs (struct regcache *regcache)
+fetch_fp_regs (struct regcache *regcache, ptid_t ptid)
{
struct fpreg inferior_fp_registers;
int ret;
int regno;
- ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
@@ -192,19 +192,20 @@ fetch_fp_regs (struct regcache *regcache)
static void
armnbsd_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (regno >= 0)
{
if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
- fetch_register (regcache, regno);
+ fetch_register (regcache, ptid, regno);
else
- fetch_fp_register (regcache, regno);
+ fetch_fp_register (regcache, ptid, regno);
}
else
{
- fetch_regs (regcache);
- fetch_fp_regs (regcache);
+ fetch_regs (regcache, ptid);
+ fetch_fp_regs (regcache, ptid);
}
}
diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
index 9f4f9e71ed..7ca59ba2b9 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -185,7 +185,8 @@ bsd_kvm_fetch_pcb (struct regcache *regcache, struct pcb *paddr)
static void
bsd_kvm_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct nlist nl[2];
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 2111128f21..c2c9866cd0 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -280,19 +280,18 @@ bsd_uthread_mourn_inferior (struct target_ops *ops)
}
static void
-bsd_uthread_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+bsd_uthread_fetch_registers (struct target_ops *ops, struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct bsd_uthread_ops *uthread_ops
= (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
- ptid_t ptid = inferior_ptid;
CORE_ADDR addr = ptid_get_tid (ptid);
struct target_ops *beneath = find_target_beneath (ops);
CORE_ADDR active_addr;
/* Always fetch the appropriate registers from the layer beneath. */
- beneath->to_fetch_registers (beneath, regcache, regnum);
+ beneath->to_fetch_registers (beneath, regcache, ptid, regnum);
/* FIXME: That might have gotten us more than we asked for. Make
sure we overwrite all relevant registers with values from the
diff --git a/gdb/corelow.c b/gdb/corelow.c
index ecde9542b5..735ce9f780 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -451,7 +451,7 @@ core_open (const char *arg, int from_tty)
}
/* Fetch all registers from core file. */
- target_fetch_registers (get_current_regcache (), -1);
+ target_fetch_registers (get_current_regcache (), inferior_ptid, -1);
/* Now, set up the frame cache, and print the top of stack. */
reinit_frame_cache ();
@@ -605,8 +605,8 @@ get_core_registers_cb (const char *sect_name, int size,
/* We just get all the registers, so we don't use regno. */
static void
-get_core_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+get_core_registers (struct target_ops *ops, struct regcache *regcache,
+ ptid_t ptid, int regno)
{
int i;
struct gdbarch *gdbarch;
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 8716cadf97..4073d8b30d 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1190,7 +1190,8 @@ ctf_files_info (struct target_ops *t)
static void
ctf_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct bt_ctf_event *event = NULL;
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index e757910023..e6f564e4f0 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -193,15 +193,11 @@ static void
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);
+ target_fetch_registers (regcache, info->ptid, -1);
args->note_data = fbsd_collect_thread_registers
(regcache, info->ptid, args->obfd, args->note_data,
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 1fca8e2e53..cc5fc8f188 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -507,7 +507,8 @@ fetch_register (struct regcache *regcache, int regno)
static void
go32_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (regno >= 0)
fetch_register (regcache, regno);
@@ -538,7 +539,8 @@ store_register (const struct regcache *regcache, int regno)
static void
go32_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
unsigned r;
diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c
index 17d9ced9e5..da1f914dd9 100644
--- a/gdb/hppa-linux-nat.c
+++ b/gdb/hppa-linux-nat.c
@@ -210,7 +210,7 @@ static const int greg_map[] =
/* Fetch one register. */
static void
-fetch_register (struct regcache *regcache, int regno)
+fetch_register (struct regcache *regcache, ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int tid;
@@ -223,9 +223,9 @@ fetch_register (struct regcache *regcache, int regno)
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
errno = 0;
val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0);
@@ -269,18 +269,19 @@ store_register (const struct regcache *regcache, int regno)
static void
hppa_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (-1 == regno)
{
for (regno = 0;
regno < gdbarch_num_regs (get_regcache_arch (regcache));
regno++)
- fetch_register (regcache, regno);
+ fetch_register (regcache, ptid, regno);
}
else
{
- fetch_register (regcache, regno);
+ fetch_register (regcache, ptid, regno);
}
}
diff --git a/gdb/hppa-nbsd-nat.c b/gdb/hppa-nbsd-nat.c
index 200bc6881e..caf71dac02 100644
--- a/gdb/hppa-nbsd-nat.c
+++ b/gdb/hppa-nbsd-nat.c
@@ -160,14 +160,15 @@ hppanbsd_collect_fpregset (struct regcache *regcache,
static void
hppanbsd_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1 || hppanbsd_gregset_supplies_p (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -178,7 +179,7 @@ hppanbsd_fetch_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
@@ -191,19 +192,20 @@ hppanbsd_fetch_registers (struct target_ops *ops,
static void
hppanbsd_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1 || hppanbsd_gregset_supplies_p (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
hppanbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
@@ -212,13 +214,13 @@ hppanbsd_store_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
hppanbsd_collect_fpregset (regcache, &fpregs, regnum);
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
diff --git a/gdb/hppa-obsd-nat.c b/gdb/hppa-obsd-nat.c
index 66af86b0f7..9be12d05e2 100644
--- a/gdb/hppa-obsd-nat.c
+++ b/gdb/hppa-obsd-nat.c
@@ -187,13 +187,14 @@ hppaobsd_collect_fpregset (struct regcache *regcache,
static void
hppaobsd_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1 || hppaobsd_gregset_supplies_p (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -204,7 +205,7 @@ hppaobsd_fetch_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
@@ -217,19 +218,20 @@ hppaobsd_fetch_registers (struct target_ops *ops,
static void
hppaobsd_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1 || hppaobsd_gregset_supplies_p (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
hppaobsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
@@ -238,13 +240,13 @@ hppaobsd_store_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
hppaobsd_collect_fpregset (regcache, &fpregs, regnum);
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
diff --git a/gdb/i386-bsd-nat.c b/gdb/i386-bsd-nat.c
index 186856cc5f..8e5437c4ba 100644
--- a/gdb/i386-bsd-nat.c
+++ b/gdb/i386-bsd-nat.c
@@ -129,13 +129,14 @@ i386bsd_collect_gregset (const struct regcache *regcache,
static void
i386bsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1 || GETREGS_SUPPLIES (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -157,7 +158,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
void *xstateregs;
xstateregs = alloca (x86bsd_xsave_len);
- if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETXSTATE, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
perror_with_name (_("Couldn't get extended state status"));
@@ -168,7 +169,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
#ifdef HAVE_PT_GETXMMREGS
if (have_ptrace_xmmregs != 0
- && ptrace(PT_GETXMMREGS, get_ptrace_pid (inferior_ptid),
+ && ptrace(PT_GETXMMREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
{
have_ptrace_xmmregs = 1;
@@ -178,7 +179,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
{
have_ptrace_xmmregs = 0;
#endif
- if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
@@ -194,19 +195,20 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
static void
i386bsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1 || GETREGS_SUPPLIES (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
i386bsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
@@ -227,13 +229,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
void *xstateregs;
xstateregs = alloca (x86bsd_xsave_len);
- if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETXSTATE, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
perror_with_name (_("Couldn't get extended state status"));
i387_collect_xsave (regcache, -1, xstateregs, 0);
- if (ptrace (PT_SETXSTATE, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETXSTATE, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1)
perror_with_name (_("Couldn't write extended state status"));
return;
@@ -242,14 +244,14 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
#ifdef HAVE_PT_GETXMMREGS
if (have_ptrace_xmmregs != 0
- && ptrace(PT_GETXMMREGS, get_ptrace_pid (inferior_ptid),
+ && ptrace(PT_GETXMMREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
{
have_ptrace_xmmregs = 1;
i387_collect_fxsave (regcache, regnum, xmmregs);
- if (ptrace (PT_SETXMMREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETXMMREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == -1)
perror_with_name (_("Couldn't write XMM registers"));
}
@@ -257,13 +259,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
{
have_ptrace_xmmregs = 0;
#endif
- if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
i387_collect_fsave (regcache, regnum, &fpregs);
- if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
#ifdef HAVE_PT_GETXMMREGS
diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index 4bffe6d74e..9cabc3f111 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -48,9 +48,10 @@
Otherwise, REGNO specifies which register (so we can save time). */
static void
i386_darwin_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
- thread_t current_thread = ptid_get_tid (inferior_ptid);
+ thread_t current_thread = ptid_get_tid (ptid);
int fetched = 0;
struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -165,9 +166,10 @@ i386_darwin_fetch_inferior_registers (struct target_ops *ops,
static void
i386_darwin_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
- thread_t current_thread = ptid_get_tid (inferior_ptid);
+ thread_t current_thread = ptid_get_tid (ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
#ifdef BFD64
diff --git a/gdb/i386-gnu-nat.c b/gdb/i386-gnu-nat.c
index 6953eeb78e..fe47934e97 100644
--- a/gdb/i386-gnu-nat.c
+++ b/gdb/i386-gnu-nat.c
@@ -88,7 +88,8 @@ fetch_fpregs (struct regcache *regcache, struct proc *thread)
/* Fetch register REGNO, or all regs if REGNO is -1. */
static void
gnu_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct proc *thread;
@@ -96,10 +97,10 @@ gnu_fetch_registers (struct target_ops *ops,
inf_update_procs (gnu_current_inf);
thread = inf_tid_to_thread (gnu_current_inf,
- ptid_get_lwp (inferior_ptid));
+ ptid_get_lwp (ptid));
if (!thread)
error (_("Can't fetch registers from thread %s: No such thread"),
- target_pid_to_str (inferior_ptid));
+ target_pid_to_str (ptid));
if (regno < I386_NUM_GREGS || regno == -1)
{
@@ -180,7 +181,8 @@ store_fpregs (const struct regcache *regcache, struct proc *thread, int regno)
/* Store at least register REGNO, or all regs if REGNO == -1. */
static void
gnu_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct proc *thread;
struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -189,10 +191,10 @@ gnu_store_registers (struct target_ops *ops,
inf_update_procs (gnu_current_inf);
thread = inf_tid_to_thread (gnu_current_inf,
- ptid_get_lwp (inferior_ptid));
+ ptid_get_lwp (ptid));
if (!thread)
error (_("Couldn't store registers into thread %s: No such thread"),
- target_pid_to_str (inferior_ptid));
+ target_pid_to_str (ptid));
if (regno < I386_NUM_GREGS || regno == -1)
{
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 2c4963b5f4..7602f80529 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -92,7 +92,7 @@ int have_ptrace_getfpxregs =
/* Fetch one register. */
static void
-fetch_register (struct regcache *regcache, int regno)
+fetch_register (struct regcache *regcache, ptid_t ptid, int regno)
{
int tid;
int val;
@@ -105,9 +105,9 @@ fetch_register (struct regcache *regcache, int regno)
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
errno = 0;
val = ptrace (PTRACE_PEEKUSER, tid,
@@ -453,7 +453,8 @@ store_fpxregs (const struct regcache *regcache, int tid, int regno)
static void
i386_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
int tid;
@@ -465,15 +466,15 @@ i386_linux_fetch_inferior_registers (struct target_ops *ops,
for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
if (regno == -1 || regno == i)
- fetch_register (regcache, i);
+ fetch_register (regcache, ptid, i);
return;
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
/* Use the PTRACE_GETFPXREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
@@ -486,7 +487,7 @@ i386_linux_fetch_inferior_registers (struct target_ops *ops,
/* The call above might reset `have_ptrace_getregs'. */
if (!have_ptrace_getregs)
{
- i386_linux_fetch_inferior_registers (ops, regcache, regno);
+ i386_linux_fetch_inferior_registers (ops, regcache, ptid, regno);
return;
}
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index e26dd15025..da3fdaecf6 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -690,7 +690,7 @@ ia64_linux_can_use_hw_breakpoint (struct target_ops *self,
/* Fetch register REGNUM from the inferior. */
static void
-ia64_linux_fetch_register (struct regcache *regcache, int regnum)
+ia64_linux_fetch_register (struct regcache *regcache, ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR addr;
@@ -737,9 +737,9 @@ ia64_linux_fetch_register (struct regcache *regcache, int regnum)
/* Cater for systems like GNU/Linux, that implement threads as
separate processes. */
- pid = ptid_get_lwp (inferior_ptid);
+ pid = ptid_get_lwp (ptid);
if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = ptid_get_pid (ptid);
/* This isn't really an address, but ptrace thinks of it as one. */
addr = ia64_register_addr (gdbarch, regnum);
@@ -768,15 +768,16 @@ ia64_linux_fetch_register (struct regcache *regcache, int regnum)
static void
ia64_linux_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1)
for (regnum = 0;
regnum < gdbarch_num_regs (get_regcache_arch (regcache));
regnum++)
- ia64_linux_fetch_register (regcache, regnum);
+ ia64_linux_fetch_register (regcache, ptid, regnum);
else
- ia64_linux_fetch_register (regcache, regnum);
+ ia64_linux_fetch_register (regcache, ptid, regnum);
}
/* Store register REGNUM into the inferior. */
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index b04b52e9b0..49445dd688 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -72,7 +72,8 @@ store_waitstatus (struct target_waitstatus *ourstatus, int hoststatus)
static void
inf_child_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1)
{
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 215787425f..3cc6a133fd 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -706,7 +706,7 @@ static CORE_ADDR (*inf_ptrace_register_u_offset)(struct gdbarch *, int, int);
/* Fetch register REGNUM from the inferior. */
static void
-inf_ptrace_fetch_register (struct regcache *regcache, int regnum)
+inf_ptrace_fetch_register (struct regcache *regcache, ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR addr;
@@ -725,9 +725,9 @@ inf_ptrace_fetch_register (struct regcache *regcache, int regnum)
/* Cater for systems like GNU/Linux, that implement threads as
separate processes. */
- pid = ptid_get_lwp (inferior_ptid);
+ pid = ptid_get_lwp (ptid);
if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = ptid_get_pid (ptid);
size = register_size (gdbarch, regnum);
gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
@@ -752,16 +752,16 @@ inf_ptrace_fetch_register (struct regcache *regcache, int regnum)
for all registers. */
static void
-inf_ptrace_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+inf_ptrace_fetch_registers (struct target_ops *ops, struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1)
for (regnum = 0;
regnum < gdbarch_num_regs (get_regcache_arch (regcache));
regnum++)
- inf_ptrace_fetch_register (regcache, regnum);
+ inf_ptrace_fetch_register (regcache, ptid, regnum);
else
- inf_ptrace_fetch_register (regcache, regnum);
+ inf_ptrace_fetch_register (regcache, ptid, regnum);
}
/* Store register REGNUM into the inferior. */
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 1a3e48d83d..6021d94731 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -1692,9 +1692,11 @@ linux_corefile_thread (struct thread_info *info,
regcache = get_thread_arch_regcache (info->ptid, args->gdbarch);
+ /* We need to save/restore inferior_ptid as long as linux_get_siginfo_data
+ depends on it. */
old_chain = save_inferior_ptid ();
inferior_ptid = info->ptid;
- target_fetch_registers (regcache, -1);
+ target_fetch_registers (regcache, info->ptid, -1);
siginfo_data = linux_get_siginfo_data (args->gdbarch, &siginfo_size);
do_cleanups (old_chain);
diff --git a/gdb/m32r-linux-nat.c b/gdb/m32r-linux-nat.c
index 9d9bef385e..ff47bf735f 100644
--- a/gdb/m32r-linux-nat.c
+++ b/gdb/m32r-linux-nat.c
@@ -192,14 +192,15 @@ fill_fpregset (const struct regcache *regcache,
static void
m32r_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
int tid;
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
/* Use the PTRACE_GETREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
@@ -219,13 +220,14 @@ m32r_linux_fetch_inferior_registers (struct target_ops *ops,
registers). */
static void
m32r_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
int tid;
/* GNU/Linux LWP ID's are process ID's. */
- if ((tid = ptid_get_lwp (inferior_ptid)) == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ if ((tid = ptid_get_lwp (ptid)) == 0)
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
/* Use the PTRACE_SETREGS request whenever possible, since it
transfers more registers in one system call. */
diff --git a/gdb/m68k-bsd-nat.c b/gdb/m68k-bsd-nat.c
index 227da382e6..a4b745aae0 100644
--- a/gdb/m68k-bsd-nat.c
+++ b/gdb/m68k-bsd-nat.c
@@ -109,13 +109,14 @@ m68kbsd_collect_fpregset (struct regcache *regcache,
static void
m68kbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -126,7 +127,7 @@ m68kbsd_fetch_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
@@ -139,19 +140,20 @@ m68kbsd_fetch_inferior_registers (struct target_ops *ops,
static void
m68kbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
m68kbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
@@ -160,13 +162,13 @@ m68kbsd_store_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
m68kbsd_collect_fpregset (regcache, &fpregs, regnum);
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
diff --git a/gdb/m68k-linux-nat.c b/gdb/m68k-linux-nat.c
index e5182caf39..d7403e5e72 100644
--- a/gdb/m68k-linux-nat.c
+++ b/gdb/m68k-linux-nat.c
@@ -100,7 +100,7 @@ static int have_ptrace_getregs =
/* Fetch one register. */
static void
-fetch_register (struct regcache *regcache, int regno)
+fetch_register (struct regcache *regcache, ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
long regaddr, val;
@@ -109,9 +109,9 @@ fetch_register (struct regcache *regcache, int regno)
int tid;
/* Overload thread id onto process id. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* no thread id, just use
+ tid = ptid_get_pid (ptid); /* no thread id, just use
process id. */
regaddr = 4 * regmap[regno];
@@ -134,11 +134,11 @@ fetch_register (struct regcache *regcache, int regno)
Otherwise, REGNO specifies which register (so we can save time). */
static void
-old_fetch_inferior_registers (struct regcache *regcache, int regno)
+old_fetch_inferior_registers (struct regcache *regcache, ptid_t ptid, int regno)
{
if (regno >= 0)
{
- fetch_register (regcache, regno);
+ fetch_register (regcache, ptid, regno);
}
else
{
@@ -146,7 +146,7 @@ old_fetch_inferior_registers (struct regcache *regcache, int regno)
regno < gdbarch_num_regs (get_regcache_arch (regcache));
regno++)
{
- fetch_register (regcache, regno);
+ fetch_register (regcache, ptid, regno);
}
}
}
@@ -404,7 +404,8 @@ static void store_fpregs (const struct regcache *regcache, int tid, int regno)
static void
m68k_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
int tid;
@@ -412,14 +413,14 @@ m68k_linux_fetch_inferior_registers (struct target_ops *ops,
GETREGS request isn't available. */
if (! have_ptrace_getregs)
{
- old_fetch_inferior_registers (regcache, regno);
+ old_fetch_inferior_registers (regcache, ptid, regno);
return;
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
/* Use the PTRACE_GETFPXREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
@@ -432,7 +433,7 @@ m68k_linux_fetch_inferior_registers (struct target_ops *ops,
/* The call above might reset `have_ptrace_getregs'. */
if (! have_ptrace_getregs)
{
- old_fetch_inferior_registers (regcache, -1);
+ old_fetch_inferior_registers (regcache, ptid, -1);
return;
}
diff --git a/gdb/m88k-bsd-nat.c b/gdb/m88k-bsd-nat.c
index 72d3630710..895b6c85d3 100644
--- a/gdb/m88k-bsd-nat.c
+++ b/gdb/m88k-bsd-nat.c
@@ -64,11 +64,12 @@ m88kbsd_collect_gregset (const struct regcache *regcache,
static void
m88kbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -80,17 +81,18 @@ m88kbsd_fetch_inferior_registers (struct target_ops *ops,
static void
m88kbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
m88kbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
diff --git a/gdb/mips-fbsd-nat.c b/gdb/mips-fbsd-nat.c
index 0472df88f4..f8bce008c1 100644
--- a/gdb/mips-fbsd-nat.c
+++ b/gdb/mips-fbsd-nat.c
@@ -45,14 +45,15 @@ getregs_supplies (struct gdbarch *gdbarch, int regnum)
static void
mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regnum == -1 || getregs_supplies (gdbarch, regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -66,7 +67,7 @@ mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
@@ -80,21 +81,22 @@ mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
static void
mips_fbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regnum == -1 || getregs_supplies (gdbarch, regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
mips_fbsd_collect_gregs (regcache, regnum, (char *) ®s,
sizeof (register_t));
- if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
@@ -107,14 +109,14 @@ mips_fbsd_store_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
mips_fbsd_collect_fpregs (regcache, regnum, (char *) &fpregs,
sizeof (f_register_t));
- if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, get_ptrace_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 9d22773e9c..f9b6e1b2fc 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -54,7 +54,7 @@ static int have_ptrace_regsets = 1;
PTRACE_PEEKUSER and PTRACE_POKEUSER. */
static void (*super_fetch_registers) (struct target_ops *,
- struct regcache *, int);
+ struct regcache *, ptid_t, int);
static void (*super_store_registers) (struct target_ops *,
struct regcache *, int);
@@ -214,7 +214,8 @@ fill_fpregset (const struct regcache *regcache,
static void
mips64_linux_regsets_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int is_fp, is_dsp;
@@ -244,9 +245,9 @@ mips64_linux_regsets_fetch_registers (struct target_ops *ops,
else
is_dsp = 0;
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ tid = ptid_get_pid (ptid);
if (regno == -1 || (!is_fp && !is_dsp))
{
@@ -286,14 +287,15 @@ mips64_linux_regsets_fetch_registers (struct target_ops *ops,
}
if (is_dsp)
- super_fetch_registers (ops, regcache, regno);
+ super_fetch_registers (ops, regcache, ptid, regno);
else if (regno == -1 && have_dsp)
{
for (regi = mips_regnum (gdbarch)->dspacc;
regi < mips_regnum (gdbarch)->dspacc + 6;
regi++)
- super_fetch_registers (ops, regcache, regi);
- super_fetch_registers (ops, regcache, mips_regnum (gdbarch)->dspctl);
+ super_fetch_registers (ops, regcache, ptid, regi);
+ super_fetch_registers (ops, regcache, ptid,
+ mips_regnum (gdbarch)->dspctl);
}
}
@@ -381,16 +383,17 @@ mips64_linux_regsets_store_registers (struct target_ops *ops,
static void
mips64_linux_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
/* Unless we already know that PTRACE_GETREGS does not work, try it. */
if (have_ptrace_regsets)
- mips64_linux_regsets_fetch_registers (ops, regcache, regnum);
+ mips64_linux_regsets_fetch_registers (ops, regcache, ptid, regnum);
/* If we know, or just found out, that PTRACE_GETREGS does not work, fall
back to PTRACE_PEEKUSER. */
if (!have_ptrace_regsets)
- super_fetch_registers (ops, regcache, regnum);
+ super_fetch_registers (ops, regcache, ptid, regnum);
}
/* Store REGNO (or all registers if REGNO == -1) to the target
diff --git a/gdb/mips-nbsd-nat.c b/gdb/mips-nbsd-nat.c
index b7c19dc85f..a111e9ceda 100644
--- a/gdb/mips-nbsd-nat.c
+++ b/gdb/mips-nbsd-nat.c
@@ -40,14 +40,15 @@ getregs_supplies (struct gdbarch *gdbarch, int regno)
static void
mipsnbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regno == -1 || getregs_supplies (gdbarch, regno))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -61,7 +62,7 @@ mipsnbsd_fetch_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
@@ -71,20 +72,21 @@ mipsnbsd_fetch_inferior_registers (struct target_ops *ops,
static void
mipsnbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regno == -1 || getregs_supplies (gdbarch, regno))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
mipsnbsd_fill_reg (regcache, (char *) ®s, regno);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
@@ -97,13 +99,13 @@ mipsnbsd_store_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
mipsnbsd_fill_fpreg (regcache, (char *) &fpregs, regno);
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
diff --git a/gdb/mips64-obsd-nat.c b/gdb/mips64-obsd-nat.c
index 97af421981..b69e049539 100644
--- a/gdb/mips64-obsd-nat.c
+++ b/gdb/mips64-obsd-nat.c
@@ -79,11 +79,12 @@ mips64obsd_collect_gregset (const struct regcache *regcache,
static void
mips64obsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -95,17 +96,18 @@ mips64obsd_fetch_inferior_registers (struct target_ops *ops,
static void
mips64obsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
mips64obsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 13b5ccf99f..f1994c5d8d 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -857,7 +857,8 @@ procfs_wait (struct target_ops *ops,
and update gdb's idea of their current values. */
static void
procfs_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
union
{
@@ -868,7 +869,7 @@ procfs_fetch_registers (struct target_ops *ops,
reg;
int regsize;
- procfs_set_thread (inferior_ptid);
+ procfs_set_thread (ptid);
if (devctl (ctl_fd, DCMD_PROC_GETGREG, ®, sizeof (reg), ®size) == EOK)
nto_supply_gregset (regcache, (char *) ®.greg);
if (devctl (ctl_fd, DCMD_PROC_GETFPREG, ®, sizeof (reg), ®size)
@@ -1338,7 +1339,8 @@ get_regset (int regset, char *buf, int bufsize, int *regsize)
static void
procfs_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
union
{
@@ -1351,9 +1353,9 @@ procfs_store_registers (struct target_ops *ops,
int len, regset, regsize, dev_set, err;
char *data;
- if (ptid_equal (inferior_ptid, null_ptid))
+ if (ptid_equal (ptid, null_ptid))
return;
- procfs_set_thread (inferior_ptid);
+ procfs_set_thread (ptid);
if (regno == -1)
{
diff --git a/gdb/ppc-fbsd-nat.c b/gdb/ppc-fbsd-nat.c
index 823c063643..c96113b29f 100644
--- a/gdb/ppc-fbsd-nat.c
+++ b/gdb/ppc-fbsd-nat.c
@@ -117,11 +117,12 @@ getfpregs_supplies (struct gdbarch *gdbarch, int regno)
static void
ppcfbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
gdb_gregset_t regs;
- if (ptrace (PT_GETREGS, ptid_get_lwp (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_lwp (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -132,7 +133,7 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops,
const struct regset *fpregset = ppc_fbsd_fpregset ();
gdb_fpregset_t fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_lwp (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_lwp (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
@@ -145,17 +146,18 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops,
static void
ppcfbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
gdb_gregset_t regs;
- if (ptrace (PT_GETREGS, ptid_get_lwp (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_lwp (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
fill_gregset (regcache, ®s, regno);
- if (ptrace (PT_SETREGS, ptid_get_lwp (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_lwp (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
@@ -163,13 +165,13 @@ ppcfbsd_store_inferior_registers (struct target_ops *ops,
{
gdb_fpregset_t fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_lwp (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_lwp (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
fill_fpregset (regcache, &fpregs, regno);
- if (ptrace (PT_SETFPREGS, ptid_get_lwp (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_lwp (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't set FP registers"));
}
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index a56d154d31..e7070ccd37 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -807,14 +807,15 @@ fetch_ppc_registers (struct regcache *regcache, int tid)
point registers depending upon the value of regno. */
static void
ppc_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
/* Overload thread id onto process id. */
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (ptid);
/* No thread id, just use process id. */
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ tid = ptid_get_pid (ptid);
if (regno == -1)
fetch_ppc_registers (regcache, tid);
diff --git a/gdb/ppc-nbsd-nat.c b/gdb/ppc-nbsd-nat.c
index 21d927cc14..f2b837b3c0 100644
--- a/gdb/ppc-nbsd-nat.c
+++ b/gdb/ppc-nbsd-nat.c
@@ -78,7 +78,8 @@ getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
static void
ppcnbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -86,7 +87,7 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops,
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -98,7 +99,7 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
diff --git a/gdb/ppc-obsd-nat.c b/gdb/ppc-obsd-nat.c
index 1a39e46295..0bb6f9f5d2 100644
--- a/gdb/ppc-obsd-nat.c
+++ b/gdb/ppc-obsd-nat.c
@@ -72,11 +72,12 @@ getfpregs_supplies (struct gdbarch *gdbarch, int regnum)
static void
ppcobsd_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -93,7 +94,7 @@ ppcobsd_fetch_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
diff --git a/gdb/ppc-ravenscar-thread.c b/gdb/ppc-ravenscar-thread.c
index 795dae7a4d..9f518c2b53 100644
--- a/gdb/ppc-ravenscar-thread.c
+++ b/gdb/ppc-ravenscar-thread.c
@@ -145,7 +145,7 @@ register_in_thread_descriptor_p (const struct ravenscar_reg_info *reg_info,
static void
ppc_ravenscar_generic_fetch_registers
(const struct ravenscar_reg_info *reg_info,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache, ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
const int num_regs = gdbarch_num_regs (gdbarch);
@@ -154,7 +154,7 @@ ppc_ravenscar_generic_fetch_registers
CORE_ADDR thread_descriptor_address;
/* The tid is the thread_id field, which is a pointer to the thread. */
- thread_descriptor_address = (CORE_ADDR) ptid_get_tid (inferior_ptid);
+ thread_descriptor_address = (CORE_ADDR) ptid_get_tid (ptid);
/* Read registers. */
for (current_regnum = 0; current_regnum < num_regs; current_regnum++)
@@ -215,9 +215,10 @@ static const struct ravenscar_reg_info ppc_reg_info =
for most PowerPC targets. */
static void
-ppc_ravenscar_powerpc_fetch_registers (struct regcache *regcache, int regnum)
+ppc_ravenscar_powerpc_fetch_registers (struct regcache *regcache, ptid_t ptid,
+ int regnum)
{
- ppc_ravenscar_generic_fetch_registers (&ppc_reg_info, regcache, regnum);
+ ppc_ravenscar_generic_fetch_registers (&ppc_reg_info, regcache, ptid, regnum);
}
/* Implement the to_store_registers ravenscar_arch_ops method
@@ -258,9 +259,11 @@ static const struct ravenscar_reg_info e500_reg_info =
for E500 targets. */
static void
-ppc_ravenscar_e500_fetch_registers (struct regcache *regcache, int regnum)
+ppc_ravenscar_e500_fetch_registers (struct regcache *regcache, ptid_t ptid,
+ int regnum)
{
- ppc_ravenscar_generic_fetch_registers (&e500_reg_info, regcache, regnum);
+ ppc_ravenscar_generic_fetch_registers (&e500_reg_info, regcache, ptid,
+ regnum);
}
/* Implement the to_store_registers ravenscar_arch_ops method
diff --git a/gdb/proc-service.c b/gdb/proc-service.c
index d39830cb69..188ad55157 100644
--- a/gdb/proc-service.c
+++ b/gdb/proc-service.c
@@ -158,16 +158,13 @@ ps_pdwrite (gdb_ps_prochandle_t ph, psaddr_t addr,
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;
+ ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
-
- target_fetch_registers (regcache, -1);
+ regcache = get_thread_arch_regcache (ptid, target_gdbarch ());
+ target_fetch_registers (regcache, ptid, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
- do_cleanups (old_chain);
return PS_OK;
}
@@ -197,16 +194,13 @@ ps_err_e
ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
gdb_prfpregset_t *fpregset)
{
- struct cleanup *old_chain = save_inferior_ptid ();
struct regcache *regcache;
+ ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
-
- target_fetch_registers (regcache, -1);
+ regcache = get_thread_arch_regcache (ptid, target_gdbarch ());
+ target_fetch_registers (regcache, ptid, -1);
fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
- do_cleanups (old_chain);
return PS_OK;
}
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 2269016ce8..c7b7dab1d4 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -115,7 +115,7 @@ static void procfs_resume (struct target_ops *,
static void procfs_interrupt (struct target_ops *self, ptid_t);
static void procfs_files_info (struct target_ops *);
static void procfs_fetch_registers (struct target_ops *,
- struct regcache *, int);
+ struct regcache *, ptid_t, int);
static void procfs_store_registers (struct target_ops *,
struct regcache *, int);
static void procfs_pass_signals (struct target_ops *self,
@@ -3215,19 +3215,20 @@ do_detach (int signo)
static void
procfs_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
gdb_gregset_t *gregs;
procinfo *pi;
- int pid = ptid_get_pid (inferior_ptid);
- int tid = ptid_get_lwp (inferior_ptid);
+ int pid = ptid_get_pid (ptid);
+ int tid = ptid_get_lwp (ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
pi = find_procinfo_or_die (pid, tid);
if (pi == NULL)
error (_("procfs: fetch_registers failed to find procinfo for %s"),
- target_pid_to_str (inferior_ptid));
+ target_pid_to_str (ptid));
gregs = proc_get_gregs (pi);
if (gregs == NULL)
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index d44c9810f6..12a4eab269 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -57,8 +57,6 @@ static ptid_t ravenscar_running_thread (void);
static char *ravenscar_extra_thread_info (struct target_ops *self,
struct thread_info *tp);
static int ravenscar_thread_alive (struct target_ops *ops, ptid_t ptid);
-static void ravenscar_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum);
static void ravenscar_store_registers (struct target_ops *ops,
struct regcache *regcache, int regnum);
static void ravenscar_prepare_to_store (struct target_ops *self,
@@ -264,22 +262,22 @@ ravenscar_pid_to_str (struct target_ops *ops, ptid_t ptid)
}
static void
-ravenscar_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ravenscar_fetch_registers (struct target_ops *ops, struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct target_ops *beneath = find_target_beneath (ops);
if (!ravenscar_runtime_initialized ()
- || ptid_equal (inferior_ptid, base_magic_null_ptid)
- || ptid_equal (inferior_ptid, ravenscar_running_thread ()))
- beneath->to_fetch_registers (beneath, regcache, regnum);
+ || ptid_equal (ptid, base_magic_null_ptid)
+ || ptid_equal (ptid, ravenscar_running_thread ()))
+ beneath->to_fetch_registers (beneath, regcache, ptid, regnum);
else
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct ravenscar_arch_ops *arch_ops
= gdbarch_ravenscar_ops (gdbarch);
- arch_ops->to_fetch_registers (regcache, regnum);
+ arch_ops->to_fetch_registers (regcache, ptid, regnum);
}
}
diff --git a/gdb/ravenscar-thread.h b/gdb/ravenscar-thread.h
index 9497d0f98a..2413153010 100644
--- a/gdb/ravenscar-thread.h
+++ b/gdb/ravenscar-thread.h
@@ -24,7 +24,7 @@
struct ravenscar_arch_ops
{
- void (*to_fetch_registers) (struct regcache *, int);
+ void (*to_fetch_registers) (struct regcache *, ptid_t, int);
void (*to_store_registers) (struct regcache *, int);
void (*to_prepare_to_store) (struct regcache *);
};
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index f7683f237f..3f6cc85947 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1420,12 +1420,13 @@ record_btrace_remove_breakpoint (struct target_ops *ops,
static void
record_btrace_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct btrace_insn_iterator *replay;
struct thread_info *tp;
- tp = find_thread_ptid (inferior_ptid);
+ tp = find_thread_ptid (ptid);
gdb_assert (tp != NULL);
replay = tp->btrace.replay;
@@ -1453,7 +1454,7 @@ record_btrace_fetch_registers (struct target_ops *ops,
{
struct target_ops *t = ops->beneath;
- t->to_fetch_registers (t, regcache, regno);
+ t->to_fetch_registers (t, regcache, ptid, regno);
}
}
diff --git a/gdb/record-full.c b/gdb/record-full.c
index bd95acc6b1..0b04f0fbb7 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -796,7 +796,7 @@ record_full_core_open_1 (const char *name, int from_tty)
int i;
/* Get record_full_core_regbuf. */
- target_fetch_registers (regcache, -1);
+ target_fetch_registers (regcache, inferior_ptid, -1);
record_full_core_regbuf = (gdb_byte *) xmalloc (MAX_REGISTER_SIZE * regnum);
for (i = 0; i < regnum; i ++)
regcache_raw_collect (regcache, i,
@@ -2045,7 +2045,7 @@ record_full_core_kill (struct target_ops *ops)
static void
record_full_core_fetch_registers (struct target_ops *ops,
struct regcache *regcache,
- int regno)
+ ptid_t ptid, int regno)
{
if (regno < 0)
{
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 0728a03b65..bdf0bcbc82 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -659,7 +659,7 @@ regcache_raw_update (struct regcache *regcache, int regnum)
struct cleanup *old_chain = save_inferior_ptid ();
inferior_ptid = regcache->ptid;
- target_fetch_registers (regcache, regnum);
+ target_fetch_registers (regcache, inferior_ptid, regnum);
do_cleanups (old_chain);
/* A number of targets can't access the whole set of raw
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index b0c68c617e..609ae84fac 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -426,16 +426,18 @@ one2one_register_sim_regno (struct gdbarch *gdbarch, int regnum)
static void
gdbsim_fetch_register (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct inferior *inf = find_inferior_ptid (ptid);
struct sim_inferior_data *sim_data
- = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
+ = get_sim_inferior_data (inf, SIM_INSTANCE_NEEDED);
if (regno == -1)
{
for (regno = 0; regno < gdbarch_num_regs (gdbarch); regno++)
- gdbsim_fetch_register (ops, regcache, regno);
+ gdbsim_fetch_register (ops, regcache, ptid, regno);
return;
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 2f34c4c300..b1b1c58038 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -7704,14 +7704,14 @@ set_remote_traceframe (void)
}
static void
-remote_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+remote_fetch_registers (struct target_ops *ops, struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct remote_arch_state *rsa = get_remote_arch_state ();
int i;
set_remote_traceframe ();
- set_general_thread (inferior_ptid);
+ set_general_thread (ptid);
if (regnum >= 0)
{
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index f42847bfea..7362df9580 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -159,7 +159,7 @@ rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf)
/* Fetch register REGNO from the inferior. */
static void
-fetch_register (struct regcache *regcache, int regno)
+fetch_register (struct regcache *regcache, ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE];
@@ -172,7 +172,7 @@ fetch_register (struct regcache *regcache, int regno)
/* Floating-point registers. */
if (isfloat)
- rs6000_ptrace32 (PT_READ_FPR, ptid_get_pid (inferior_ptid), addr, nr, 0);
+ rs6000_ptrace32 (PT_READ_FPR, ptid_get_pid (ptid), addr, nr, 0);
/* Bogus register number. */
else if (nr < 0)
@@ -188,14 +188,14 @@ fetch_register (struct regcache *regcache, int regno)
else
{
if (!ARCH64 ())
- *addr = rs6000_ptrace32 (PT_READ_GPR, ptid_get_pid (inferior_ptid),
+ *addr = rs6000_ptrace32 (PT_READ_GPR, ptid_get_pid (ptid),
(int *) nr, 0, 0);
else
{
/* PT_READ_GPR requires the buffer parameter to point to long long,
even if the register is really only 32 bits. */
long long buf;
- rs6000_ptrace64 (PT_READ_GPR, ptid_get_pid (inferior_ptid),
+ rs6000_ptrace64 (PT_READ_GPR, ptid_get_pid (ptid),
nr, 0, &buf);
if (register_size (gdbarch, regno) == 8)
memcpy (addr, &buf, 8);
@@ -281,11 +281,12 @@ store_register (struct regcache *regcache, int regno)
static void
rs6000_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regno != -1)
- fetch_register (regcache, regno);
+ fetch_register (regcache, ptid, regno);
else
{
@@ -296,25 +297,25 @@ rs6000_fetch_inferior_registers (struct target_ops *ops,
regno < tdep->ppc_gp0_regnum + ppc_num_gprs;
regno++)
{
- fetch_register (regcache, regno);
+ fetch_register (regcache, ptid, regno);
}
/* Read general purpose floating point registers. */
if (tdep->ppc_fp0_regnum >= 0)
for (regno = 0; regno < ppc_num_fprs; regno++)
- fetch_register (regcache, tdep->ppc_fp0_regnum + regno);
+ fetch_register (regcache, ptid, tdep->ppc_fp0_regnum + regno);
/* Read special registers. */
- fetch_register (regcache, gdbarch_pc_regnum (gdbarch));
- fetch_register (regcache, tdep->ppc_ps_regnum);
- fetch_register (regcache, tdep->ppc_cr_regnum);
- fetch_register (regcache, tdep->ppc_lr_regnum);
- fetch_register (regcache, tdep->ppc_ctr_regnum);
- fetch_register (regcache, tdep->ppc_xer_regnum);
+ fetch_register (regcache, ptid, gdbarch_pc_regnum (gdbarch));
+ fetch_register (regcache, ptid, tdep->ppc_ps_regnum);
+ fetch_register (regcache, ptid, tdep->ppc_cr_regnum);
+ fetch_register (regcache, ptid, tdep->ppc_lr_regnum);
+ fetch_register (regcache, ptid, tdep->ppc_ctr_regnum);
+ fetch_register (regcache, ptid, tdep->ppc_xer_regnum);
if (tdep->ppc_fpscr_regnum >= 0)
- fetch_register (regcache, tdep->ppc_fpscr_regnum);
+ fetch_register (regcache, ptid, tdep->ppc_fpscr_regnum);
if (tdep->ppc_mq_regnum >= 0)
- fetch_register (regcache, tdep->ppc_mq_regnum);
+ fetch_register (regcache, ptid, tdep->ppc_mq_regnum);
}
}
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 3544588de6..1703844e08 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -376,9 +376,10 @@ check_regset (int tid, int regset, int regsize)
this for all registers. */
static void
s390_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
- int tid = s390_inferior_tid ();
+ int tid = s390_inferior_tid (ptid);
if (regnum == -1 || S390_IS_GREGSET_REGNUM (regnum))
fetch_regs (regcache, tid);
diff --git a/gdb/sh-nbsd-nat.c b/gdb/sh-nbsd-nat.c
index 90c9689899..d1ece86cdd 100644
--- a/gdb/sh-nbsd-nat.c
+++ b/gdb/sh-nbsd-nat.c
@@ -43,13 +43,14 @@
static void
shnbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno))
{
struct reg inferior_registers;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't get registers"));
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index a09a3ab9a8..56fdc96380 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -452,7 +452,8 @@ sol_thread_wait (struct target_ops *ops,
static void
sol_thread_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
thread_t thread;
td_thrhandle_t thandle;
@@ -463,15 +464,15 @@ sol_thread_fetch_registers (struct target_ops *ops,
gdb_fpregset_t *fpregset_p = &fpregset;
struct target_ops *beneath = find_target_beneath (ops);
- if (!ptid_tid_p (inferior_ptid))
+ if (!ptid_tid_p (ptid))
{
/* It's an LWP; pass the request on to the layer beneath. */
- beneath->to_fetch_registers (beneath, regcache, regnum);
+ beneath->to_fetch_registers (beneath, regcache, ptid, regnum);
return;
}
- /* Solaris thread: convert INFERIOR_PTID into a td_thrhandle_t. */
- thread = ptid_get_tid (inferior_ptid);
+ /* Solaris thread: convert PTID into a td_thrhandle_t. */
+ thread = ptid_get_tid (ptid);
if (thread == 0)
error (_("sol_thread_fetch_registers: thread == 0"));
diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c
index b058ccf1e7..b423ce5c40 100644
--- a/gdb/sparc-nat.c
+++ b/gdb/sparc-nat.c
@@ -135,7 +135,8 @@ sparc32_fpregset_supplies_p (struct gdbarch *gdbarch, int regnum)
void
sparc_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int pid;
@@ -153,9 +154,9 @@ sparc_fetch_inferior_registers (struct target_ops *ops,
These functions should instead be paramaterized with an explicit
object (struct regcache, struct thread_info?) into which the LWPs
registers can be written. */
- pid = ptid_get_lwp (inferior_ptid);
+ pid = ptid_get_lwp (ptid);
if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = ptid_get_pid (ptid);
if (regnum == SPARC_G0_REGNUM)
{
diff --git a/gdb/sparc-nat.h b/gdb/sparc-nat.h
index b598e197f1..bfa6961fe9 100644
--- a/gdb/sparc-nat.h
+++ b/gdb/sparc-nat.h
@@ -45,7 +45,7 @@ extern int sparc32_fpregset_supplies_p (struct gdbarch *gdbarch, int regnum);
extern struct target_ops *sparc_target (void);
extern void sparc_fetch_inferior_registers (struct target_ops *,
- struct regcache *, int);
+ struct regcache *, ptid_t, int);
extern void sparc_store_inferior_registers (struct target_ops *,
struct regcache *, int);
diff --git a/gdb/sparc-ravenscar-thread.c b/gdb/sparc-ravenscar-thread.c
index 89f960aa24..0573f8345d 100644
--- a/gdb/sparc-ravenscar-thread.c
+++ b/gdb/sparc-ravenscar-thread.c
@@ -25,8 +25,6 @@
#include "ravenscar-thread.h"
#include "sparc-ravenscar-thread.h"
-static void sparc_ravenscar_fetch_registers (struct regcache *regcache,
- int regnum);
static void sparc_ravenscar_store_registers (struct regcache *regcache,
int regnum);
static void sparc_ravenscar_prepare_to_store (struct regcache *regcache);
@@ -101,7 +99,8 @@ register_in_thread_descriptor_p (int regnum)
thread. */
static void
-sparc_ravenscar_fetch_registers (struct regcache *regcache, int regnum)
+sparc_ravenscar_fetch_registers (struct regcache *regcache, ptid_t ptid,
+ int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
const int sp_regnum = gdbarch_sp_regnum (gdbarch);
@@ -112,7 +111,7 @@ sparc_ravenscar_fetch_registers (struct regcache *regcache, int regnum)
ULONGEST stack_address;
/* The tid is the thread_id field, which is a pointer to the thread. */
- thread_descriptor_address = (CORE_ADDR) ptid_get_tid (inferior_ptid);
+ thread_descriptor_address = (CORE_ADDR) ptid_get_tid (ptid);
/* Read the saved SP in the context buffer. */
current_address = thread_descriptor_address
diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c
index b99a1a3de3..6516a10b76 100644
--- a/gdb/spu-multiarch.c
+++ b/gdb/spu-multiarch.c
@@ -140,8 +140,8 @@ spu_region_ok_for_hw_watchpoint (struct target_ops *self,
/* Override the to_fetch_registers routine. */
static void
-spu_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+spu_fetch_registers (struct target_ops *ops, struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
@@ -152,12 +152,12 @@ spu_fetch_registers (struct target_ops *ops,
/* This version applies only if we're currently in spu_run. */
if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
{
- ops_beneath->to_fetch_registers (ops_beneath, regcache, regno);
+ ops_beneath->to_fetch_registers (ops_beneath, regcache, ptid, regno);
return;
}
/* We must be stopped on a spu_run system call. */
- if (!parse_spufs_run (inferior_ptid, &spufs_fd, &spufs_addr))
+ if (!parse_spufs_run (ptid, &spufs_fd, &spufs_addr))
return;
/* The ID register holds the spufs file handle. */
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 470b7e44d8..01ab150e3a 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -159,28 +159,30 @@ debug_wait (struct target_ops *self, ptid_t arg1, struct target_waitstatus *arg2
}
static void
-delegate_fetch_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+delegate_fetch_registers (struct target_ops *self, struct regcache *arg1, ptid_t arg2, int arg3)
{
self = self->beneath;
- self->to_fetch_registers (self, arg1, arg2);
+ self->to_fetch_registers (self, arg1, arg2, arg3);
}
static void
-tdefault_fetch_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+tdefault_fetch_registers (struct target_ops *self, struct regcache *arg1, ptid_t arg2, int arg3)
{
}
static void
-debug_fetch_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+debug_fetch_registers (struct target_ops *self, struct regcache *arg1, ptid_t arg2, int arg3)
{
fprintf_unfiltered (gdb_stdlog, "-> %s->to_fetch_registers (...)\n", debug_target.to_shortname);
- debug_target.to_fetch_registers (&debug_target, arg1, arg2);
+ debug_target.to_fetch_registers (&debug_target, arg1, arg2, arg3);
fprintf_unfiltered (gdb_stdlog, "<- %s->to_fetch_registers (", debug_target.to_shortname);
target_debug_print_struct_target_ops_p (&debug_target);
fputs_unfiltered (", ", gdb_stdlog);
target_debug_print_struct_regcache_p (arg1);
fputs_unfiltered (", ", gdb_stdlog);
- target_debug_print_int (arg2);
+ target_debug_print_ptid_t (arg2);
+ fputs_unfiltered (", ", gdb_stdlog);
+ target_debug_print_int (arg3);
fputs_unfiltered (")\n", gdb_stdlog);
}
diff --git a/gdb/target.c b/gdb/target.c
index 0ff8515d3b..e57789f15f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3585,9 +3585,9 @@ debug_print_register (const char * func,
}
void
-target_fetch_registers (struct regcache *regcache, int regno)
+target_fetch_registers (struct regcache *regcache, ptid_t ptid, int regno)
{
- current_target.to_fetch_registers (¤t_target, regcache, regno);
+ current_target.to_fetch_registers (¤t_target, regcache, ptid, regno);
if (targetdebug)
debug_print_register ("target_fetch_registers", regcache, regno);
}
diff --git a/gdb/target.h b/gdb/target.h
index 943a0e2e1a..24a138ff67 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -468,7 +468,8 @@ struct target_ops
ptid_t, struct target_waitstatus *,
int TARGET_DEBUG_PRINTER (target_debug_print_options))
TARGET_DEFAULT_FUNC (default_target_wait);
- void (*to_fetch_registers) (struct target_ops *, struct regcache *, int)
+ void (*to_fetch_registers) (struct target_ops *, struct regcache *, ptid_t,
+ int)
TARGET_DEFAULT_IGNORE ();
void (*to_store_registers) (struct target_ops *, struct regcache *, int)
TARGET_DEFAULT_NORETURN (noprocess ());
@@ -1380,9 +1381,11 @@ extern ptid_t default_target_wait (struct target_ops *ops,
struct target_waitstatus *status,
int options);
-/* Fetch at least register REGNO, or all regs if regno == -1. No result. */
+/* Fetch at least register REGNO of thread PTID from the target and store it in
+ REGCACHE. Fetch all registers if REGNO == -1. */
-extern void target_fetch_registers (struct regcache *regcache, int regno);
+extern void target_fetch_registers (struct regcache *regcache, ptid_t ptid,
+ int regno);
/* Store at least register REGNO, or all regs if REGNO == -1.
It can store as many registers as it wants to, so target_prepare_to_store
diff --git a/gdb/tilegx-linux-nat.c b/gdb/tilegx-linux-nat.c
index c0833cf74b..5c47a3e075 100644
--- a/gdb/tilegx-linux-nat.c
+++ b/gdb/tilegx-linux-nat.c
@@ -123,14 +123,15 @@ fill_fpregset (const struct regcache *regcache,
static void
fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
elf_gregset_t regs;
int tid;
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ tid = ptid_get_pid (ptid);
if (ptrace (PTRACE_GETREGS, tid, 0, (PTRACE_TYPE_ARG3) ®s) < 0)
perror_with_name (_("Couldn't get registers"));
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index dbcd65d5df..268392993e 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -848,8 +848,8 @@ traceframe_find_block_type (char type_wanted, int pos)
requested register from it. */
static void
-tfile_fetch_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+tfile_fetch_registers (struct target_ops *ops, struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int offset, regn, regsize, dummy;
diff --git a/gdb/vax-bsd-nat.c b/gdb/vax-bsd-nat.c
index a8bc603679..8d1cdf4856 100644
--- a/gdb/vax-bsd-nat.c
+++ b/gdb/vax-bsd-nat.c
@@ -64,11 +64,12 @@ vaxbsd_collect_gregset (const struct regcache *regcache,
static void
vaxbsd_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index a177b38ea3..c930a37ce3 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -531,9 +531,10 @@ do_windows_fetch_inferior_registers (struct regcache *regcache,
static void
windows_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int r)
+ struct regcache *regcache,
+ ptid_t ptid, int r)
{
- windows_thread_info *th = thread_rec (ptid_get_tid (inferior_ptid), TRUE);
+ windows_thread_info *th = thread_rec (ptid_get_tid (ptid), TRUE);
/* Check if current_thread exists. Windows sometimes uses a non-existent
thread id in its events. */
@@ -1351,7 +1352,7 @@ windows_resume (struct target_ops *ops,
/* Single step by setting t bit. */
struct regcache *regcache = get_current_regcache ();
struct gdbarch *gdbarch = get_regcache_arch (regcache);
- windows_fetch_inferior_registers (ops, regcache,
+ windows_fetch_inferior_registers (ops, regcache, inferior_ptid,
gdbarch_ps_regnum (gdbarch));
th->context.EFlags |= FLAG_TRACE_BIT;
}
diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c
index c29f0c71e6..688ed5c7d6 100644
--- a/gdb/xtensa-linux-nat.c
+++ b/gdb/xtensa-linux-nat.c
@@ -168,13 +168,13 @@ supply_fpregset (struct regcache *regcache,
return;
}
-/* Fetch greg-register(s) from process/thread TID
- and store value(s) in GDB's register array. */
+/* Fetch greg-register(s) from process/thread PTID
+ and store value(s) in REGCACHE. */
static void
-fetch_gregs (struct regcache *regcache, int regnum)
+fetch_gregs (struct regcache *regcache, ptid_t ptid, int regnum)
{
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (ptid);
gdb_gregset_t regs;
int areg;
@@ -219,9 +219,9 @@ static int xtreg_high;
interface provides special requests for this. */
static void
-fetch_xtregs (struct regcache *regcache, int regnum)
+fetch_xtregs (struct regcache *regcache, ptid_t ptid, int regnum)
{
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (ptid);
const xtensa_regtable_t *ptr;
char xtregs [XTENSA_ELF_XTREG_SIZE];
@@ -255,17 +255,18 @@ store_xtregs (struct regcache *regcache, int regnum)
static void
xtensa_linux_fetch_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1)
{
- fetch_gregs (regcache, regnum);
- fetch_xtregs (regcache, regnum);
+ fetch_gregs (regcache, ptid, regnum);
+ fetch_xtregs (regcache, ptid, regnum);
}
else if ((regnum < xtreg_lo) || (regnum > xtreg_high))
- fetch_gregs (regcache, regnum);
+ fetch_gregs (regcache, ptid, regnum);
else
- fetch_xtregs (regcache, regnum);
+ fetch_xtregs (regcache, ptid, regnum);
}
static void
--
2.11.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 6/7] Pass ptid to target_store_registers
2017-03-08 16:42 [PATCH 0/7] Pass ptid to target_ops register methods Simon Marchi
` (4 preceding siblings ...)
2017-03-08 16:42 ` [PATCH 4/7] Pass down ptid in bsd_uthread_ops layer Simon Marchi
@ 2017-03-08 16:42 ` Simon Marchi
2017-03-08 16:42 ` [PATCH 3/7] Define and use typedefs for bsd_uthread_ops fields Simon Marchi
` (2 subsequent siblings)
8 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2017-03-08 16:42 UTC (permalink / raw)
To: gdb-patches; +Cc: Simon Marchi
This patch adds a ptid parameter to the target_store_registers function
and the to_store_registers method of target_ops. The implementations
are therefore expected to rely on this and not on inferior_ptid.
gdb/ChangeLog:
* target-delegates.c: Re-generate.
* target.h (struct target_ops) <to_store_registers>: Add ptid
parameter.
(target_store_registers): Likewise.
* target.c (target_store_registers): Likewise.
* aarch64-linux-nat.c (store_gregs_to_thread,
store_fpregs_to_thread, aarch64_linux_store_inferior_registers):
Add ptid parameter and use it.
* aix-thread.c (aix_thread_store_registers): Add ptid parameter
and use it.
* amd64-linux-nat.c (amd64_linux_store_inferior_registers): Add
ptid parameter and use it.
* arm-linux-nat.c (store_fpregs, store_regs, store_wmmx_regs,
store_vfp_regs, arm_linux_store_inferior_registers): Likewise.
* arm-nbsd-nat.c (store_register, store_fp_register,
armnbsd_store_registers): Likewise.
* bsd-uthread.c (bsd_uthread_store_registers): Likewise.
* hppa-linux-nat.c (store_register,
hppa_linux_store_inferior_registers): Likewise.
* i386-linux-nat.c (store_register,
i386_linux_store_inferior_registers): Likewise.
* ia64-linux-nat.c (ia64_linux_store_register,
ia64_linux_store_registers): Likewise.
* inf-child.c (inf_child_store_inferior_registers): Add ptid
parameter.
* inf-ptrace.c (inf_ptrace_store_register,
inf_ptrace_store_registers): Likewise.
* m68k-linux-nat.c (store_register,
old_store_inferior_registers,
m68k_linux_store_inferior_registers): Likewise.
* mips-linux-nat.c (super_store_registers,
mips64_linux_regsets_store_registers,
mips64_linux_store_registers): Likewise.
* ppc-linux-nat.c (ppc_linux_store_inferior_registers):
Likewise.
* ppc-nbsd-nat.c (ppcnbsd_store_inferior_registers): Likewise.
* ppc-obsd-nat.c (ppcobsd_store_registers): Likewise.
* ppc-ravenscar-thread.c (ppc_ravenscar_generic_store_registers):
Add ptid parameter and use it.
(ppc_ravenscar_powerpc_store_registers): Likewise.
(ppc_ravenscar_e500_store_registers): Likewise.
* proc-service.c (ps_lsetregs, ps_lsetfpregs): Add ptid parameter
and use it. Don't set/restore inferior_ptid.
* procfs.c (procfs_store_registers): Add ptid parameter and use
it.
* ravenscar-thread.c (ravenscar_store_registers): Add ptid
parameter and use it. Remove declaration at top of file.
* ravenscar-thread.h (struct ravenscar_arch_ops)
<to_store_registers>: Add ptid parameter.
* record-btrace.c (record_btrace_store_registers): Add ptid
parameter and use it.
* record-full.c (record_full_store_registers): Likewise.
(record_full_core_store_registers): Add ptid parameter.
* regcache.c (regcache_raw_write): Pass ptid to
target_store_registers.
* remote.c (remote_store_registers): Add ptid parameter and use
it.
* remote-sim.c (gdbsim_store_register): Likewise.
* rs6000-aix-tdep.c (rs6000_push_dummy_call): Pass inferior_ptid
to target_store_registers.
* rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call):
Likewise.
* rs6000-nat.c (store_register,
rs6000_store_inferior_registers): Add ptid parameter and use it.
* s390-linux-nat.c (s390_linux_store_inferior_registers):
Likewise.
* sh-nbsd-nat.c (shnbsd_store_inferior_registers): Likewise.
* sol-thread.c (sol_thread_store_registers): Likewise.
* sparc-nat.c (sparc_store_inferior_registers): Likewise.
* sparc-nat.h (sparc_store_inferior_registers): Likewise.
* sparc-ravenscar-thread.c (sparc_ravenscar_store_registers):
Add ptid parameter and use it. Remove declaration at top of
file.
* spu-linux-nat.c (spu_store_inferior_registers): Add ptid
parameter and use it.
* spu-multiarch.c (spu_store_registers): Likewise.
* tilegx-linux-nat.c (store_inferior_registers): Likewise.
* vax-bsd-nat.c (vaxbsd_store_inferior_registers): Likewise.
* windows-nat.c (windows_store_inferior_registers): Likewise.
* xtensa-linux-nat.c (store_gregs, store_xtregs,
xtensa_linux_store_inferior_registers): Likewise.
---
gdb/aarch64-linux-nat.c | 18 +++++++++---------
gdb/aix-thread.c | 9 +++++----
gdb/amd64-linux-nat.c | 7 ++++---
gdb/arm-linux-nat.c | 35 ++++++++++++++++++-----------------
gdb/arm-nbsd-nat.c | 29 +++++++++++++++--------------
gdb/bsd-uthread.c | 6 +++---
gdb/hppa-linux-nat.c | 13 +++++++------
gdb/i386-linux-nat.c | 15 ++++++++-------
gdb/ia64-linux-nat.c | 14 ++++++++------
gdb/inf-child.c | 3 ++-
gdb/inf-ptrace.c | 14 ++++++++------
gdb/m68k-linux-nat.c | 22 ++++++++++++----------
gdb/mips-linux-nat.c | 22 ++++++++++++----------
gdb/ppc-linux-nat.c | 7 ++++---
gdb/ppc-nbsd-nat.c | 11 ++++++-----
gdb/ppc-obsd-nat.c | 11 ++++++-----
gdb/ppc-ravenscar-thread.c | 15 +++++++++------
gdb/proc-service.c | 18 ++++++------------
gdb/procfs.c | 11 ++++++-----
gdb/ravenscar-thread.c | 13 ++++++-------
gdb/ravenscar-thread.h | 2 +-
gdb/record-btrace.c | 7 ++++---
gdb/record-full.c | 6 +++---
gdb/regcache.c | 2 +-
gdb/remote-sim.c | 8 +++++---
gdb/remote.c | 5 +++--
gdb/rs6000-aix-tdep.c | 3 ++-
gdb/rs6000-lynx178-tdep.c | 3 ++-
gdb/rs6000-nat.c | 33 +++++++++++++++++----------------
gdb/s390-linux-nat.c | 5 +++--
gdb/sh-nbsd-nat.c | 7 ++++---
gdb/sol-thread.c | 11 ++++++-----
gdb/sparc-nat.c | 7 ++++---
gdb/sparc-nat.h | 2 +-
gdb/sparc-ravenscar-thread.c | 8 +++-----
gdb/spu-linux-nat.c | 3 ++-
gdb/spu-multiarch.c | 6 +++---
gdb/target-delegates.c | 14 ++++++++------
gdb/target.c | 4 ++--
gdb/target.h | 6 ++++--
gdb/tilegx-linux-nat.c | 7 ++++---
gdb/vax-bsd-nat.c | 7 ++++---
gdb/windows-nat.c | 5 +++--
gdb/xtensa-linux-nat.c | 23 ++++++++++++-----------
44 files changed, 255 insertions(+), 222 deletions(-)
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 3fc340496c..e17a4a2916 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -190,7 +190,7 @@ fetch_gregs_from_thread (struct regcache *regcache, ptid_t ptid)
values in the GDB's register array. */
static void
-store_gregs_to_thread (const struct regcache *regcache)
+store_gregs_to_thread (const struct regcache *regcache, ptid_t ptid)
{
int ret, tid;
elf_gregset_t regs;
@@ -200,7 +200,7 @@ store_gregs_to_thread (const struct regcache *regcache)
/* Make sure REGS can hold all registers contents on both aarch64
and arm. */
gdb_static_assert (sizeof (regs) >= 18 * 4);
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
iovec.iov_base = ®s;
if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32)
@@ -281,7 +281,7 @@ fetch_fpregs_from_thread (struct regcache *regcache, ptid_t ptid)
values in the GDB's register array. */
static void
-store_fpregs_to_thread (const struct regcache *regcache)
+store_fpregs_to_thread (const struct regcache *regcache, ptid_t ptid)
{
int ret, tid;
elf_fpregset_t regs;
@@ -291,7 +291,7 @@ store_fpregs_to_thread (const struct regcache *regcache)
/* Make sure REGS can hold all VFP registers contents on both aarch64
and arm. */
gdb_static_assert (sizeof regs >= VFP_REGS_SIZE);
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
iovec.iov_base = ®s;
@@ -365,17 +365,17 @@ aarch64_linux_fetch_inferior_registers (struct target_ops *ops,
static void
aarch64_linux_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache,
- int regno)
+ ptid_t ptid, int regno)
{
if (regno == -1)
{
- store_gregs_to_thread (regcache);
- store_fpregs_to_thread (regcache);
+ store_gregs_to_thread (regcache, ptid);
+ store_fpregs_to_thread (regcache, ptid);
}
else if (regno < AARCH64_V0_REGNUM)
- store_gregs_to_thread (regcache);
+ store_gregs_to_thread (regcache, ptid);
else
- store_fpregs_to_thread (regcache);
+ store_fpregs_to_thread (regcache, ptid);
}
/* Fill register REGNO (if it is a general-purpose register) in
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index b85c147f03..04144945da 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1657,17 +1657,18 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
static void
aix_thread_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct thread_info *thread;
pthdb_tid_t tid;
struct target_ops *beneath = find_target_beneath (ops);
- if (!PD_TID (inferior_ptid))
- beneath->to_store_registers (beneath, regcache, regno);
+ if (!PD_TID (ptid))
+ beneath->to_store_registers (beneath, regcache, ptid, regno);
else
{
- thread = find_thread_ptid (inferior_ptid);
+ thread = find_thread_ptid (ptid);
tid = thread->priv->tid;
if (tid == PTHDB_INVALID_TID)
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index a9f61cddac..f9c81ea84b 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -212,15 +212,16 @@ amd64_linux_fetch_inferior_registers (struct target_ops *ops,
static void
amd64_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int tid;
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
{
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 86ac33d307..a1c50e27f3 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -107,13 +107,13 @@ fetch_fpregs (struct regcache *regcache, ptid_t ptid)
the contents from regcache. */
static void
-store_fpregs (const struct regcache *regcache)
+store_fpregs (const struct regcache *regcache, ptid_t ptid)
{
int ret, regno, tid;
gdb_byte fp[ARM_LINUX_SIZEOF_NWFPE];
/* Get the thread id for the ptrace call. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
/* Read the floating point state. */
if (have_ptrace_getregset == TRIBOOL_TRUE)
@@ -188,13 +188,13 @@ fetch_regs (struct regcache *regcache, ptid_t ptid)
}
static void
-store_regs (const struct regcache *regcache)
+store_regs (const struct regcache *regcache, ptid_t ptid)
{
int ret, regno, tid;
elf_gregset_t regs;
/* Get the thread id for the ptrace call. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
/* Fetch the general registers. */
if (have_ptrace_getregset == TRIBOOL_TRUE)
@@ -262,13 +262,13 @@ fetch_wmmx_regs (struct regcache *regcache, ptid_t ptid)
}
static void
-store_wmmx_regs (const struct regcache *regcache)
+store_wmmx_regs (const struct regcache *regcache, ptid_t ptid)
{
char regbuf[IWMMXT_REGS_SIZE];
int ret, regno, tid;
/* Get the thread id for the ptrace call. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
ret = ptrace (PTRACE_GETWMMXREGS, tid, 0, regbuf);
if (ret < 0)
@@ -328,7 +328,7 @@ fetch_vfp_regs (struct regcache *regcache, ptid_t ptid)
}
static void
-store_vfp_regs (const struct regcache *regcache)
+store_vfp_regs (const struct regcache *regcache, ptid_t ptid)
{
gdb_byte regbuf[VFP_REGS_SIZE];
int ret, regno, tid;
@@ -336,7 +336,7 @@ store_vfp_regs (const struct regcache *regcache)
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* Get the thread id for the ptrace call. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
@@ -414,34 +414,35 @@ arm_linux_fetch_inferior_registers (struct target_ops *ops,
static void
arm_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (-1 == regno)
{
- store_regs (regcache);
+ store_regs (regcache, ptid);
if (tdep->have_wmmx_registers)
- store_wmmx_regs (regcache);
+ store_wmmx_regs (regcache, ptid);
if (tdep->vfp_register_count > 0)
- store_vfp_regs (regcache);
+ store_vfp_regs (regcache, ptid);
if (tdep->have_fpa_registers)
- store_fpregs (regcache);
+ store_fpregs (regcache, ptid);
}
else
{
if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM)
- store_regs (regcache);
+ store_regs (regcache, ptid);
else if ((regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM))
- store_fpregs (regcache);
+ store_fpregs (regcache, ptid);
else if (tdep->have_wmmx_registers
&& regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
- store_wmmx_regs (regcache);
+ store_wmmx_regs (regcache, ptid);
else if (tdep->vfp_register_count > 0
&& regno >= ARM_D0_REGNUM
&& regno <= ARM_D0_REGNUM + tdep->vfp_register_count)
- store_vfp_regs (regcache);
+ store_vfp_regs (regcache, ptid);
}
}
diff --git a/gdb/arm-nbsd-nat.c b/gdb/arm-nbsd-nat.c
index 8857e37ce0..f59e5645b7 100644
--- a/gdb/arm-nbsd-nat.c
+++ b/gdb/arm-nbsd-nat.c
@@ -211,13 +211,13 @@ armnbsd_fetch_registers (struct target_ops *ops,
static void
-store_register (const struct regcache *regcache, int regno)
+store_register (const struct regcache *regcache, ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct reg inferior_registers;
int ret;
- ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
@@ -280,7 +280,7 @@ store_register (const struct regcache *regcache, int regno)
break;
}
- ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
@@ -328,7 +328,7 @@ store_regs (const struct regcache *regcache)
inferior_registers.r_pc = pc_val | psr_val;
}
- ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
@@ -336,12 +336,12 @@ store_regs (const struct regcache *regcache)
}
static void
-store_fp_register (const struct regcache *regcache, int regno)
+store_fp_register (const struct regcache *regcache, ptid_t ptid, int regno)
{
struct fpreg inferior_fp_registers;
int ret;
- ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
@@ -363,7 +363,7 @@ store_fp_register (const struct regcache *regcache, int regno)
break;
}
- ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
@@ -371,7 +371,7 @@ store_fp_register (const struct regcache *regcache, int regno)
}
static void
-store_fp_regs (const struct regcache *regcache)
+store_fp_regs (const struct regcache *regcache, ptid_t ptid)
{
struct fpreg inferior_fp_registers;
int ret;
@@ -385,7 +385,7 @@ store_fp_regs (const struct regcache *regcache)
regcache_raw_collect (regcache, ARM_FPS_REGNUM,
(char *) &inferior_fp_registers.fpr_fpsr);
- ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ ret = ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
@@ -394,19 +394,20 @@ store_fp_regs (const struct regcache *regcache)
static void
armnbsd_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (regno >= 0)
{
if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM)
- store_register (regcache, regno);
+ store_register (regcache, regno, ptid);
else
- store_fp_register (regcache, regno);
+ store_fp_register (regcache, regno, ptid);
}
else
{
- store_regs (regcache);
- store_fp_regs (regcache);
+ store_regs (regcache, ptid);
+ store_fp_regs (regcache, ptid);
}
}
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index c2c9866cd0..04bd43bc6a 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -309,13 +309,13 @@ bsd_uthread_fetch_registers (struct target_ops *ops, struct regcache *regcache,
static void
bsd_uthread_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct bsd_uthread_ops *uthread_ops
= (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
struct target_ops *beneath = find_target_beneath (ops);
- ptid_t ptid = inferior_ptid;
CORE_ADDR addr = ptid_get_tid (ptid);
CORE_ADDR active_addr;
@@ -330,7 +330,7 @@ bsd_uthread_store_registers (struct target_ops *ops,
{
/* Updating the thread that is currently running; pass the
request to the layer beneath. */
- beneath->to_store_registers (beneath, regcache, regnum);
+ beneath->to_store_registers (beneath, regcache, ptid, regnum);
}
}
diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c
index da1f914dd9..ff28313840 100644
--- a/gdb/hppa-linux-nat.c
+++ b/gdb/hppa-linux-nat.c
@@ -240,7 +240,7 @@ fetch_register (struct regcache *regcache, ptid_t ptid, int regno)
/* Store one register. */
static void
-store_register (const struct regcache *regcache, int regno)
+store_register (const struct regcache *regcache, ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int tid;
@@ -250,9 +250,9 @@ store_register (const struct regcache *regcache, int regno)
return;
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
errno = 0;
regcache_raw_collect (regcache, regno, &val);
@@ -291,18 +291,19 @@ hppa_linux_fetch_inferior_registers (struct target_ops *ops,
static void
hppa_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (-1 == regno)
{
for (regno = 0;
regno < gdbarch_num_regs (get_regcache_arch (regcache));
regno++)
- store_register (regcache, regno);
+ store_register (regcache, regno, ptid);
}
else
{
- store_register (regcache, regno);
+ store_register (regcache, regno, ptid);
}
}
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 7602f80529..94f6809eb9 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -123,7 +123,7 @@ fetch_register (struct regcache *regcache, ptid_t ptid, int regno)
/* Store one register. */
static void
-store_register (const struct regcache *regcache, int regno)
+store_register (const struct regcache *regcache, ptid_t ptid, int regno)
{
int tid;
int val;
@@ -133,9 +133,9 @@ store_register (const struct regcache *regcache, int regno)
return;
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
errno = 0;
regcache_raw_collect (regcache, regno, &val);
@@ -535,7 +535,8 @@ i386_linux_fetch_inferior_registers (struct target_ops *ops,
registers). */
static void
i386_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
int tid;
@@ -547,15 +548,15 @@ i386_linux_store_inferior_registers (struct target_ops *ops,
for (i = 0; i < gdbarch_num_regs (get_regcache_arch (regcache)); i++)
if (regno == -1 || regno == i)
- store_register (regcache, i);
+ store_register (regcache, ptid, i);
return;
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
/* Use the PTRACE_SETFPXREGS requests whenever possible, since it
transfers more registers in one system call. But remember that
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index da3fdaecf6..7c00c5b51f 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -783,7 +783,8 @@ ia64_linux_fetch_registers (struct target_ops *ops,
/* Store register REGNUM into the inferior. */
static void
-ia64_linux_store_register (const struct regcache *regcache, int regnum)
+ia64_linux_store_register (const struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR addr;
@@ -796,9 +797,9 @@ ia64_linux_store_register (const struct regcache *regcache, int regnum)
/* Cater for systems like GNU/Linux, that implement threads as
separate processes. */
- pid = ptid_get_lwp (inferior_ptid);
+ pid = ptid_get_lwp (ptid);
if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = ptid_get_pid (ptid);
/* This isn't really an address, but ptrace thinks of it as one. */
addr = ia64_register_addr (gdbarch, regnum);
@@ -827,15 +828,16 @@ ia64_linux_store_register (const struct regcache *regcache, int regnum)
static void
ia64_linux_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1)
for (regnum = 0;
regnum < gdbarch_num_regs (get_regcache_arch (regcache));
regnum++)
- ia64_linux_store_register (regcache, regnum);
+ ia64_linux_store_register (regcache, ptid, regnum);
else
- ia64_linux_store_register (regcache, regnum);
+ ia64_linux_store_register (regcache, ptid, regnum);
}
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 49445dd688..0f128c4905 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -91,7 +91,8 @@ inf_child_fetch_inferior_registers (struct target_ops *ops,
static void
inf_child_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
}
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 3cc6a133fd..cf9cf5e93e 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -767,7 +767,8 @@ inf_ptrace_fetch_registers (struct target_ops *ops, struct regcache *regcache,
/* Store register REGNUM into the inferior. */
static void
-inf_ptrace_store_register (const struct regcache *regcache, int regnum)
+inf_ptrace_store_register (const struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR addr;
@@ -783,9 +784,9 @@ inf_ptrace_store_register (const struct regcache *regcache, int regnum)
/* Cater for systems like GNU/Linux, that implement threads as
separate processes. */
- pid = ptid_get_lwp (inferior_ptid);
+ pid = ptid_get_lwp (ptid);
if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = ptid_get_pid (ptid);
size = register_size (gdbarch, regnum);
gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
@@ -811,15 +812,16 @@ inf_ptrace_store_register (const struct regcache *regcache, int regnum)
static void
inf_ptrace_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1)
for (regnum = 0;
regnum < gdbarch_num_regs (get_regcache_arch (regcache));
regnum++)
- inf_ptrace_store_register (regcache, regnum);
+ inf_ptrace_store_register (regcache, ptid, regnum);
else
- inf_ptrace_store_register (regcache, regnum);
+ inf_ptrace_store_register (regcache, ptid, regnum);
}
/* Create a "traditional" ptrace target. REGISTER_U_OFFSET should be
diff --git a/gdb/m68k-linux-nat.c b/gdb/m68k-linux-nat.c
index d7403e5e72..b39459df28 100644
--- a/gdb/m68k-linux-nat.c
+++ b/gdb/m68k-linux-nat.c
@@ -154,7 +154,7 @@ old_fetch_inferior_registers (struct regcache *regcache, ptid_t ptid, int regno)
/* Store one register. */
static void
-store_register (const struct regcache *regcache, int regno)
+store_register (const struct regcache *regcache, ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
long regaddr, val;
@@ -163,9 +163,9 @@ store_register (const struct regcache *regcache, int regno)
gdb_byte buf[M68K_MAX_REGISTER_SIZE];
/* Overload thread id onto process id. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* no thread id, just use
+ tid = ptid_get_pid (ptid); /* no thread id, just use
process id. */
regaddr = 4 * regmap[regno];
@@ -192,11 +192,12 @@ store_register (const struct regcache *regcache, int regno)
Otherwise, REGNO specifies which register (so we can save time). */
static void
-old_store_inferior_registers (const struct regcache *regcache, int regno)
+old_store_inferior_registers (const struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (regno >= 0)
{
- store_register (regcache, regno);
+ store_register (regcache, ptid, regno);
}
else
{
@@ -204,7 +205,7 @@ old_store_inferior_registers (const struct regcache *regcache, int regno)
regno < gdbarch_num_regs (get_regcache_arch (regcache));
regno++)
{
- store_register (regcache, regno);
+ store_register (regcache, ptid, regno);
}
}
}
@@ -462,7 +463,8 @@ m68k_linux_fetch_inferior_registers (struct target_ops *ops,
registers). */
static void
m68k_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
int tid;
@@ -470,14 +472,14 @@ m68k_linux_store_inferior_registers (struct target_ops *ops,
SETREGS request isn't available. */
if (! have_ptrace_getregs)
{
- old_store_inferior_registers (regcache, regno);
+ old_store_inferior_registers (regcache, ptid, regno);
return;
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (ptid); /* Not a threaded program. */
/* Use the PTRACE_SETFPREGS requests whenever possible, since it
transfers more registers in one system call. But remember that
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index f9b6e1b2fc..8456cc0e9b 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -56,7 +56,7 @@ static int have_ptrace_regsets = 1;
static void (*super_fetch_registers) (struct target_ops *,
struct regcache *, ptid_t, int);
static void (*super_store_registers) (struct target_ops *,
- struct regcache *, int);
+ struct regcache *, ptid_t, int);
static void (*super_close) (struct target_ops *);
@@ -304,7 +304,8 @@ mips64_linux_regsets_fetch_registers (struct target_ops *ops,
static void
mips64_linux_regsets_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int is_fp, is_dsp;
@@ -334,9 +335,9 @@ mips64_linux_regsets_store_registers (struct target_ops *ops,
else
is_dsp = 0;
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ tid = ptid_get_pid (ptid);
if (regno == -1 || (!is_fp && !is_dsp))
{
@@ -367,14 +368,14 @@ mips64_linux_regsets_store_registers (struct target_ops *ops,
}
if (is_dsp)
- super_store_registers (ops, regcache, regno);
+ super_store_registers (ops, regcache, ptid, regno);
else if (regno == -1 && have_dsp)
{
for (regi = mips_regnum (gdbarch)->dspacc;
regi < mips_regnum (gdbarch)->dspacc + 6;
regi++)
- super_store_registers (ops, regcache, regi);
- super_store_registers (ops, regcache, mips_regnum (gdbarch)->dspctl);
+ super_store_registers (ops, regcache, ptid, regi);
+ super_store_registers (ops, regcache, ptid, mips_regnum (gdbarch)->dspctl);
}
}
@@ -401,16 +402,17 @@ mips64_linux_fetch_registers (struct target_ops *ops,
static void
mips64_linux_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
/* Unless we already know that PTRACE_GETREGS does not work, try it. */
if (have_ptrace_regsets)
- mips64_linux_regsets_store_registers (ops, regcache, regnum);
+ mips64_linux_regsets_store_registers (ops, regcache, ptid, regnum);
/* If we know, or just found out, that PTRACE_GETREGS does not work, fall
back to PTRACE_PEEKUSER. */
if (!have_ptrace_regsets)
- super_store_registers (ops, regcache, regnum);
+ super_store_registers (ops, regcache, ptid, regnum);
}
/* Return the address in the core dump or inferior of register
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index e7070ccd37..a35e06864e 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2290,14 +2290,15 @@ ppc_linux_masked_watch_num_registers (struct target_ops *target,
static void
ppc_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
/* Overload thread id onto process id. */
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (ptid);
/* No thread id, just use process id. */
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ tid = ptid_get_pid (ptid);
if (regno >= 0)
store_register (regcache, tid, regno);
diff --git a/gdb/ppc-nbsd-nat.c b/gdb/ppc-nbsd-nat.c
index f2b837b3c0..13a6382956 100644
--- a/gdb/ppc-nbsd-nat.c
+++ b/gdb/ppc-nbsd-nat.c
@@ -110,7 +110,8 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops,
static void
ppcnbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
@@ -118,14 +119,14 @@ ppcnbsd_store_inferior_registers (struct target_ops *ops,
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
ppc_collect_gregset (&ppcnbsd_gregset, regcache,
regnum, ®s, sizeof regs);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
@@ -134,14 +135,14 @@ ppcnbsd_store_inferior_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
ppc_collect_fpregset (&ppcnbsd_fpregset, regcache,
regnum, &fpregs, sizeof fpregs);
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't set FP registers"));
}
diff --git a/gdb/ppc-obsd-nat.c b/gdb/ppc-obsd-nat.c
index 0bb6f9f5d2..09a6acedcd 100644
--- a/gdb/ppc-obsd-nat.c
+++ b/gdb/ppc-obsd-nat.c
@@ -109,11 +109,12 @@ ppcobsd_fetch_registers (struct target_ops *ops,
static void
ppcobsd_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -124,7 +125,7 @@ ppcobsd_store_registers (struct target_ops *ops,
regnum, ®s, sizeof regs);
#endif
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
@@ -134,14 +135,14 @@ ppcobsd_store_registers (struct target_ops *ops,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
ppc_collect_fpregset (&ppcobsd_fpregset, regcache,
regnum, &fpregs, sizeof fpregs);
- if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
diff --git a/gdb/ppc-ravenscar-thread.c b/gdb/ppc-ravenscar-thread.c
index 9f518c2b53..1e4eb03cf1 100644
--- a/gdb/ppc-ravenscar-thread.c
+++ b/gdb/ppc-ravenscar-thread.c
@@ -184,7 +184,7 @@ ppc_ravenscar_generic_prepare_to_store (struct regcache *regcache)
static void
ppc_ravenscar_generic_store_registers
(const struct ravenscar_reg_info *reg_info,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache, ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int buf_size = register_size (gdbarch, regnum);
@@ -193,7 +193,7 @@ ppc_ravenscar_generic_store_registers
if (register_in_thread_descriptor_p (reg_info, regnum))
register_address
- = ptid_get_tid (inferior_ptid) + reg_info->context_offsets [regnum];
+ = ptid_get_tid (ptid) + reg_info->context_offsets [regnum];
else
return;
@@ -225,9 +225,10 @@ ppc_ravenscar_powerpc_fetch_registers (struct regcache *regcache, ptid_t ptid,
for most PowerPC targets. */
static void
-ppc_ravenscar_powerpc_store_registers (struct regcache *regcache, int regnum)
+ppc_ravenscar_powerpc_store_registers (struct regcache *regcache, ptid_t ptid,
+ int regnum)
{
- ppc_ravenscar_generic_store_registers (&ppc_reg_info, regcache, regnum);
+ ppc_ravenscar_generic_store_registers (&ppc_reg_info, regcache, ptid, regnum);
}
/* The ravenscar_arch_ops vector for most PowerPC targets. */
@@ -270,9 +271,11 @@ ppc_ravenscar_e500_fetch_registers (struct regcache *regcache, ptid_t ptid,
for E500 targets. */
static void
-ppc_ravenscar_e500_store_registers (struct regcache *regcache, int regnum)
+ppc_ravenscar_e500_store_registers (struct regcache *regcache, ptid_t ptid,
+ int regnum)
{
- ppc_ravenscar_generic_store_registers (&e500_reg_info, regcache, regnum);
+ ppc_ravenscar_generic_store_registers (&e500_reg_info, regcache, ptid,
+ regnum);
}
/* The ravenscar_arch_ops vector for E500 targets. */
diff --git a/gdb/proc-service.c b/gdb/proc-service.c
index 188ad55157..373c762cb4 100644
--- a/gdb/proc-service.c
+++ b/gdb/proc-service.c
@@ -174,16 +174,13 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
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;
+ ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
-
+ regcache = get_thread_arch_regcache (ptid, target_gdbarch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
- target_store_registers (regcache, -1);
+ target_store_registers (regcache, ptid, -1);
- do_cleanups (old_chain);
return PS_OK;
}
@@ -211,16 +208,13 @@ ps_err_e
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;
+ ptid_t ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
- regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
-
+ regcache = get_thread_arch_regcache (ptid, target_gdbarch ());
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
- target_store_registers (regcache, -1);
+ target_store_registers (regcache, ptid, -1);
- do_cleanups (old_chain);
return PS_OK;
}
diff --git a/gdb/procfs.c b/gdb/procfs.c
index c7b7dab1d4..e98f68aef9 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -117,7 +117,7 @@ static void procfs_files_info (struct target_ops *);
static void procfs_fetch_registers (struct target_ops *,
struct regcache *, ptid_t, int);
static void procfs_store_registers (struct target_ops *,
- struct regcache *, int);
+ struct regcache *, ptid_t, int);
static void procfs_pass_signals (struct target_ops *self,
int, unsigned char *);
static void procfs_kill_inferior (struct target_ops *ops);
@@ -3265,19 +3265,20 @@ procfs_fetch_registers (struct target_ops *ops,
static void
procfs_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
gdb_gregset_t *gregs;
procinfo *pi;
- int pid = ptid_get_pid (inferior_ptid);
- int tid = ptid_get_lwp (inferior_ptid);
+ int pid = ptid_get_pid (ptid);
+ int tid = ptid_get_lwp (ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
pi = find_procinfo_or_die (pid, tid);
if (pi == NULL)
error (_("procfs: store_registers: failed to find procinfo for %s"),
- target_pid_to_str (inferior_ptid));
+ target_pid_to_str (ptid));
gregs = proc_get_gregs (pi);
if (gregs == NULL)
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 12a4eab269..0660d03a5e 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -57,8 +57,6 @@ static ptid_t ravenscar_running_thread (void);
static char *ravenscar_extra_thread_info (struct target_ops *self,
struct thread_info *tp);
static int ravenscar_thread_alive (struct target_ops *ops, ptid_t ptid);
-static void ravenscar_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum);
static void ravenscar_prepare_to_store (struct target_ops *self,
struct regcache *regcache);
static void ravenscar_resume (struct target_ops *ops, ptid_t ptid, int step,
@@ -283,21 +281,22 @@ ravenscar_fetch_registers (struct target_ops *ops, struct regcache *regcache,
static void
ravenscar_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct target_ops *beneath = find_target_beneath (ops);
if (!ravenscar_runtime_initialized ()
- || ptid_equal (inferior_ptid, base_magic_null_ptid)
- || ptid_equal (inferior_ptid, ravenscar_running_thread ()))
- beneath->to_store_registers (beneath, regcache, regnum);
+ || ptid_equal (ptid, base_magic_null_ptid)
+ || ptid_equal (ptid, ravenscar_running_thread ()))
+ beneath->to_store_registers (beneath, regcache, ptid, regnum);
else
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct ravenscar_arch_ops *arch_ops
= gdbarch_ravenscar_ops (gdbarch);
- arch_ops->to_store_registers (regcache, regnum);
+ arch_ops->to_store_registers (regcache, ptid, regnum);
}
}
diff --git a/gdb/ravenscar-thread.h b/gdb/ravenscar-thread.h
index 2413153010..2df88981a5 100644
--- a/gdb/ravenscar-thread.h
+++ b/gdb/ravenscar-thread.h
@@ -25,7 +25,7 @@
struct ravenscar_arch_ops
{
void (*to_fetch_registers) (struct regcache *, ptid_t, int);
- void (*to_store_registers) (struct regcache *, int);
+ void (*to_store_registers) (struct regcache *, ptid_t, int);
void (*to_prepare_to_store) (struct regcache *);
};
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 3f6cc85947..6c16148a25 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1462,18 +1462,19 @@ record_btrace_fetch_registers (struct target_ops *ops,
static void
record_btrace_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct target_ops *t;
if (!record_btrace_generating_corefile
- && record_btrace_is_replaying (ops, inferior_ptid))
+ && record_btrace_is_replaying (ops, ptid))
error (_("Cannot write registers while replaying."));
gdb_assert (may_write_registers != 0);
t = ops->beneath;
- t->to_store_registers (t, regcache, regno);
+ t->to_store_registers (t, regcache, ptid, regno);
}
/* The to_prepare_to_store method of target record-btrace. */
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 0b04f0fbb7..c55fb41b01 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1459,7 +1459,7 @@ record_full_registers_change (struct regcache *regcache, int regnum)
static void
record_full_store_registers (struct target_ops *ops,
struct regcache *regcache,
- int regno)
+ ptid_t ptid, int regno)
{
if (!record_full_gdb_operation_disable)
{
@@ -1507,7 +1507,7 @@ record_full_store_registers (struct target_ops *ops,
record_full_registers_change (regcache, regno);
}
- ops->beneath->to_store_registers (ops->beneath, regcache, regno);
+ ops->beneath->to_store_registers (ops->beneath, regcache, ptid, regno);
}
/* "to_xfer_partial" method. Behavior is conditional on
@@ -2074,7 +2074,7 @@ record_full_core_prepare_to_store (struct target_ops *self,
static void
record_full_core_store_registers (struct target_ops *ops,
struct regcache *regcache,
- int regno)
+ ptid_t ptid, int regno)
{
if (record_full_gdb_operation_disable)
regcache_raw_collect (regcache, regno,
diff --git a/gdb/regcache.c b/gdb/regcache.c
index bdf0bcbc82..c8eb200fa2 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -957,7 +957,7 @@ regcache_raw_write (struct regcache *regcache, int regnum,
chain_before_invalidate_register
= make_cleanup_regcache_invalidate (regcache, regnum);
- target_store_registers (regcache, regnum);
+ target_store_registers (regcache, regcache->ptid, regnum);
/* The target did not throw an error so we can discard invalidating the
register and restore the cleanup chain to what it was. */
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 609ae84fac..b7ecdbb05f 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -504,16 +504,18 @@ gdbsim_fetch_register (struct target_ops *ops,
static void
gdbsim_store_register (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct inferior *inf = find_inferior_ptid (ptid);
struct sim_inferior_data *sim_data
- = get_sim_inferior_data (current_inferior (), SIM_INSTANCE_NEEDED);
+ = get_sim_inferior_data (inf, SIM_INSTANCE_NEEDED);
if (regno == -1)
{
for (regno = 0; regno < gdbarch_num_regs (gdbarch); regno++)
- gdbsim_store_register (ops, regcache, regno);
+ gdbsim_store_register (ops, regcache, ptid, regno);
return;
}
else if (gdbarch_register_sim_regno (gdbarch, regno) >= 0)
diff --git a/gdb/remote.c b/gdb/remote.c
index b1b1c58038..b7ffa4a28f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -7862,13 +7862,14 @@ store_registers_using_G (const struct regcache *regcache)
static void
remote_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct remote_arch_state *rsa = get_remote_arch_state ();
int i;
set_remote_traceframe ();
- set_general_thread (inferior_ptid);
+ set_general_thread (ptid);
if (regnum >= 0)
{
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index 9841a60eaf..3cd0350e14 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -37,6 +37,7 @@
#include "solib.h"
#include "solib-aix.h"
#include "xml-utils.h"
+#include "inferior.h"
/* If the kernel has to deliver a signal, it pushes a sigcontext
structure on the stack and then calls the signal handler, passing
@@ -407,7 +408,7 @@ ran_out_of_registers_for_arguments:
regcache_raw_write_signed (regcache, tdep->ppc_toc_regnum,
solib_aix_get_toc_value (func_addr));
- target_store_registers (regcache, -1);
+ target_store_registers (regcache, inferior_ptid, -1);
return sp;
}
diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c
index f2aa1f8448..600084f546 100644
--- a/gdb/rs6000-lynx178-tdep.c
+++ b/gdb/rs6000-lynx178-tdep.c
@@ -24,6 +24,7 @@
#include "ppc-tdep.h"
#include "value.h"
#include "xcoffread.h"
+#include "inferior.h"
/* Implement the "push_dummy_call" gdbarch method. */
@@ -256,7 +257,7 @@ ran_out_of_registers_for_arguments:
breakpoint. */
regcache_raw_write_signed (regcache, tdep->ppc_lr_regnum, bp_addr);
- target_store_registers (regcache, -1);
+ target_store_registers (regcache, inferior_ptid, -1);
return sp;
}
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 7362df9580..6f3f807637 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -219,7 +219,7 @@ fetch_register (struct regcache *regcache, ptid_t ptid, int regno)
/* Store register REGNO back into the inferior. */
static void
-store_register (struct regcache *regcache, int regno)
+store_register (struct regcache *regcache, ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE];
@@ -235,7 +235,7 @@ store_register (struct regcache *regcache, int regno)
/* Floating-point registers. */
if (isfloat)
- rs6000_ptrace32 (PT_WRITE_FPR, ptid_get_pid (inferior_ptid), addr, nr, 0);
+ rs6000_ptrace32 (PT_WRITE_FPR, ptid_get_pid (ptid), addr, nr, 0);
/* Bogus register number. */
else if (nr < 0)
@@ -253,7 +253,7 @@ store_register (struct regcache *regcache, int regno)
the register's value is passed by value, but for 64-bit inferiors,
the address of a buffer containing the value is passed. */
if (!ARCH64 ())
- rs6000_ptrace32 (PT_WRITE_GPR, ptid_get_pid (inferior_ptid),
+ rs6000_ptrace32 (PT_WRITE_GPR, ptid_get_pid (ptid),
(int *) nr, *addr, 0);
else
{
@@ -264,7 +264,7 @@ store_register (struct regcache *regcache, int regno)
memcpy (&buf, addr, 8);
else
buf = *addr;
- rs6000_ptrace64 (PT_WRITE_GPR, ptid_get_pid (inferior_ptid),
+ rs6000_ptrace64 (PT_WRITE_GPR, ptid_get_pid (ptid),
nr, 0, &buf);
}
}
@@ -325,11 +325,12 @@ rs6000_fetch_inferior_registers (struct target_ops *ops,
static void
rs6000_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regno != -1)
- store_register (regcache, regno);
+ store_register (regcache, ptid, regno);
else
{
@@ -340,25 +341,25 @@ rs6000_store_inferior_registers (struct target_ops *ops,
regno < tdep->ppc_gp0_regnum + ppc_num_gprs;
regno++)
{
- store_register (regcache, regno);
+ store_register (regcache, ptid, regno);
}
/* Write floating point registers. */
if (tdep->ppc_fp0_regnum >= 0)
for (regno = 0; regno < ppc_num_fprs; regno++)
- store_register (regcache, tdep->ppc_fp0_regnum + regno);
+ store_register (regcache, ptid, tdep->ppc_fp0_regnum + regno);
/* Write special registers. */
- store_register (regcache, gdbarch_pc_regnum (gdbarch));
- store_register (regcache, tdep->ppc_ps_regnum);
- store_register (regcache, tdep->ppc_cr_regnum);
- store_register (regcache, tdep->ppc_lr_regnum);
- store_register (regcache, tdep->ppc_ctr_regnum);
- store_register (regcache, tdep->ppc_xer_regnum);
+ store_register (regcache, ptid, gdbarch_pc_regnum (gdbarch));
+ store_register (regcache, ptid, tdep->ppc_ps_regnum);
+ store_register (regcache, ptid, tdep->ppc_cr_regnum);
+ store_register (regcache, ptid, tdep->ppc_lr_regnum);
+ store_register (regcache, ptid, tdep->ppc_ctr_regnum);
+ store_register (regcache, ptid, tdep->ppc_xer_regnum);
if (tdep->ppc_fpscr_regnum >= 0)
- store_register (regcache, tdep->ppc_fpscr_regnum);
+ store_register (regcache, ptid, tdep->ppc_fpscr_regnum);
if (tdep->ppc_mq_regnum >= 0)
- store_register (regcache, tdep->ppc_mq_regnum);
+ store_register (regcache, ptid, tdep->ppc_mq_regnum);
}
}
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 1703844e08..15fab438a3 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -420,9 +420,10 @@ s390_linux_fetch_inferior_registers (struct target_ops *ops,
-1, do this for all registers. */
static void
s390_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
- int tid = s390_inferior_tid ();
+ int tid = s390_inferior_tid (ptid);
if (regnum == -1 || S390_IS_GREGSET_REGNUM (regnum))
store_regs (regcache, tid, regnum);
diff --git a/gdb/sh-nbsd-nat.c b/gdb/sh-nbsd-nat.c
index d1ece86cdd..4d1794f806 100644
--- a/gdb/sh-nbsd-nat.c
+++ b/gdb/sh-nbsd-nat.c
@@ -65,13 +65,14 @@ shnbsd_fetch_inferior_registers (struct target_ops *ops,
static void
shnbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
if (regno == -1 || GETREGS_SUPPLIES (get_regcache_arch (regcache), regno))
{
struct reg inferior_registers;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't get registers"));
@@ -79,7 +80,7 @@ shnbsd_store_inferior_registers (struct target_ops *ops,
(char *) &inferior_registers,
SHNBSD_SIZEOF_GREGS);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't set registers"));
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 56fdc96380..bd20cba480 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -508,7 +508,8 @@ sol_thread_fetch_registers (struct target_ops *ops,
static void
sol_thread_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
thread_t thread;
td_thrhandle_t thandle;
@@ -516,17 +517,17 @@ sol_thread_store_registers (struct target_ops *ops,
prgregset_t gregset;
prfpregset_t fpregset;
- if (!ptid_tid_p (inferior_ptid))
+ if (!ptid_tid_p (ptid))
{
struct target_ops *beneath = find_target_beneath (ops);
/* It's an LWP; pass the request on to the layer beneath. */
- beneath->to_store_registers (beneath, regcache, regnum);
+ beneath->to_store_registers (beneath, regcache, ptid, regnum);
return;
}
- /* Solaris thread: convert INFERIOR_PTID into a td_thrhandle_t. */
- thread = ptid_get_tid (inferior_ptid);
+ /* Solaris thread: convert PTID into a td_thrhandle_t. */
+ thread = ptid_get_tid (ptid);
val = p_td_ta_map_id2thr (main_ta, thread, &thandle);
if (val != TD_OK)
diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c
index b423ce5c40..f0bcc131dc 100644
--- a/gdb/sparc-nat.c
+++ b/gdb/sparc-nat.c
@@ -191,16 +191,17 @@ sparc_fetch_inferior_registers (struct target_ops *ops,
void
sparc_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int pid;
/* NOTE: cagney/2002-12-02: See comment in fetch_inferior_registers
about threaded assumptions. */
- pid = ptid_get_lwp (inferior_ptid);
+ pid = ptid_get_lwp (ptid);
if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = ptid_get_pid (ptid);
if (regnum == -1 || sparc_gregset_supplies_p (gdbarch, regnum))
{
diff --git a/gdb/sparc-nat.h b/gdb/sparc-nat.h
index bfa6961fe9..4ab8130403 100644
--- a/gdb/sparc-nat.h
+++ b/gdb/sparc-nat.h
@@ -47,6 +47,6 @@ extern struct target_ops *sparc_target (void);
extern void sparc_fetch_inferior_registers (struct target_ops *,
struct regcache *, ptid_t, int);
extern void sparc_store_inferior_registers (struct target_ops *,
- struct regcache *, int);
+ struct regcache *, ptid_t, int);
#endif /* sparc-nat.h */
diff --git a/gdb/sparc-ravenscar-thread.c b/gdb/sparc-ravenscar-thread.c
index 0573f8345d..4e63ec5a3c 100644
--- a/gdb/sparc-ravenscar-thread.c
+++ b/gdb/sparc-ravenscar-thread.c
@@ -25,8 +25,6 @@
#include "ravenscar-thread.h"
#include "sparc-ravenscar-thread.h"
-static void sparc_ravenscar_store_registers (struct regcache *regcache,
- int regnum);
static void sparc_ravenscar_prepare_to_store (struct regcache *regcache);
/* Register offsets from a referenced address (exempli gratia the
@@ -152,7 +150,8 @@ sparc_ravenscar_prepare_to_store (struct regcache *regcache)
thread. */
static void
-sparc_ravenscar_store_registers (struct regcache *regcache, int regnum)
+sparc_ravenscar_store_registers (struct regcache *regcache, ptid_t ptid,
+ int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int buf_size = register_size (gdbarch, regnum);
@@ -160,8 +159,7 @@ sparc_ravenscar_store_registers (struct regcache *regcache, int regnum)
ULONGEST register_address;
if (register_in_thread_descriptor_p (regnum))
- register_address =
- ptid_get_tid (inferior_ptid) + sparc_register_offsets [regnum];
+ register_address = ptid_get_tid (ptid) + sparc_register_offsets [regnum];
else if (register_on_stack_p (regnum))
{
regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM,
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index c5b91222c1..a0b28219cf 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -534,7 +534,8 @@ spu_fetch_inferior_registers (struct target_ops *ops,
/* Override the store_inferior_register routine. */
static void
spu_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache,
+ ptid_t ptid, int regno)
{
int fd;
ULONGEST addr;
diff --git a/gdb/spu-multiarch.c b/gdb/spu-multiarch.c
index 6516a10b76..a07909885e 100644
--- a/gdb/spu-multiarch.c
+++ b/gdb/spu-multiarch.c
@@ -196,7 +196,7 @@ spu_fetch_registers (struct target_ops *ops, struct regcache *regcache,
/* Override the to_store_registers routine. */
static void
spu_store_registers (struct target_ops *ops,
- struct regcache *regcache, int regno)
+ struct regcache *regcache, ptid_t ptid, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
struct target_ops *ops_beneath = find_target_beneath (ops);
@@ -206,12 +206,12 @@ spu_store_registers (struct target_ops *ops,
/* This version applies only if we're currently in spu_run. */
if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
{
- ops_beneath->to_store_registers (ops_beneath, regcache, regno);
+ ops_beneath->to_store_registers (ops_beneath, regcache, ptid, regno);
return;
}
/* We must be stopped on a spu_run system call. */
- if (!parse_spufs_run (inferior_ptid, &spufs_fd, &spufs_addr))
+ if (!parse_spufs_run (ptid, &spufs_fd, &spufs_addr))
return;
/* The NPC register is found in PPC memory at SPUFS_ADDR. */
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 01ab150e3a..3f1c236d8f 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -187,29 +187,31 @@ debug_fetch_registers (struct target_ops *self, struct regcache *arg1, ptid_t ar
}
static void
-delegate_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+delegate_store_registers (struct target_ops *self, struct regcache *arg1, ptid_t arg2, int arg3)
{
self = self->beneath;
- self->to_store_registers (self, arg1, arg2);
+ self->to_store_registers (self, arg1, arg2, arg3);
}
static void
-tdefault_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+tdefault_store_registers (struct target_ops *self, struct regcache *arg1, ptid_t arg2, int arg3)
{
noprocess ();
}
static void
-debug_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
+debug_store_registers (struct target_ops *self, struct regcache *arg1, ptid_t arg2, int arg3)
{
fprintf_unfiltered (gdb_stdlog, "-> %s->to_store_registers (...)\n", debug_target.to_shortname);
- debug_target.to_store_registers (&debug_target, arg1, arg2);
+ debug_target.to_store_registers (&debug_target, arg1, arg2, arg3);
fprintf_unfiltered (gdb_stdlog, "<- %s->to_store_registers (", debug_target.to_shortname);
target_debug_print_struct_target_ops_p (&debug_target);
fputs_unfiltered (", ", gdb_stdlog);
target_debug_print_struct_regcache_p (arg1);
fputs_unfiltered (", ", gdb_stdlog);
- target_debug_print_int (arg2);
+ target_debug_print_ptid_t (arg2);
+ fputs_unfiltered (", ", gdb_stdlog);
+ target_debug_print_int (arg3);
fputs_unfiltered (")\n", gdb_stdlog);
}
diff --git a/gdb/target.c b/gdb/target.c
index e57789f15f..6ce0921ac0 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3593,12 +3593,12 @@ target_fetch_registers (struct regcache *regcache, ptid_t ptid, int regno)
}
void
-target_store_registers (struct regcache *regcache, int regno)
+target_store_registers (struct regcache *regcache, ptid_t ptid, int regno)
{
if (!may_write_registers)
error (_("Writing to registers is not allowed (regno %d)"), regno);
- current_target.to_store_registers (¤t_target, regcache, regno);
+ current_target.to_store_registers (¤t_target, regcache, ptid, regno);
if (targetdebug)
{
debug_print_register ("target_store_registers", regcache, regno);
diff --git a/gdb/target.h b/gdb/target.h
index 24a138ff67..d6c07ad44d 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -471,7 +471,8 @@ struct target_ops
void (*to_fetch_registers) (struct target_ops *, struct regcache *, ptid_t,
int)
TARGET_DEFAULT_IGNORE ();
- void (*to_store_registers) (struct target_ops *, struct regcache *, int)
+ void (*to_store_registers) (struct target_ops *, struct regcache *, ptid_t,
+ int)
TARGET_DEFAULT_NORETURN (noprocess ());
void (*to_prepare_to_store) (struct target_ops *, struct regcache *)
TARGET_DEFAULT_NORETURN (noprocess ());
@@ -1391,7 +1392,8 @@ extern void target_fetch_registers (struct regcache *regcache, ptid_t ptid,
It can store as many registers as it wants to, so target_prepare_to_store
must have been previously called. Calls error() if there are problems. */
-extern void target_store_registers (struct regcache *regcache, int regs);
+extern void target_store_registers (struct regcache *regcache, ptid_t ptid,
+ int regs);
/* Get ready to modify the registers array. On machines which store
individual registers, this doesn't need to do anything. On machines
diff --git a/gdb/tilegx-linux-nat.c b/gdb/tilegx-linux-nat.c
index 5c47a3e075..f3e747b570 100644
--- a/gdb/tilegx-linux-nat.c
+++ b/gdb/tilegx-linux-nat.c
@@ -144,14 +144,15 @@ fetch_inferior_registers (struct target_ops *ops,
static void
store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
elf_gregset_t regs;
int tid;
- tid = ptid_get_lwp (inferior_ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ tid = ptid_get_pid (ptid);
if (ptrace (PTRACE_GETREGS, tid, 0, (PTRACE_TYPE_ARG3) ®s) < 0)
perror_with_name (_("Couldn't get registers"));
diff --git a/gdb/vax-bsd-nat.c b/gdb/vax-bsd-nat.c
index 8d1cdf4856..dfc8c8c738 100644
--- a/gdb/vax-bsd-nat.c
+++ b/gdb/vax-bsd-nat.c
@@ -81,17 +81,18 @@ vaxbsd_fetch_inferior_registers (struct target_ops *ops,
static void
vaxbsd_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
vaxbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index c930a37ce3..5094c69871 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -559,9 +559,10 @@ do_windows_store_inferior_registers (const struct regcache *regcache,
/* Store a new register value into the current thread context. */
static void
windows_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int r)
+ struct regcache *regcache,
+ ptid_t ptid, int r)
{
- windows_thread_info *th = thread_rec (ptid_get_tid (inferior_ptid), TRUE);
+ windows_thread_info *th = thread_rec (ptid_get_tid (ptid), TRUE);
/* Check if current_thread exists. Windows sometimes uses a non-existent
thread id in its events. */
diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c
index 688ed5c7d6..467c24968a 100644
--- a/gdb/xtensa-linux-nat.c
+++ b/gdb/xtensa-linux-nat.c
@@ -187,13 +187,13 @@ fetch_gregs (struct regcache *regcache, ptid_t ptid, int regnum)
supply_gregset_reg (regcache, ®s, regnum);
}
-/* Store greg-register(s) in GDB's register
- array into the process/thread specified by TID. */
+/* Store greg-register(s) in REGCACHE into the process/thread specified by
+ PTID. */
static void
-store_gregs (struct regcache *regcache, int regnum)
+store_gregs (struct regcache *regcache, ptid_t ptid, int regnum)
{
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (ptid);
gdb_gregset_t regs;
int areg;
@@ -235,9 +235,9 @@ fetch_xtregs (struct regcache *regcache, ptid_t ptid, int regnum)
}
static void
-store_xtregs (struct regcache *regcache, int regnum)
+store_xtregs (struct regcache *regcache, ptid_t ptid, int regnum)
{
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (ptid);
const xtensa_regtable_t *ptr;
char xtregs [XTENSA_ELF_XTREG_SIZE];
@@ -271,17 +271,18 @@ xtensa_linux_fetch_inferior_registers (struct target_ops *ops,
static void
xtensa_linux_store_inferior_registers (struct target_ops *ops,
- struct regcache *regcache, int regnum)
+ struct regcache *regcache,
+ ptid_t ptid, int regnum)
{
if (regnum == -1)
{
- store_gregs (regcache, regnum);
- store_xtregs (regcache, regnum);
+ store_gregs (regcache, ptid, regnum);
+ store_xtregs (regcache, ptid, regnum);
}
else if ((regnum < xtreg_lo) || (regnum > xtreg_high))
- store_gregs (regcache, regnum);
+ store_gregs (regcache, ptid, regnum);
else
- store_xtregs (regcache, regnum);
+ store_xtregs (regcache, ptid, regnum);
}
/* Called by libthread_db. */
--
2.11.0
^ permalink raw reply [flat|nested] 14+ messages in thread