+2016-01-19 John Baldwin <jhb@FreeBSD.org>
+
+ * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Use
+ get_ptrace_pid.
+ (amd64bsd_store_inferior_registers): Use get_ptrace_pid.
+ (amd64bsd_dr_get): Use get_ptrace_pid.
+ (amd64bsd_dr_set): Use get_ptrace_pid.
+ * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Use get_ptrace_pid.
+ (i386bsd_store_inferior_registers): Use get_ptrace_pid.
+ (i386bsd_dr_get): Use get_ptrace_pid.
+ (i386bsd_dr_set): Use get_ptrace_pid.
+ * inf-ptrace.c (get_ptrace_pid): Export.
+ * inf-ptrace.h (get_ptrace_pid): Declare.
+ * ppcfbsd-nat.c (ppcfbsd_fetch_inferior_registers): Use lwp id.
+ (ppcfbsd_store_inferior_registers): Use lwp id.
+
2016-01-19 John Baldwin <jhb@FreeBSD.org>
* fbsd_tdep.c (fbsd_core_pid_to_str): New function.
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
if (amd64bsd_xsave_len != 0)
{
xstateregs = alloca (amd64bsd_xsave_len);
- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
perror_with_name (_("Couldn't get extended state status"));
}
#endif
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_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, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
if (amd64bsd_xsave_len != 0)
{
xstateregs = alloca (amd64bsd_xsave_len);
- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_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, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETXSTATE, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xstateregs, amd64bsd_xsave_len) == -1)
perror_with_name (_("Couldn't write extended state status"));
return;
}
#endif
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_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, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
{
struct dbreg dbregs;
- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't read debug registers"));
{
struct dbreg dbregs;
- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't get debug registers"));
DBREG_DRX ((&dbregs), regnum) = value;
- if (ptrace (PT_SETDBREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETDBREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't write debug registers"));
}
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
char *xstateregs;
xstateregs = alloca (i386bsd_xsave_len);
- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
perror_with_name (_("Couldn't get extended state status"));
#ifdef HAVE_PT_GETXMMREGS
if (have_ptrace_xmmregs != 0
- && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
+ && ptrace(PT_GETXMMREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
{
have_ptrace_xmmregs = 1;
{
have_ptrace_xmmregs = 0;
#endif
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
i386bsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
char *xstateregs;
xstateregs = alloca (i386bsd_xsave_len);
- if (ptrace (PT_GETXSTATE, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_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, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETXSTATE, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xstateregs, i386bsd_xsave_len) == -1)
perror_with_name (_("Couldn't write extended state status"));
return;
#ifdef HAVE_PT_GETXMMREGS
if (have_ptrace_xmmregs != 0
- && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
+ && ptrace(PT_GETXMMREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
{
have_ptrace_xmmregs = 1;
i387_collect_fxsave (regcache, regnum, xmmregs);
- if (ptrace (PT_SETXMMREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETXMMREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == -1)
perror_with_name (_("Couldn't write XMM registers"));
}
{
have_ptrace_xmmregs = 0;
#endif
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_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, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
#ifdef HAVE_PT_GETXMMREGS
{
struct dbreg dbregs;
- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't read debug registers"));
{
struct dbreg dbregs;
- if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't get debug registers"));
DBREG_DRX ((&dbregs), regnum) = value;
- if (ptrace (PT_SETDBREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_SETDBREGS, get_ptrace_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't write debug registers"));
}
/* Return which PID to pass to ptrace in order to observe/control the
tracee identified by PTID. */
-static pid_t
+pid_t
get_ptrace_pid (ptid_t ptid)
{
pid_t pid;
inf_ptrace_trad_target (CORE_ADDR (*register_u_offset)
(struct gdbarch *, int, int));
+/* Return which PID to pass to ptrace in order to observe/control the
+ tracee identified by PTID. */
+
+extern pid_t get_ptrace_pid (ptid_t);
+
#endif
{
gdb_gregset_t regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_lwp (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
const struct regset *fpregset = ppc_fbsd_fpregset ();
gdb_fpregset_t fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_lwp (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
{
gdb_gregset_t regs;
- if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_lwp (inferior_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_pid (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_lwp (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
{
gdb_fpregset_t fpregs;
- if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_lwp (inferior_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_pid (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_lwp (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't set FP registers"));
}