Use ptid from regcache in almost all remaining nat files
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 20 Mar 2017 21:37:36 +0000 (17:37 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Mon, 20 Mar 2017 21:37:36 +0000 (17:37 -0400)
This patch contains almost all of the remaining changes needed to make
to_fetch_registers/to_store_registers/to_prepare_to_store independent of
inferior_ptid.  It contains only some "trivial" changes, the more
complicated ones are in separate patches.

gdb/ChangeLog:

* 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.

30 files changed:
gdb/ChangeLog
gdb/i386-linux-nat.c
gdb/ia64-linux-nat.c
gdb/inf-ptrace.c
gdb/m32r-linux-nat.c
gdb/m68k-bsd-nat.c
gdb/m68k-linux-nat.c
gdb/m88k-bsd-nat.c
gdb/mips-fbsd-nat.c
gdb/mips-linux-nat.c
gdb/mips-nbsd-nat.c
gdb/mips64-obsd-nat.c
gdb/nto-procfs.c
gdb/ppc-fbsd-nat.c
gdb/ppc-linux-nat.c
gdb/ppc-nbsd-nat.c
gdb/ppc-obsd-nat.c
gdb/procfs.c
gdb/ravenscar-thread.c
gdb/record-btrace.c
gdb/remote-sim.c
gdb/remote.c
gdb/rs6000-nat.c
gdb/s390-linux-nat.c
gdb/sh-nbsd-nat.c
gdb/sol-thread.c
gdb/sparc-nat.c
gdb/tilegx-linux-nat.c
gdb/vax-bsd-nat.c
gdb/xtensa-linux-nat.c

index 87d385966be1555108e31c371614023e9a097e1b..70d48a5e58d2f97fbbb7ab517b16b848397b52f8 100644 (file)
@@ -1,3 +1,68 @@
+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
index 2c4963b5f40e8786343cfff4b6b9f234dd209667..b08470f3058661807a50594f4fbe210405a6cc24 100644 (file)
@@ -36,6 +36,7 @@
 #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
@@ -94,7 +95,7 @@ int have_ptrace_getfpxregs =
 static void
 fetch_register (struct regcache *regcache, int regno)
 {
-  int tid;
+  pid_t tid;
   int val;
 
   gdb_assert (!have_ptrace_getregs);
@@ -104,10 +105,7 @@ fetch_register (struct regcache *regcache, int regno)
       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,
@@ -125,17 +123,14 @@ fetch_register (struct regcache *regcache, int regno)
 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);
@@ -455,7 +450,7 @@ static void
 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.  */
@@ -470,10 +465,7 @@ i386_linux_fetch_inferior_registers (struct target_ops *ops,
       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
@@ -536,7 +528,7 @@ static void
 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.  */
@@ -551,10 +543,7 @@ i386_linux_store_inferior_registers (struct target_ops *ops,
       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
index e26dd1502506a631bc93e8ee06243ddc9c863809..a532b983859a0c3659045637e5749252a6a64e1d 100644 (file)
@@ -41,6 +41,8 @@
 /* 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
@@ -696,7 +698,8 @@ ia64_linux_fetch_register (struct regcache *regcache, int regnum)
   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)
@@ -735,11 +738,7 @@ ia64_linux_fetch_register (struct regcache *regcache, int 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);
@@ -788,16 +787,13 @@ ia64_linux_store_register (const struct regcache *regcache, int 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);
index 431a36b8c726f8475650de00bf895b8d5f48fa83..61d24269a81fdcdaedee3e1f9a08d09bb0eb9f3f 100644 (file)
@@ -708,7 +708,8 @@ inf_ptrace_fetch_register (struct regcache *regcache, int 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);
@@ -719,11 +720,7 @@ inf_ptrace_fetch_register (struct regcache *regcache, int 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);
@@ -769,7 +766,8 @@ inf_ptrace_store_register (const struct regcache *regcache, int 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, 1);
@@ -777,11 +775,7 @@ inf_ptrace_store_register (const struct regcache *regcache, int regnum)
       || 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);
index 9d9bef385ebf5fe7c8a01b132d65d68caa014813..a33de23dc3296afc3ed34b4422cbebabff127521 100644 (file)
@@ -26,6 +26,7 @@
 #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"
@@ -194,12 +195,7 @@ static void
 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
@@ -221,11 +217,7 @@ static void
 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.  */
index 227da382e63d892c7a3ec5f9b5dc2a708bceeadd..e0aee05ce5ca4489ab206791917dd99f6bdd093c 100644 (file)
@@ -111,12 +111,13 @@ static void
 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) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't get registers"));
 
       m68kbsd_supply_gregset (regcache, &regs);
@@ -126,8 +127,7 @@ m68kbsd_fetch_inferior_registers (struct target_ops *ops,
     {
       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);
@@ -141,18 +141,18 @@ static void
 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) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't get registers"));
 
       m68kbsd_collect_gregset (regcache, &regs, regnum);
 
-      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-                 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't write registers"));
     }
 
@@ -160,14 +160,12 @@ m68kbsd_store_inferior_registers (struct target_ops *ops,
     {
       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"));
     }
 }
index e5182caf39197f759c85c2321e4d66c428f5911e..eb143753222535e16b8c072f0219ec3ee9fa8547 100644 (file)
@@ -51,6 +51,8 @@
 /* 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
@@ -106,13 +108,7 @@ fetch_register (struct regcache *regcache, int regno)
   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))
@@ -159,14 +155,8 @@ store_register (const struct regcache *regcache, int regno)
   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];
 
@@ -406,7 +396,7 @@ static void
 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.  */
@@ -416,10 +406,7 @@ m68k_linux_fetch_inferior_registers (struct target_ops *ops,
       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
@@ -463,7 +450,7 @@ static void
 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.  */
@@ -473,10 +460,7 @@ m68k_linux_store_inferior_registers (struct target_ops *ops,
       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
index 72d363071001290f2dd804c4d686c99674038fb7..9549b8d3a21a0f14bbce2fd46616b12b207d39e7 100644 (file)
@@ -68,7 +68,7 @@ m88kbsd_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 (regcache_get_ptid (regcache)),
              (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
@@ -84,13 +84,13 @@ m88kbsd_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 (regcache_get_ptid (regcache)),
              (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   m88kbsd_collect_gregset (regcache, &regs, regnum);
 
-  if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+  if (ptrace (PT_SETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
              (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't write registers"));
 }
index 0472df88f49545e789aafc10660683bbdce9f3a6..078df52db67c842bf2ddefde224bdbad7673af4f 100644 (file)
@@ -47,13 +47,14 @@ static void
 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) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't get registers"));
 
       mips_fbsd_supply_gregs (regcache, regnum, &regs, sizeof (register_t));
@@ -66,8 +67,7 @@ mips_fbsd_fetch_inferior_registers (struct target_ops *ops,
     {
       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,
@@ -82,20 +82,20 @@ static void
 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) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't get registers"));
 
       mips_fbsd_collect_gregs (regcache, regnum, (char *) &regs,
                               sizeof (register_t));
 
-      if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
-                 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't write registers"));
 
       if (regnum != -1)
@@ -107,15 +107,13 @@ mips_fbsd_store_inferior_registers (struct target_ops *ops,
     {
       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"));
     }
 }
index 9d22773e9cff042948b391133f356e51e7778102..9596b49099b5f6b0190c343cf2166ac493381085 100644 (file)
@@ -34,6 +34,7 @@
 #include <sgidefs.h>
 #include "nat/gdb_ptrace.h"
 #include <asm/ptrace.h>
+#include "inf-ptrace.h"
 
 #include "nat/mips-linux-watch.h"
 
@@ -244,9 +245,7 @@ mips64_linux_regsets_fetch_registers (struct target_ops *ops,
   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))
     {
@@ -332,9 +331,7 @@ mips64_linux_regsets_store_registers (struct target_ops *ops,
   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))
     {
index b7c19dc85f08d2ec43bc30aab8b47419dc661e6d..41e67b7ff51615b2e11dd4dadd353ba4844493c4 100644 (file)
@@ -42,13 +42,14 @@ static void
 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) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't get registers"));
       
       mipsnbsd_supply_reg (regcache, (char *) &regs, regno);
@@ -61,8 +62,7 @@ mipsnbsd_fetch_inferior_registers (struct target_ops *ops,
     {
       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);
@@ -73,19 +73,19 @@ static void
 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) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't get registers"));
 
       mipsnbsd_fill_reg (regcache, (char *) &regs, regno);
 
-      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid), 
-                 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't write registers"));
 
       if (regno != -1)
@@ -97,14 +97,12 @@ mipsnbsd_store_inferior_registers (struct target_ops *ops,
     {
       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"));
     }
 }
index 97af421981a61bfcdee17d9c90c3f4acfdd64ad0..d32af80da09c11b234806a334f6f3a79b0c8919b 100644 (file)
@@ -82,9 +82,9 @@ mips64obsd_fetch_inferior_registers (struct target_ops *ops,
                                     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) &regs, 0) == -1)
+  if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   mips64obsd_supply_gregset (regcache, &regs);
@@ -98,15 +98,14 @@ mips64obsd_store_inferior_registers (struct target_ops *ops,
                                     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) &regs, 0) == -1)
+  if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   mips64obsd_collect_gregset (regcache, &regs, regnum);
 
-  if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+  if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't write registers"));
 }
 \f
