+2017-03-20 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * i386-linux-nat.c (fetch_register, store_register,
+ i386_linux_fetch_inferior_registers,
+ i386_linux_store_inferior_registers): Use ptid from regcache.
+ * ia64-linux-nat.c (ia64_linux_fetch_register,
+ ia64_linux_store_register): Likewise.
+ * inf-ptrace.c (inf_ptrace_fetch_register,
+ inf_ptrace_store_register): Likewise.
+ * m32r-linux-nat.c (m32r_linux_fetch_inferior_registers,
+ m32r_linux_store_inferior_registers): Likewise.
+ * m68k-bsd-nat.c (m68kbsd_fetch_inferior_registers,
+ m68kbsd_store_inferior_registers): Likewise.
+ * m68k-linux-nat.c (fetch_register, store_register,
+ m68k_linux_fetch_inferior_registers,
+ m68k_linux_store_inferior_registers): Likewise.
+ * m88k-bsd-nat.c (m88kbsd_fetch_inferior_registers,
+ m88kbsd_store_inferior_registers): Likewise.
+ * mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers,
+ mips_fbsd_store_inferior_registers): Likewise.
+ * mips-linux-nat.c (mips64_linux_regsets_fetch_registers,
+ mips64_linux_regsets_store_registers): Likewise.
+ * mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers,
+ mipsnbsd_store_inferior_registers): Likewise.
+ * mips-obsd-nat.c (mips64obsd_fetch_inferior_registers,
+ mips64obsd_store_inferior_registers): Likewise.
+ * nto-procfs.c (procfs_fetch_registers, procfs_store_registers):
+ Likewise.
+ * ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers,
+ ppcfbsd_store_inferior_registers): Likewise.
+ * ppc-linux-nat.c (ppc_linux_fetch_inferior_registers,
+ ppc_linux_store_inferior_registers): Likewise.
+ * ppc-nbsd-nat.c (ppcnbsd_fetch_inferior_registers,
+ ppcnbsd_store_inferior_registers): Likewise.
+ * ppc-obsd-nat.c (ppcobsd_fetch_registers,
+ ppcobsd_store_registers): Likewise.
+ * procfs.c (procfs_fetch_registers, procfs_store_registers):
+ Likewise.
+ * ravenscar-thread.c (ravenscar_fetch_registers,
+ ravenscar_store_registers, ravenscar_prepare_to_store):
+ Likewise.
+ * record-btrace.c (record_btrace_fetch_registers,
+ record_btrace_store_registers, record_btrace_prepare_to_store):
+ Likewise.
+ * remote-sim.c (gdbsim_fetch_register, gdbsim_store_register):
+ Lookup inferior using ptid from regcache, instead of
+ current_inferior.
+ * remote.c (remote_fetch_registers, remote_store_registers): Use
+ ptid from regcache.
+ * rs6000-nat.c (fetch_register, store_register): Likewise.
+ * s390-linux-nat.c (s390_linux_fetch_inferior_registers,
+ s390_linux_store_inferior_registers): Likewise.
+ * sh-nbsd-nat.c (shnbsd_fetch_inferior_registers,
+ shnbsd_store_inferior_registers): Likewise.
+ * sol-thread.c (sol_thread_fetch_registers,
+ sol_thread_store_registers): Likewise.
+ * sparc-nat.c (sparc_fetch_inferior_registers,
+ sparc_store_inferior_registers): Likewise.
+ * tilegx-linux-nat.c (fetch_inferior_registers,
+ store_inferior_registers): Likewise.
+ * vax-bsd-nat.c (vaxbsd_fetch_inferior_registers,
+ vaxbsd_store_inferior_registers): Likewise.
+ * xtensa-linux-nat.c (fetch_gregs, store_gregs, fetch_xtregs,
+ store_xtregs): Likewise.
+
2017-03-20 Artemiy Volkov <artemiyv@acm.org>
PR gdb/14441
#include "linux-nat.h"
#include "x86-linux-nat.h"
#include "nat/linux-ptrace.h"
+#include "inf-ptrace.h"
/* The register sets used in GNU/Linux ELF core-dumps are identical to
the register sets in `struct user' that is used for a.out
static void
fetch_register (struct regcache *regcache, int regno)
{
- int tid;
+ pid_t tid;
int val;
gdb_assert (!have_ptrace_getregs);
return;
}
- /* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = get_ptrace_pid (regcache_get_ptid (regcache));
errno = 0;
val = ptrace (PTRACE_PEEKUSER, tid,
static void
store_register (const struct regcache *regcache, int regno)
{
- int tid;
+ pid_t tid;
int val;
gdb_assert (!have_ptrace_getregs);
if (i386_linux_gregset_reg_offset[regno] == -1)
return;
- /* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = get_ptrace_pid (regcache_get_ptid (regcache));
errno = 0;
regcache_raw_collect (regcache, regno, &val);
i386_linux_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
- int tid;
+ pid_t tid;
/* Use the old method of peeking around in `struct user' if the
GETREGS request isn't available. */
return;
}
- /* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = get_ptrace_pid (regcache_get_ptid (regcache));
/* Use the PTRACE_GETFPXREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
i386_linux_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
- int tid;
+ pid_t tid;
/* Use the old method of poking around in `struct user' if the
SETREGS request isn't available. */
return;
}
- /* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = get_ptrace_pid (regcache_get_ptid (regcache));
/* Use the PTRACE_SETFPXREGS requests whenever possible, since it
transfers more registers in one system call. But remember that
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
+#include "inf-ptrace.h"
+
/* These must match the order of the register names.
Some sort of lookup table is needed because the offsets associated
CORE_ADDR addr;
size_t size;
PTRACE_TYPE_RET *buf;
- int pid, i;
+ pid_t pid;
+ int i;
/* r0 cannot be fetched but is always zero. */
if (regnum == IA64_GR0_REGNUM)
return;
}
- /* Cater for systems like GNU/Linux, that implement threads as
- separate processes. */
- pid = ptid_get_lwp (inferior_ptid);
- if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = get_ptrace_pid (regcache_get_ptid (regcache));
/* This isn't really an address, but ptrace thinks of it as one. */
addr = ia64_register_addr (gdbarch, regnum);
CORE_ADDR addr;
size_t size;
PTRACE_TYPE_RET *buf;
- int pid, i;
+ pid_t pid;
+ int i;
if (ia64_cannot_store_register (gdbarch, regnum))
return;
- /* Cater for systems like GNU/Linux, that implement threads as
- separate processes. */
- pid = ptid_get_lwp (inferior_ptid);
- if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = get_ptrace_pid (regcache_get_ptid (regcache));
/* This isn't really an address, but ptrace thinks of it as one. */
addr = ia64_register_addr (gdbarch, regnum);
CORE_ADDR addr;
size_t size;
PTRACE_TYPE_RET *buf;
- int pid, i;
+ pid_t pid;
+ int i;
/* This isn't really an address, but ptrace thinks of it as one. */
addr = inf_ptrace_register_u_offset (gdbarch, regnum, 0);
return;
}
- /* Cater for systems like GNU/Linux, that implement threads as
- separate processes. */
- pid = ptid_get_lwp (inferior_ptid);
- if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = get_ptrace_pid (regcache_get_ptid (regcache));
size = register_size (gdbarch, regnum);
gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
CORE_ADDR addr;
size_t size;
PTRACE_TYPE_RET *buf;
- int pid, i;
+ pid_t pid;
+ int i;
/* This isn't really an address, but ptrace thinks of it as one. */
addr = inf_ptrace_register_u_offset (gdbarch, regnum, 1);
|| gdbarch_cannot_store_register (gdbarch, regnum))
return;
- /* Cater for systems like GNU/Linux, that implement threads as
- separate processes. */
- pid = ptid_get_lwp (inferior_ptid);
- if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = get_ptrace_pid (regcache_get_ptid (regcache));
size = register_size (gdbarch, regnum);
gdb_assert ((size % sizeof (PTRACE_TYPE_RET)) == 0);
#include "nat/gdb_ptrace.h"
#include <sys/user.h>
#include <sys/procfs.h>
+#include "inf-ptrace.h"
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
m32r_linux_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
- int tid;
-
- /* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
/* Use the PTRACE_GETREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
m32r_linux_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, 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. */
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
/* Use the PTRACE_SETREGS request whenever possible, since it
transfers more registers in one system call. */
m68kbsd_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
m68kbsd_supply_gregset (regcache, ®s);
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
m68kbsd_supply_fpregset (regcache, &fpregs);
m68kbsd_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (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),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
}
/* Defines ps_err_e, struct ps_prochandle. */
#include "gdb_proc_service.h"
+#include "inf-ptrace.h"
+
#ifndef PTRACE_GET_THREAD_AREA
#define PTRACE_GET_THREAD_AREA 25
#endif
long regaddr, val;
int i;
gdb_byte buf[M68K_MAX_REGISTER_SIZE];
- int tid;
-
- /* Overload thread id onto process id. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* no thread id, just use
- process id. */
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
regaddr = 4 * regmap[regno];
for (i = 0; i < register_size (gdbarch, regno); i += sizeof (long))
struct gdbarch *gdbarch = get_regcache_arch (regcache);
long regaddr, val;
int i;
- int tid;
gdb_byte buf[M68K_MAX_REGISTER_SIZE];
-
- /* Overload thread id onto process id. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* no thread id, just use
- process id. */
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
regaddr = 4 * regmap[regno];
m68k_linux_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
- int tid;
+ pid_t tid;
/* Use the old method of peeking around in `struct user' if the
GETREGS request isn't available. */
return;
}
- /* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = get_ptrace_pid (regcache_get_ptid (regcache));
/* Use the PTRACE_GETFPXREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
m68k_linux_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
- int tid;
+ pid_t tid;
/* Use the old method of poking around in `struct user' if the
SETREGS request isn't available. */
return;
}
- /* GNU/Linux LWP ID's are process ID's. */
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
+ tid = get_ptrace_pid (regcache_get_ptid (regcache));
/* Use the PTRACE_SETFPREGS requests whenever possible, since it
transfers more registers in one system call. But remember that
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
(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 (regcache_get_ptid (regcache)),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
+
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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
mips_fbsd_supply_gregs (regcache, regnum, ®s, sizeof (register_t));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
mips_fbsd_supply_fpregs (regcache, regnum, &fpregs,
mips_fbsd_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
+ pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
+
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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
if (regnum != -1)
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (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),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
}
#include <sgidefs.h>
#include "nat/gdb_ptrace.h"
#include <asm/ptrace.h>
+#include "inf-ptrace.h"
#include "nat/mips-linux-watch.h"
else
is_dsp = 0;
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ tid = get_ptrace_pid (regcache_get_ptid (regcache));
if (regno == -1 || (!is_fp && !is_dsp))
{
else
is_dsp = 0;
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ tid = get_ptrace_pid (regcache_get_ptid (regcache));
if (regno == -1 || (!is_fp && !is_dsp))
{
mipsnbsd_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
mipsnbsd_supply_reg (regcache, (char *) ®s, regno);
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
mipsnbsd_supply_fpreg (regcache, (char *) &fpregs, regno);
mipsnbsd_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
if (regno != -1)
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (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),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
}
struct regcache *regcache, int regnum)
{
struct reg regs;
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
mips64obsd_supply_gregset (regcache, ®s);
struct regcache *regcache, int regnum)
{
struct reg regs;
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
\f
reg;
int regsize;
- procfs_set_thread (inferior_ptid);
+ procfs_set_thread (regcache_get_ptid (regcache));
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)
unsigned off;
int len, regset, regsize, dev_set, err;
char *data;
+ ptid_t ptid = regcache_get_ptid (regcache);
- 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)
{
struct regcache *regcache, int regno)
{
gdb_gregset_t regs;
+ pid_t pid = ptid_get_lwp (regcache_get_ptid (regcache));
- if (ptrace (PT_GETREGS, ptid_get_lwp (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
supply_gregset (regcache, ®s);
const struct regset *fpregset = ppc_fbsd_fpregset ();
gdb_fpregset_t fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_lwp (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
ppc_supply_fpregset (fpregset, regcache, regno, &fpregs, sizeof fpregs);
struct regcache *regcache, int regno)
{
gdb_gregset_t regs;
+ pid_t pid = ptid_get_lwp (regcache_get_ptid (regcache));
- if (ptrace (PT_GETREGS, ptid_get_lwp (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
if (regno == -1 || getfpregs_supplies (get_regcache_arch (regcache), regno))
{
gdb_fpregset_t fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_lwp (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (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),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't set FP registers"));
}
}
#include <fcntl.h>
#include <sys/procfs.h>
#include "nat/gdb_ptrace.h"
+#include "inf-ptrace.h"
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
ppc_linux_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
- /* Overload thread id onto process id. */
- int tid = ptid_get_lwp (inferior_ptid);
-
- /* No thread id, just use process id. */
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
if (regno == -1)
fetch_ppc_registers (regcache, tid);
ppc_linux_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
- /* Overload thread id onto process id. */
- int tid = ptid_get_lwp (inferior_ptid);
-
- /* No thread id, just use process id. */
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
if (regno >= 0)
store_register (regcache, tid, regno);
struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
if (regnum == -1 || getregs_supplies (gdbarch, regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
ppc_supply_gregset (&ppcnbsd_gregset, regcache,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
ppc_supply_fpregset (&ppcnbsd_fpregset, regcache,
struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
if (regnum == -1 || getregs_supplies (gdbarch, regnum))
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (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),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't set FP registers"));
}
}
struct regcache *regcache, int regnum)
{
struct reg regs;
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
ppc_supply_gregset (&ppcobsd_gregset, regcache, -1,
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
ppc_supply_fpregset (&ppcobsd_fpregset, regcache, -1,
struct regcache *regcache, int regnum)
{
struct reg regs;
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
ppc_collect_gregset (&ppcobsd_gregset, regcache,
regnum, ®s, sizeof regs);
#endif
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
#ifdef PT_GETFPREGS
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_GETFPREGS, pid, (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),
- (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+ if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
#endif
{
gdb_gregset_t *gregs;
procinfo *pi;
- int pid = ptid_get_pid (inferior_ptid);
- int tid = ptid_get_lwp (inferior_ptid);
+ ptid_t ptid = regcache_get_ptid (regcache);
+ 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)
{
gdb_gregset_t *gregs;
procinfo *pi;
- int pid = ptid_get_pid (inferior_ptid);
- int tid = ptid_get_lwp (inferior_ptid);
+ ptid_t ptid = regcache_get_ptid (regcache);
+ 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)
struct regcache *regcache, int regnum)
{
struct target_ops *beneath = find_target_beneath (ops);
+ ptid_t ptid = regcache_get_ptid (regcache);
if (!ravenscar_runtime_initialized ()
- || ptid_equal (inferior_ptid, base_magic_null_ptid)
- || ptid_equal (inferior_ptid, ravenscar_running_thread ()))
+ || ptid_equal (ptid, base_magic_null_ptid)
+ || ptid_equal (ptid, ravenscar_running_thread ()))
beneath->to_fetch_registers (beneath, regcache, regnum);
else
{
struct regcache *regcache, int regnum)
{
struct target_ops *beneath = find_target_beneath (ops);
+ ptid_t ptid = regcache_get_ptid (regcache);
if (!ravenscar_runtime_initialized ()
- || ptid_equal (inferior_ptid, base_magic_null_ptid)
- || ptid_equal (inferior_ptid, ravenscar_running_thread ()))
+ || ptid_equal (ptid, base_magic_null_ptid)
+ || ptid_equal (ptid, ravenscar_running_thread ()))
beneath->to_store_registers (beneath, regcache, regnum);
else
{
struct regcache *regcache)
{
struct target_ops *beneath = find_target_beneath (self);
+ ptid_t ptid = regcache_get_ptid (regcache);
if (!ravenscar_runtime_initialized ()
- || ptid_equal (inferior_ptid, base_magic_null_ptid)
- || ptid_equal (inferior_ptid, ravenscar_running_thread ()))
+ || ptid_equal (ptid, base_magic_null_ptid)
+ || ptid_equal (ptid, ravenscar_running_thread ()))
beneath->to_prepare_to_store (beneath, regcache);
else
{
struct btrace_insn_iterator *replay;
struct thread_info *tp;
- tp = find_thread_ptid (inferior_ptid);
+ tp = find_thread_ptid (regcache_get_ptid (regcache));
gdb_assert (tp != NULL);
replay = tp->btrace.replay;
struct target_ops *t;
if (!record_btrace_generating_corefile
- && record_btrace_is_replaying (ops, inferior_ptid))
+ && record_btrace_is_replaying (ops, regcache_get_ptid (regcache)))
error (_("Cannot write registers while replaying."));
gdb_assert (may_write_registers != 0);
struct target_ops *t;
if (!record_btrace_generating_corefile
- && record_btrace_is_replaying (ops, inferior_ptid))
+ && record_btrace_is_replaying (ops, regcache_get_ptid (regcache)))
return;
t = ops->beneath;
struct regcache *regcache, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct inferior *inf = find_inferior_ptid (regcache_get_ptid (regcache));
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)
{
struct regcache *regcache, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct inferior *inf = find_inferior_ptid (regcache_get_ptid (regcache));
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)
{
int i;
set_remote_traceframe ();
- set_general_thread (inferior_ptid);
+ set_general_thread (regcache_get_ptid (regcache));
if (regnum >= 0)
{
int i;
set_remote_traceframe ();
- set_general_thread (inferior_ptid);
+ set_general_thread (regcache_get_ptid (regcache));
if (regnum >= 0)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE];
int nr, isfloat;
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
/* Retrieved values may be -1, so infer errors from errno. */
errno = 0;
/* Floating-point registers. */
if (isfloat)
- rs6000_ptrace32 (PT_READ_FPR, ptid_get_pid (inferior_ptid), addr, nr, 0);
+ rs6000_ptrace32 (PT_READ_FPR, pid, addr, nr, 0);
/* Bogus register number. */
else if (nr < 0)
else
{
if (!ARCH64 ())
- *addr = rs6000_ptrace32 (PT_READ_GPR, ptid_get_pid (inferior_ptid),
- (int *) nr, 0, 0);
+ *addr = rs6000_ptrace32 (PT_READ_GPR, pid, (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),
- nr, 0, &buf);
+ rs6000_ptrace64 (PT_READ_GPR, pid, nr, 0, &buf);
if (register_size (gdbarch, regno) == 8)
memcpy (addr, &buf, 8);
else
struct gdbarch *gdbarch = get_regcache_arch (regcache);
int addr[MAX_REGISTER_SIZE];
int nr, isfloat;
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
/* Fetch the register's value from the register cache. */
regcache_raw_collect (regcache, regno, addr);
/* Floating-point registers. */
if (isfloat)
- rs6000_ptrace32 (PT_WRITE_FPR, ptid_get_pid (inferior_ptid), addr, nr, 0);
+ rs6000_ptrace32 (PT_WRITE_FPR, pid, addr, nr, 0);
/* Bogus register number. */
else if (nr < 0)
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),
- (int *) nr, *addr, 0);
+ rs6000_ptrace32 (PT_WRITE_GPR, pid, (int *) nr, *addr, 0);
else
{
/* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte
memcpy (&buf, addr, 8);
else
buf = *addr;
- rs6000_ptrace64 (PT_WRITE_GPR, ptid_get_pid (inferior_ptid),
- nr, 0, &buf);
+ rs6000_ptrace64 (PT_WRITE_GPR, pid, nr, 0, &buf);
}
}
#include <sys/ucontext.h>
#include <elf.h>
#include <algorithm>
+#include "inf-ptrace.h"
/* Per-thread arch-specific data. */
s390_linux_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
- int tid = s390_inferior_tid ();
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
if (regnum == -1 || S390_IS_GREGSET_REGNUM (regnum))
fetch_regs (regcache, tid);
s390_linux_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regnum)
{
- int tid = s390_inferior_tid ();
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
if (regnum == -1 || S390_IS_GREGSET_REGNUM (regnum))
store_regs (regcache, tid, regnum);
shnbsd_fetch_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
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, pid,
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't get registers"));
shnbsd_store_inferior_registers (struct target_ops *ops,
struct regcache *regcache, int regno)
{
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
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, pid,
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't get registers"));
(char *) &inferior_registers,
SHNBSD_SIZEOF_GREGS);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, pid,
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't set registers"));
gdb_gregset_t *gregset_p = &gregset;
gdb_fpregset_t *fpregset_p = &fpregset;
struct target_ops *beneath = find_target_beneath (ops);
+ ptid_t ptid = regcache_get_ptid (regcache);
- 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);
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"));
td_err_e val;
prgregset_t gregset;
prfpregset_t fpregset;
+ ptid_t ptid = regcache_get_ptid (regcache);
- if (!ptid_tid_p (inferior_ptid))
+ if (!ptid_tid_p (ptid))
{
struct target_ops *beneath = find_target_beneath (ops);
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)
struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
- int pid;
+ pid_t pid;
/* NOTE: cagney/2002-12-03: This code assumes that the currently
selected light weight processes' registers can be written
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);
- if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = get_ptrace_pid (regcache_get_ptid (regcache));
if (regnum == SPARC_G0_REGNUM)
{
struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
- int pid;
+ pid_t pid;
/* NOTE: cagney/2002-12-02: See comment in fetch_inferior_registers
about threaded assumptions. */
- pid = ptid_get_lwp (inferior_ptid);
- if (pid == 0)
- pid = ptid_get_pid (inferior_ptid);
+ pid = get_ptrace_pid (regcache_get_ptid (regcache));
if (regnum == -1 || sparc_gregset_supplies_p (gdbarch, regnum))
{
#include "gdbcore.h"
#include "regcache.h"
#include "linux-nat.h"
+#include "inf-ptrace.h"
#include "nat/gdb_ptrace.h"
struct regcache *regcache, int regnum)
{
elf_gregset_t regs;
- int tid;
-
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
if (ptrace (PTRACE_GETREGS, tid, 0, (PTRACE_TYPE_ARG3) ®s) < 0)
perror_with_name (_("Couldn't get registers"));
struct regcache *regcache, int regnum)
{
elf_gregset_t regs;
- int tid;
-
- tid = ptid_get_lwp (inferior_ptid);
- if (tid == 0)
- tid = ptid_get_pid (inferior_ptid);
+ pid_t tid = get_ptrace_pid (regcache_get_ptid (regcache));
if (ptrace (PTRACE_GETREGS, tid, 0, (PTRACE_TYPE_ARG3) ®s) < 0)
perror_with_name (_("Couldn't get registers"));
struct regcache *regcache, int regnum)
{
struct reg regs;
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
vaxbsd_supply_gregset (regcache, ®s);
struct regcache *regcache, int regnum)
{
struct reg regs;
+ pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_GETREGS, pid, (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),
- (PTRACE_TYPE_ARG3) ®s, 0) == -1)
+ if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
\f
static void
fetch_gregs (struct regcache *regcache, int regnum)
{
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (regcache_get_ptid (regcache));
gdb_gregset_t regs;
int areg;
static void
store_gregs (struct regcache *regcache, int regnum)
{
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (regcache_get_ptid (regcache));
gdb_gregset_t regs;
int areg;
static void
fetch_xtregs (struct regcache *regcache, int regnum)
{
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (regcache_get_ptid (regcache));
const xtensa_regtable_t *ptr;
char xtregs [XTENSA_ELF_XTREG_SIZE];
static void
store_xtregs (struct regcache *regcache, int regnum)
{
- int tid = ptid_get_lwp (inferior_ptid);
+ int tid = ptid_get_lwp (regcache_get_ptid (regcache));
const xtensa_regtable_t *ptr;
char xtregs [XTENSA_ELF_XTREG_SIZE];