gdb: remove interp_pre_command_loop
[binutils-gdb.git] / gdb / procfs.c
index 741e62a24026e5fb75e40931ba1760229f116ecf..d55a16a9fb53cafdafc2ef7a244772c0c47048c1 100644 (file)
@@ -589,6 +589,8 @@ static int proc_iterate_over_threads
   (procinfo *pi,
    int (*func) (procinfo *, procinfo *, void *),
    void *ptr);
+static void proc_resume (procinfo *pi, ptid_t scope_ptid,
+                        int step, enum gdb_signal signo);
 
 static void
 proc_warn (procinfo *pi, const char *func, int line)
@@ -2115,11 +2117,8 @@ wait_again:
              case PR_SYSENTRY:
                if (what == SYS_lwp_exit)
                  {
-                   if (print_thread_events)
-                     gdb_printf (_("[%s exited]\n"),
-                                 target_pid_to_str (retval).c_str ());
-                   delete_thread (find_thread_ptid (this, retval));
-                   target_continue_no_signal (ptid);
+                   delete_thread (this->find_thread (retval));
+                   proc_resume (pi, ptid, 0, GDB_SIGNAL_0);
                    goto wait_again;
                  }
                else if (what == SYS_exit)
@@ -2183,8 +2182,7 @@ wait_again:
                                      i, sysargs[i]);
                      }
 
-                   /* How to keep going without returning to wfi: */
-                   target_continue_no_signal (ptid);
+                   proc_resume (pi, ptid, 0, GDB_SIGNAL_0);
                    goto wait_again;
                  }
                break;
@@ -2217,15 +2215,12 @@ wait_again:
                    if (!in_thread_list (this, temp_ptid))
                      add_thread (this, temp_ptid);
 
-                   target_continue_no_signal (ptid);
+                   proc_resume (pi, ptid, 0, GDB_SIGNAL_0);
                    goto wait_again;
                  }
                else if (what == SYS_lwp_exit)
                  {
-                   if (print_thread_events)
-                     gdb_printf (_("[%s exited]\n"),
-                                 target_pid_to_str (retval).c_str ());
-                   delete_thread (find_thread_ptid (this, retval));
+                   delete_thread (this->find_thread (retval));
                    status->set_spurious ();
                    return retval;
                  }
@@ -2249,7 +2244,7 @@ wait_again:
                                      i, sysargs[i]);
                      }
 
-                   target_continue_no_signal (ptid);
+                   proc_resume (pi, ptid, 0, GDB_SIGNAL_0);
                    goto wait_again;
                  }
                break;
@@ -2428,20 +2423,16 @@ invalidate_cache (procinfo *parent, procinfo *pi, void *ptr)
   return 0;
 }
 
-/* Make the child process runnable.  Normally we will then call
-   procfs_wait and wait for it to stop again (unless gdb is async).
+/* Make child process PI runnable.
 
    If STEP is true, then arrange for the child to stop again after
-   executing a single instruction.  If SIGNO is zero, then cancel any
-   pending signal; if non-zero, then arrange for the indicated signal
-   to be delivered to the child when it runs.  If PID is -1, then
-   allow any child thread to run; if non-zero, then allow only the
-   indicated thread to run.  (not implemented yet).  */
+   executing a single instruction.  SCOPE_PTID, STEP and SIGNO are
+   like in the target_resume interface.  */
 
-void
-procfs_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
+static void
+proc_resume (procinfo *pi, ptid_t scope_ptid, int step, enum gdb_signal signo)
 {
-  procinfo *pi, *thread;
+  procinfo *thread;
   int native_signo;
 
   /* FIXME: Check/reword.  */
@@ -2453,10 +2444,6 @@ procfs_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
      So basically PR_STEP is the sole argument that must be passed
      to proc_run_process.  */
 
-  /* Find procinfo for main process.  */
-  pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
-
-  /* First cut: ignore pid argument.  */
   errno = 0;
 
   /* Convert signal to host numbering.  */
@@ -2473,11 +2460,11 @@ procfs_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
   /* Void the process procinfo's caches.  */
   invalidate_cache (NULL, pi, NULL);
 
-  if (ptid.pid () != -1)
+  if (scope_ptid.pid () != -1)
     {
       /* Resume a specific thread, presumably suppressing the
         others.  */
-      thread = find_procinfo (ptid.pid (), ptid.lwp ());
+      thread = find_procinfo (scope_ptid.pid (), scope_ptid.lwp ());
       if (thread != NULL)
        {
          if (thread->tid != 0)
@@ -2502,6 +2489,17 @@ procfs_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
     }
 }
 
+/* Implementation of target_ops::resume.  */
+
+void
+procfs_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo)
+{
+  /* Find procinfo for main process.  */
+  procinfo *pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
+
+  proc_resume (pi, scope_ptid, step, signo);
+}
+
 /* Set up to trace signals in the child process.  */
 
 void
@@ -2854,7 +2852,7 @@ procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr)
 {
   ptid_t gdb_threadid = ptid_t (pi->pid, thread->tid, 0);
 
-  thread_info *thr = find_thread_ptid (&the_procfs_target, gdb_threadid);
+  thread_info *thr = the_procfs_target.find_thread (gdb_threadid);
   if (thr == NULL || thr->state == THREAD_EXITED)
     add_thread (&the_procfs_target, gdb_threadid);