index 13b5ccf99f1f91d2141d0a2a48a6696b61ab0722..75f92dcf7805c4c30b96d458469e7ae2de2c6d29 100644 (file)
@@ -868,7 +868,7 @@ procfs_fetch_registers (struct target_ops *ops,
   reg;
   int regsize;
 
-  procfs_set_thread (inferior_ptid);
+  procfs_set_thread (regcache_get_ptid (regcache));
   if (devctl (ctl_fd, DCMD_PROC_GETGREG, &reg, sizeof (reg), &regsize) == EOK)
     nto_supply_gregset (regcache, (char *) &reg.greg);
   if (devctl (ctl_fd, DCMD_PROC_GETFPREG, &reg, sizeof (reg), &regsize)
@@ -1350,10 +1350,11 @@ procfs_store_registers (struct target_ops *ops,
   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)
     {
index 823c063643a771cd06dc93db9caf35e2c1576004..ae5877af9f8a7e0e46fb02a4c8cba0550b4f88bb 100644 (file)
@@ -120,9 +120,9 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops,
                                  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) &regs, 0) == -1)
+  if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   supply_gregset (regcache, &regs);
@@ -132,8 +132,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),
-                 (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);
@@ -148,29 +147,26 @@ ppcfbsd_store_inferior_registers (struct target_ops *ops,
                                  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) &regs, 0) == -1)
