* dwarf2read.c (dwarf2_get_pc_bounds): Check DW_AT_high_pc form to
[deliverable/binutils-gdb.git] / gdb / inferior.c
index eb33b9a3766ab6d3e1c5e66f79103e4ce9280c46..00f6fa3384b2cc38f370463f31c050a650b7ac4a 100644 (file)
@@ -1,6 +1,6 @@
 /* Multi-process control for GDB, the GNU debugger.
 
-   Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -31,6 +31,7 @@
 #include "symfile.h"
 #include "environ.h"
 #include "cli/cli-utils.h"
+#include "continuations.h"
 
 void _initialize_inferiors (void);
 
@@ -177,25 +178,6 @@ delete_thread_of_inferior (struct thread_info *tp, void *data)
   return 0;
 }
 
-void
-delete_threads_of_inferior (int pid)
-{
-  struct inferior *inf;
-  struct delete_thread_of_inferior_arg arg;
-
-  for (inf = inferior_list; inf; inf = inf->next)
-    if (inf->pid == pid)
-      break;
-
-  if (!inf)
-    return;
-
-  arg.pid = pid;
-  arg.silent = 1;
-
-  iterate_over_threads (delete_thread_of_inferior, &arg);
-}
-
 /* If SILENT then be quiet -- don't announce a inferior death, or the
    exit of its threads.  */
 
@@ -275,11 +257,15 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
   observer_notify_inferior_exit (inf);
 
   inf->pid = 0;
+  inf->fake_pid_p = 0;
   if (inf->vfork_parent != NULL)
     {
       inf->vfork_parent->vfork_child = NULL;
       inf->vfork_parent = NULL;
     }
+
+  inf->has_exit_code = 0;
+  inf->exit_code = 0;
 }
 
 void
@@ -521,6 +507,18 @@ number_of_inferiors (void)
   return count;
 }
 
+/* Converts an inferior process id to a string.  Like
+   target_pid_to_str, but special cases the null process.  */
+
+static char *
+inferior_pid_to_str (int pid)
+{
+  if (pid != 0)
+    return target_pid_to_str (pid_to_ptid (pid));
+  else
+    return _("<null>");
+}
+
 /* Prints the list of inferiors and their details on UIOUT.  This is a
    version of 'info_inferior_command' suitable for use from MI.
 
@@ -574,11 +572,8 @@ print_inferior (struct ui_out *uiout, char *requested_inferiors)
 
       ui_out_field_int (uiout, "number", inf->num);
 
-      if (inf->pid)
-       ui_out_field_string (uiout, "target-id",
-                            target_pid_to_str (pid_to_ptid (inf->pid)));
-      else
-       ui_out_field_string (uiout, "target-id", "<null>");
+      ui_out_field_string (uiout, "target-id",
+                          inferior_pid_to_str (inf->pid));
 
       if (inf->pspace->ebfd)
        ui_out_field_string (uiout, "exec",
@@ -612,13 +607,15 @@ detach_inferior_command (char *args, int from_tty)
 {
   int num, pid;
   struct thread_info *tp;
+  struct get_number_or_range_state state;
 
   if (!args || !*args)
     error (_("Requires argument (inferior id(s) to detach)"));
 
-  while (*args != '\0')
+  init_number_or_range (&state, args);
+  while (!state.finished)
     {
-      num = get_number_or_range (&args);
+      num = get_number_or_range (&state);
 
       if (!valid_gdb_inferior_id (num))
        {
@@ -646,13 +643,15 @@ kill_inferior_command (char *args, int from_tty)
 {
   int num, pid;
   struct thread_info *tp;
+  struct get_number_or_range_state state;
 
   if (!args || !*args)
     error (_("Requires argument (inferior id(s) to kill)"));
 
-  while (*args != '\0')
+  init_number_or_range (&state, args);
+  while (!state.finished)
     {
-      num = get_number_or_range (&args);
+      num = get_number_or_range (&state);
 
       if (!valid_gdb_inferior_id (num))
        {
@@ -691,7 +690,7 @@ inferior_command (char *args, int from_tty)
 
   printf_filtered (_("[Switching to inferior %d [%s] (%s)]\n"),
                   inf->num,
-                  target_pid_to_str (pid_to_ptid (inf->pid)),
+                  inferior_pid_to_str (inf->pid),
                   (inf->pspace->ebfd
                    ? bfd_get_filename (inf->pspace->ebfd)
                    : _("<noexec>")));
@@ -724,10 +723,10 @@ inferior_command (char *args, int from_tty)
     }
 
   if (inf->pid != 0 && is_running (inferior_ptid))
-    ui_out_text (uiout, "(running)\n");
+    ui_out_text (current_uiout, "(running)\n");
   else if (inf->pid != 0)
     {
-      ui_out_text (uiout, "\n");
+      ui_out_text (current_uiout, "\n");
       print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
     }
 }
@@ -737,23 +736,25 @@ inferior_command (char *args, int from_tty)
 static void
 info_inferiors_command (char *args, int from_tty)
 {
-  print_inferior (uiout, args);
+  print_inferior (current_uiout, args);
 }
 
 /* remove-inferior ID */
 
-void
+static void
 remove_inferior_command (char *args, int from_tty)
 {
   int num;
   struct inferior *inf;
+  struct get_number_or_range_state state;
 
   if (args == NULL || *args == '\0')
     error (_("Requires an argument (inferior id(s) to remove)"));
 
-  while (*args != '\0')
+  init_number_or_range (&state, args);
+  while (!state.finished)
     {
-      num = get_number_or_range (&args);
+      num = get_number_or_range (&state);
       inf = find_inferior_id (num);
 
       if (inf == NULL)
@@ -799,7 +800,7 @@ add_inferior_with_spaces (void)
 
 /* add-inferior [-copies N] [-exec FILENAME]  */
 
-void
+static void
 add_inferior_command (char *args, int from_tty)
 {
   int i, copies = 1;
@@ -862,7 +863,7 @@ add_inferior_command (char *args, int from_tty)
 
 /* clone-inferior [-copies N] [ID] */
 
-void
+static void
 clone_inferior_command (char *args, int from_tty)
 {
   int i, copies = 1;
This page took 0.027897 seconds and 4 git commands to generate.