Remove stale -DNO_PROTOTYPES bits from gdb testsuite
[deliverable/binutils-gdb.git] / gdb / darwin-nat.c
index 3bd8d8ce003d57b3ef22ec6e649d0ba31b61259e..0d7b028e39cbc4c7d5169a962408f88d3e23d2b5 100644 (file)
@@ -378,32 +378,30 @@ darwin_nat_target::check_new_threads (inferior *inf)
   MACH_CHECK_ERROR (kret);
 }
 
-static int
-find_inferior_task_it (struct inferior *inf, void *port_ptr)
-{
-  darwin_inferior *priv = get_darwin_inferior (inf);
-
-  return priv != nullptr && priv->task == *(task_t *)port_ptr;
-}
-
-static int
-find_inferior_pid_it (struct inferior *inf, void *pid_ptr)
-{
-  return inf->pid == *(int *)pid_ptr;
-}
-
 /* Return an inferior by task port.  */
 static struct inferior *
 darwin_find_inferior_by_task (task_t port)
 {
-  return iterate_over_inferiors (&find_inferior_task_it, &port);
+  for (inferior *inf : all_inferiors ())
+    {
+      darwin_inferior *priv = get_darwin_inferior (inf);
+
+      if (priv != nullptr && priv->task == port)
+       return inf;
+    }
+  return nullptr;
 }
 
 /* Return an inferior by pid port.  */
 static struct inferior *
 darwin_find_inferior_by_pid (int pid)
 {
-  return iterate_over_inferiors (&find_inferior_pid_it, &pid);
+  for (inferior *inf : all_inferiors ())
+    {
+      if (inf->pid == pid)
+       return inf;
+    }
+  return nullptr;
 }
 
 /* Return a thread by port.  */
@@ -458,15 +456,6 @@ darwin_resume_inferior (struct inferior *inf)
     }
 }
 
-/* Iterator functions.  */
-
-static int
-darwin_resume_inferior_it (struct inferior *inf, void *arg)
-{
-  darwin_resume_inferior (inf);
-  return 0;
-}
-
 static void
 darwin_dump_message (mach_msg_header_t *hdr, int disp_body)
 {
@@ -886,23 +875,6 @@ darwin_resume_inferior_threads (struct inferior *inf, int step, int nsignal)
       darwin_resume_thread (inf, thread, step, nsignal);
 }
 
-struct resume_inferior_threads_param
-{
-  int step;
-  int nsignal;
-};
-
-static int
-darwin_resume_inferior_threads_it (struct inferior *inf, void *param)
-{
-  int step = ((struct resume_inferior_threads_param *)param)->step;
-  int nsignal = ((struct resume_inferior_threads_param *)param)->nsignal;
-
-  darwin_resume_inferior_threads (inf, step, nsignal);
-
-  return 0;
-}
-
 /* Suspend all threads of INF.  */
 
 static void
@@ -951,15 +923,13 @@ darwin_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
   /* minus_one_ptid is RESUME_ALL.  */
   if (ptid == minus_one_ptid)
     {
-      struct resume_inferior_threads_param param;
-
-      param.nsignal = nsignal;
-      param.step = step;
-
       /* Resume threads.  */
-      iterate_over_inferiors (darwin_resume_inferior_threads_it, &param);
+      for (inferior *inf : all_inferiors ())
+       darwin_resume_inferior_threads (inf, step, nsignal);
+
       /* Resume tasks.  */
-      iterate_over_inferiors (darwin_resume_inferior_it, NULL);
+      for (inferior *inf : all_inferiors ())
+       darwin_resume_inferior (inf);
     }
   else
     {
@@ -1141,8 +1111,7 @@ darwin_nat_target::decode_message (mach_msg_header_t *hdr,
              /* Looks necessary on Leopard and harmless...  */
              wait4 (inf->pid, &wstatus, 0, NULL);
 
-             inferior_ptid = ptid_t (inf->pid, 0, 0);
-             return inferior_ptid;
+             return ptid_t (inf->pid);
            }
          else
            {
@@ -1432,7 +1401,7 @@ darwin_nat_target::stop_inferior (inferior *inf)
   /* Wait until the process is really stopped.  */
   while (1)
     {
-      ptid = wait_1 (inferior_ptid, &wstatus);
+      ptid = wait_1 (ptid_t (inf->pid), &wstatus);
       if (wstatus.kind == TARGET_WAITKIND_STOPPED
          && wstatus.value.sig == GDB_SIGNAL_STOP)
        break;
@@ -1557,13 +1526,13 @@ darwin_nat_target::kill ()
 
       darwin_resume_inferior (inf);
 
-      ptid = wait_1 (inferior_ptid, &wstatus);
+      ptid = wait_1 (ptid_t (inf->pid), &wstatus);
     }
   else if (errno != ESRCH)
     warning (_("Failed to kill inferior: kill (%d, 9) returned [%s]"),
             inf->pid, safe_strerror (errno));
 
-  target_mourn_inferior (inferior_ptid);
+  target_mourn_inferior (ptid_t (inf->pid));
 }
 
 static void
@@ -1683,7 +1652,7 @@ darwin_attach_pid (struct inferior *inf)
   catch (const gdb_exception &ex)
     {
       exit_inferior (inf);
-      inferior_ptid = null_ptid;
+      switch_to_no_thread ();
 
       throw;
     }
@@ -1722,7 +1691,7 @@ darwin_nat_target::init_thread_list (inferior *inf)
   struct thread_info *first_thread
     = thread_info_from_private_thread_info (first_pti);
 
-  inferior_ptid = first_thread->ptid;
+  switch_to_thread (first_thread);
 }
 
 /* The child must synchronize with gdb: gdb must set the exception port
@@ -2057,7 +2026,6 @@ darwin_nat_target::attach (const char *args, int from_tty)
     error (_("Can't attach to process %d: %s (%d)"),
            pid, safe_strerror (errno), errno);
 
-  inferior_ptid = ptid_t (pid);
   inf = current_inferior ();
   inferior_appeared (inf, pid);
   inf->attach_flag = 1;
@@ -2469,7 +2437,7 @@ darwin_nat_target::get_ada_task_ptid (long lwp, long thread)
                  names_count * sizeof (mach_port_t));
 
   if (res)
-    return ptid_t (inferior_ptid.pid (), 0, res);
+    return ptid_t (current_inferior ()->pid, 0, res);
   else
     return null_ptid;
 }
This page took 0.026596 seconds and 4 git commands to generate.