+  if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   fill_gregset (regcache, &regs, regno);
 
-  if (ptrace (PT_SETREGS, ptid_get_lwp (inferior_ptid),
-             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+  if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 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"));
     }
 }
index a56d154d3126c69431eff0717d6b4bcbe15f9d96..142fa315b0736f74d787c8cd05d13c11590affa7 100644 (file)
@@ -34,6 +34,7 @@
 #include <fcntl.h>
 #include <sys/procfs.h>
 #include "nat/gdb_ptrace.h"
+#include "inf-ptrace.h"
 
 /* Prototypes for supply_gregset etc.  */
 #include "gregset.h"
@@ -809,12 +810,7 @@ static void
 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);
@@ -2291,12 +2287,7 @@ static void
 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);
index 21d927cc1485d6200061b691adeade5dde89227f..b170583f2a44696126d40232b42fdf6028abdfef 100644 (file)
@@ -81,13 +81,13 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops,
                                  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) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't get registers"));
 
       ppc_supply_gregset (&ppcnbsd_gregset, regcache,
@@ -98,8 +98,7 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops,
     {
       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,
@@ -112,20 +111,19 @@ ppcnbsd_store_inferior_registers (struct target_ops *ops,
                                  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) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't get registers"));
 
       ppc_collect_gregset (&ppcnbsd_gregset, regcache,
                           regnum, &regs, sizeof regs);
 
-      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-                 (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
        perror_with_name (_("Couldn't write registers"));
     }
 
@@ -133,15 +131,13 @@ ppcnbsd_store_inferior_registers (struct target_ops *ops,
     {
       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"));
     }
 }
index 1a39e4629597e3092b2fdafc1cb92f83ab6a4645..20360f53c3b51fa033f1259c34dab5de6464d55e 100644 (file)
@@ -75,9 +75,9 @@ ppcobsd_fetch_registers (struct target_ops *ops,
                         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) &regs, 0) == -1)
