{
   struct reg inferior_registers;
   int ret;
+  int lwp = regcache->ptid ().lwp ();
 
   ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     {
 fetch_fp_register (struct regcache *regcache, int regno)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
+
   int ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-                   (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+                   (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   struct vfpreg &vfp = inferior_fp_registers.fpr_vfp;
 
 fetch_fp_regs (struct regcache *regcache)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
   int regno;
 
   ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   if (ret < 0)
     {
 {
   struct gdbarch *gdbarch = regcache->arch ();
   struct reg inferior_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
 
   ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     {
     }
 
   ret = ptrace (PT_SETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to write register %d to inferior"), regno);
 {
   struct gdbarch *gdbarch = regcache->arch ();
   struct reg inferior_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
   int regno;
 
     }
 
   ret = ptrace (PT_SETREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to store general registers"));
 store_fp_register (const struct regcache *regcache, int regno)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-                   (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+                   (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
   struct vfpreg &vfp = inferior_fp_registers.fpr_vfp;
 
   if (ret < 0)
     warning (_("Invalid register number."));
 
   ret = ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
-               (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+               (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to write register %d to inferior"), regno);
 store_fp_regs (const struct regcache *regcache)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
+  int lwp = regcache->ptid ().lwp ();
   if (tdep->vfp_register_count == 0)
     return;
 
                         (char *) &fpregs.fpr_vfp.vfp_fpscr);
 
   int ret = ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
-                   (PTRACE_TYPE_ARG3) &fpregs, 0);
+                   (PTRACE_TYPE_ARG3) &fpregs, lwp);
 
   if (ret < 0)
     warning (_("unable to store floating-point registers"));