GDBserver: Pass process_info pointer to target_kill
[deliverable/binutils-gdb.git] / gdb / gdbserver / spu-low.c
index 13f2b353f2092c652f0fccaa95f69e1d4ff25a79..83a31a203d48b1fe1ce0ed834c97682775530854 100644 (file)
@@ -66,7 +66,7 @@ fetch_ppc_register (int regno)
 {
   PTRACE_TYPE_RET res;
 
-  int tid = ptid_get_lwp (current_ptid);
+  int tid = current_ptid.lwp ();
 
 #ifndef __powerpc64__
   /* If running as a 32-bit process on a 64-bit system, we attempt
@@ -151,7 +151,7 @@ fetch_ppc_memory (CORE_ADDR memaddr, char *myaddr, int len)
               / sizeof (PTRACE_TYPE_RET));
   PTRACE_TYPE_RET *buffer;
 
-  int tid = ptid_get_lwp (current_ptid);
+  int tid = current_ptid.lwp ();
 
   buffer = XALLOCAVEC (PTRACE_TYPE_RET, count);
   for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
@@ -176,7 +176,7 @@ store_ppc_memory (CORE_ADDR memaddr, char *myaddr, int len)
               / sizeof (PTRACE_TYPE_RET));
   PTRACE_TYPE_RET *buffer;
 
-  int tid = ptid_get_lwp (current_ptid);
+  int tid = current_ptid.lwp ();
 
   buffer = XALLOCAVEC (PTRACE_TYPE_RET, count);
 
@@ -241,7 +241,7 @@ spu_proc_xfer_spu (const char *annex, unsigned char *readbuf,
   if (!annex)
     return 0;
 
-  sprintf (buf, "/proc/%ld/fd/%s", ptid_get_lwp (current_ptid), annex);
+  sprintf (buf, "/proc/%ld/fd/%s", current_ptid.lwp (), annex);
   fd = open (buf, writebuf? O_WRONLY : O_RDONLY);
   if (fd <= 0)
     return -1;
@@ -326,12 +326,10 @@ spu_attach (unsigned long  pid)
 
 /* Kill the inferior process.  */
 static int
-spu_kill (int pid)
+spu_kill (process_info *process)
 {
   int status, ret;
-  struct process_info *process = find_process_pid (pid);
-  if (process == NULL)
-    return -1;
+  int pid = process->pid;
 
   ptrace (PTRACE_KILL, pid, 0, 0);
 
@@ -348,13 +346,9 @@ spu_kill (int pid)
 
 /* Detach from inferior process.  */
 static int
-spu_detach (int pid)
+spu_detach (process_info *process)
 {
-  struct process_info *process = find_process_pid (pid);
-  if (process == NULL)
-    return -1;
-
-  ptrace (PTRACE_DETACH, pid, 0, 0);
+  ptrace (PTRACE_DETACH, process->pid, 0, 0);
 
   clear_inferiors ();
   remove_process (process);
@@ -368,12 +362,12 @@ spu_mourn (struct process_info *process)
 }
 
 static void
-spu_join (int pid)
+spu_join (process_info *proc)
 {
   int status, ret;
 
   do {
-    ret = waitpid (pid, &status, 0);
+    ret = waitpid (proc->pid, &status, 0);
     if (WIFEXITED (status) || WIFSIGNALED (status))
       break;
   } while (ret != -1 || errno != ECHILD);
@@ -383,7 +377,7 @@ spu_join (int pid)
 static int
 spu_thread_alive (ptid_t ptid)
 {
-  return ptid_equal (ptid, current_ptid);
+  return ptid == current_ptid;
 }
 
 /* Resume process.  */
@@ -394,8 +388,8 @@ spu_resume (struct thread_resume *resume_info, size_t n)
   size_t i;
 
   for (i = 0; i < n; i++)
-    if (ptid_equal (resume_info[i].thread, minus_one_ptid)
-       || ptid_equal (resume_info[i].thread, ptid_of (thr)))
+    if (resume_info[i].thread == minus_one_ptid
+       || resume_info[i].thread == ptid_of (thr))
       break;
 
   if (i == n)
@@ -409,7 +403,7 @@ spu_resume (struct thread_resume *resume_info, size_t n)
   regcache_invalidate ();
 
   errno = 0;
-  ptrace (PTRACE_CONT, ptid_get_lwp (ptid_of (thr)), 0, resume_info[i].sig);
+  ptrace (PTRACE_CONT, ptid_of (thr).lwp (), 0, resume_info[i].sig);
   if (errno)
     perror_with_name ("ptrace");
 }
@@ -418,7 +412,7 @@ spu_resume (struct thread_resume *resume_info, size_t n)
 static ptid_t
 spu_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
 {
-  int pid = ptid_get_pid (ptid);
+  int pid = ptid.pid ();
   int w;
   int ret;
 
@@ -457,7 +451,7 @@ spu_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
       ourstatus->kind =  TARGET_WAITKIND_EXITED;
       ourstatus->value.integer = WEXITSTATUS (w);
       clear_inferiors ();
-      return pid_to_ptid (ret);
+      return ptid_t (ret);
     }
   else if (!WIFSTOPPED (w))
     {
@@ -465,7 +459,7 @@ spu_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
       ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
       ourstatus->value.sig = gdb_signal_from_host (WTERMSIG (w));
       clear_inferiors ();
-      return pid_to_ptid (ret);
+      return ptid_t (ret);
     }
 
   /* After attach, we may have received a SIGSTOP.  Do not return this
This page took 0.028735 seconds and 4 git commands to generate.