+  if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   ppc_supply_gregset (&ppcobsd_gregset, regcache, -1,
@@ -93,8 +93,7 @@ ppcobsd_fetch_registers (struct target_ops *ops,
     {
       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,
@@ -111,9 +110,9 @@ ppcobsd_store_registers (struct target_ops *ops,
                         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) &regs, 0) == -1)
+  if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   ppc_collect_gregset (&ppcobsd_gregset, regcache,
@@ -123,8 +122,7 @@ ppcobsd_store_registers (struct target_ops *ops,
                        regnum, &regs, sizeof regs);
 #endif
 
-  if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+  if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't write registers"));
 
 #ifdef PT_GETFPREGS
@@ -133,15 +131,13 @@ ppcobsd_store_registers (struct target_ops *ops,
     {
       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
index 2269016ce8f629f3d98231f6d93d9ad8b6d76529..b860f1699e7d09a047c1d95cd5f7b622a05de961 100644 (file)
@@ -3219,15 +3219,16 @@ procfs_fetch_registers (struct target_ops *ops,
 {
   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)
@@ -3268,15 +3269,16 @@ procfs_store_registers (struct target_ops *ops,
 {
   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)
index d44c9810f69bf255f4b7fbee07a967db97e9d8f3..d1bd97f3a659599c076b37970ba4541a70899328 100644 (file)
@@ -268,10 +268,11 @@ ravenscar_fetch_registers (struct target_ops *ops,
                            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
     {
@@ -288,10 +289,11 @@ ravenscar_store_registers (struct target_ops *ops,
                            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
     {
@@ -308,10 +310,11 @@ ravenscar_prepare_to_store (struct target_ops *self,
                            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
     {
index f7683f237f43f66f08b3deb296f8bd14a7561fe3..af025e2a1caaf47be5638551a8c59b707e939daf 100644 (file)
@@ -1425,7 +1425,7 @@ record_btrace_fetch_registers (struct target_ops *ops,
   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;
@@ -1466,7 +1466,7 @@ record_btrace_store_registers (struct target_ops *ops,
   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);
@@ -1484,7 +1484,7 @@ record_btrace_prepare_to_store (struct target_ops *ops,
   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;
index b0c68c617e365c0ea18ac2eca525598b688ffbb5..0e8d65779f6f4609cee74700b2edcba6939d24d4 100644 (file)
@@ -429,8 +429,9 @@ gdbsim_fetch_register (struct target_ops *ops,
                       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)
     {
@@ -505,8 +506,9 @@ gdbsim_store_register (struct target_ops *ops,
                       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)
     {
index 3ae40ceeda6dcebd6294ddea1c237e87a5e4b198..2791ac8fb8c3776df6d87aa7600e1a0e71b4618f 100644 (file)
@@ -7711,7 +7711,7 @@ remote_fetch_registers (struct target_ops *ops,
   int i;
 
   set_remote_traceframe ();
-  set_general_thread (inferior_ptid);
+  set_general_thread (regcache_get_ptid (regcache));
 
   if (regnum >= 0)
     {
@@ -7868,7 +7868,7 @@ remote_store_registers (struct target_ops *ops,
   int i;
 
   set_remote_traceframe ();
-  set_general_thread (inferior_ptid);
+  set_general_thread (regcache_get_ptid (regcache));
 
   if (regnum >= 0)
     {
index f42847bfeab8ad6d03c96a161238283a262f98d1..8f5d25cdb3093a4b66296361b948a7e9594da4f7 100644 (file)
@@ -164,6 +164,7 @@ fetch_register (struct regcache *regcache, int regno)
   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;
@@ -172,7 +173,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, pid, addr, nr, 0);
 
   /* Bogus register number.  */
   else if (nr < 0)
@@ -188,15 +189,13 @@ fetch_register (struct regcache *regcache, int regno)
   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
@@ -224,6 +223,7 @@ store_register (struct regcache *regcache, int regno)
   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);
@@ -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, pid, addr, nr, 0);
 
   /* Bogus register number.  */
   else if (nr < 0)
@@ -253,8 +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),
-                        (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
@@ -264,8 +263,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),
-                          nr, 0, &buf);
+         rs6000_ptrace64 (PT_WRITE_GPR, pid, nr, 0, &buf);
        }
     }
 
index 2b205df9de89a6d0cb79219815b1f120c6b10028..90c73c44cd8f83f809a72106179b2931caf3aee5 100644 (file)
@@ -40,6 +40,7 @@
 #include <sys/ucontext.h>
 #include <elf.h>
 #include <algorithm>
+#include "inf-ptrace.h"
 
 /* Per-thread arch-specific data.  */
 
@@ -370,7 +371,7 @@ static void
 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);
@@ -413,7 +414,7 @@ static void
 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);
index 90c9689899d9157f5c07e384a0d181f15b46f4b8..ac93dcd59c991a6f90467cb3163677bbf3456c6b 100644 (file)
@@ -45,11 +45,13 @@ static void
 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"));
 
@@ -66,11 +68,13 @@ static void
 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"));
 
@@ -78,7 +82,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, pid,
                  (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
        perror_with_name (_("Couldn't set registers"));
 
index a09a3ab9a8bc56f367e3ba1537f5674f0a7f491f..efb3bd0b218fdba2c468a0e3952ac109866065a6 100644 (file)
@@ -462,16 +462,17 @@ sol_thread_fetch_registers (struct target_ops *ops,
   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"));
 
@@ -514,8 +515,9 @@ sol_thread_store_registers (struct target_ops *ops,
   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);
 
@@ -524,8 +526,8 @@ sol_thread_store_registers (struct target_ops *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)
index b058ccf1e78434c4c9a4b19d0530344b98739e80..b842f2b48279390c8e03e475b4be1b3607dfd68e 100644 (file)
@@ -138,7 +138,7 @@ sparc_fetch_inferior_registers (struct target_ops *ops,
                                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
@@ -153,9 +153,7 @@ 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);
-  if (pid == 0)
-    pid = ptid_get_pid (inferior_ptid);
+  pid = get_ptrace_pid (regcache_get_ptid (regcache));
 
   if (regnum == SPARC_G0_REGNUM)
     {
@@ -193,13 +191,11 @@ sparc_store_inferior_registers (struct target_ops *ops,
                                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))
     {
index c0833cf74bdc04a4a41a61055af168dc95686e54..5cdf74daf2f5f2b2f082f8769e36d8dc52e6f4d1 100644 (file)
@@ -22,6 +22,7 @@
 #include "gdbcore.h"
 #include "regcache.h"
 #include "linux-nat.h"
+#include "inf-ptrace.h"
 
 #include "nat/gdb_ptrace.h"
 
@@ -126,11 +127,7 @@ fetch_inferior_registers (struct target_ops *ops,
                          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) &regs) < 0)
     perror_with_name (_("Couldn't get registers"));
@@ -146,11 +143,7 @@ store_inferior_registers (struct target_ops *ops,
                          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) &regs) < 0)
     perror_with_name (_("Couldn't get registers"));
index a8bc603679a2083b1be1b2fcb32b83894f0fa7f0..62953682d311be63e53fb124d942048c208bbe19 100644 (file)
@@ -67,9 +67,9 @@ vaxbsd_fetch_inferior_registers (struct target_ops *ops,
                                 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) &regs, 0) == -1)
+  if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   vaxbsd_supply_gregset (regcache, &regs);
@@ -83,15 +83,14 @@ vaxbsd_store_inferior_registers (struct target_ops *ops,
                                 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) &regs, 0) == -1)
+  if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't get registers"));
 
   vaxbsd_collect_gregset (regcache, &regs, regnum);
 
-  if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-             (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+  if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
     perror_with_name (_("Couldn't write registers"));
 }
 \f
index c29f0c71e66b3511f21089b27b2b08b11f0e1f9c..69c7eefa664b1d5f6070be027520f0a2cb8cc835 100644 (file)
@@ -174,7 +174,7 @@ supply_fpregset (struct regcache *regcache,
 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;
   
@@ -193,7 +193,7 @@ fetch_gregs (struct regcache *regcache, int regnum)
 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;
 
@@ -221,7 +221,7 @@ static int xtreg_high;
 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];
 
@@ -237,7 +237,7 @@ fetch_xtregs (struct regcache *regcache, int regnum)
 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];
 
This page took 0.079138 seconds and 4 git commands to generate.