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. */
}
}
-/* 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)
{
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
/* 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, ¶m);
+ 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
{
/* 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
{
/* 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;
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
catch (const gdb_exception &ex)
{
exit_inferior (inf);
- inferior_ptid = null_ptid;
+ switch_to_no_thread ();
throw;
}
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
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;
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;
}