Update copyright dates.
[deliverable/binutils-gdb.git] / gdb / inferior.c
index f1991c97381077c4088c9f2c54c1fa3dcb8c7dfc..081849eba03bb1201654f878d4478b24ae806e2f 100644 (file)
@@ -1,6 +1,6 @@
 /* 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.
 
@@ -68,6 +68,7 @@ static void
 restore_inferior (void *arg)
 {
   struct inferior *saved_inferior = arg;
+
   set_current_inferior (saved_inferior);
 }
 
@@ -80,6 +81,7 @@ save_current_inferior (void)
 {
   struct cleanup *old_chain = make_cleanup (restore_inferior,
                                            current_inferior_);
+
   return old_chain;
 }
 
@@ -122,7 +124,7 @@ add_inferior_silent (int pid)
   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;
@@ -283,6 +285,7 @@ void
 exit_inferior (int pid)
 {
   struct inferior *inf = find_inferior_pid (pid);
+
   exit_inferior_1 (inf, 0);
 
   if (print_inferior_events)
@@ -293,6 +296,7 @@ void
 exit_inferior_silent (int pid)
 {
   struct inferior *inf = find_inferior_pid (pid);
+
   exit_inferior_1 (inf, 1);
 }
 
@@ -308,6 +312,7 @@ void
 detach_inferior (int pid)
 {
   struct inferior *inf = find_inferior_pid (pid);
+
   exit_inferior_1 (inf, 1);
 
   if (print_inferior_events)
@@ -456,16 +461,29 @@ have_inferiors (void)
 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
@@ -527,8 +545,6 @@ print_inferior (struct ui_out *uiout, int requested_inferior)
   /* 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;
 
@@ -738,6 +754,9 @@ remove_inferior_command (char *args, int from_tty)
 
   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);
 }
@@ -811,7 +830,7 @@ add_inferior_command (char *args, int from_tty)
       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);
This page took 0.025175 seconds and 4 git commands to generate.