/* Multi-process control for GDB, the GNU debugger.
- Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GDB.
restore_inferior (void *arg)
{
struct inferior *saved_inferior = arg;
+
set_current_inferior (saved_inferior);
}
{
struct cleanup *old_chain = make_cleanup (restore_inferior,
current_inferior_);
+
return old_chain;
}
memset (inf, 0, sizeof (*inf));
inf->pid = pid;
- inf->stop_soon = NO_STOP_QUIETLY;
+ inf->control.stop_soon = NO_STOP_QUIETLY;
inf->num = ++highest_inferior_num;
inf->next = inferior_list;
exit_inferior (int pid)
{
struct inferior *inf = find_inferior_pid (pid);
+
exit_inferior_1 (inf, 0);
if (print_inferior_events)
exit_inferior_silent (int pid)
{
struct inferior *inf = find_inferior_pid (pid);
+
exit_inferior_1 (inf, 1);
}
detach_inferior (int pid)
{
struct inferior *inf = find_inferior_pid (pid);
+
exit_inferior_1 (inf, 1);
if (print_inferior_events)
int
have_live_inferiors (void)
{
- struct target_ops *t;
+ struct cleanup *old_chain;
+ struct inferior *inf;
- /* The check on stratum suffices, as GDB doesn't currently support
- multiple target interfaces. */
- if (have_inferiors ())
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_stratum == process_stratum)
- return 1;
+ old_chain = make_cleanup_restore_current_thread ();
- return 0;
+ for (inf = inferior_list; inf; inf = inf->next)
+ if (inf->pid != 0)
+ {
+ struct thread_info *tp;
+
+ tp = any_thread_of_process (inf->pid);
+ if (tp)
+ {
+ switch_to_thread (tp->ptid);
+
+ if (target_has_execution)
+ break;
+ }
+ }
+
+ do_cleanups (old_chain);
+
+ return inf != NULL;
}
/* Prune away automatically added program spaces that aren't required
/* Compute number of inferiors we will print. */
for (inf = inferior_list; inf; inf = inf->next)
{
- struct cleanup *chain2;
-
if (requested_inferior != -1 && inf->num != requested_inferior)
continue;
if (inf == current_inferior ())
error (_("Can not remove current symbol inferior."));
+
+ if (inf->pid != 0)
+ error (_("Can not remove an active inferior."));
delete_inferior_1 (inf, 1);
}
if (exec != NULL)
{
/* Switch over temporarily, while reading executable and
- symbols.q */
+ symbols.q. */
set_current_program_space (inf->pspace);
set_current_inferior (inf);
switch_to_thread (null_ptid);