packaging: bump to 2.24.90
[platform/upstream/binutils.git] / gdb / inferior.c
index 5bb1514..44f4560 100644 (file)
@@ -1,6 +1,6 @@
 /* Multi-process control for GDB, the GNU debugger.
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -27,7 +27,6 @@
 #include "gdbthread.h"
 #include "ui-out.h"
 #include "observer.h"
-#include "gdbthread.h"
 #include "gdbcore.h"
 #include "symfile.h"
 #include "environ.h"
@@ -35,6 +34,7 @@
 #include "continuations.h"
 #include "arch-utils.h"
 #include "target-descriptions.h"
+#include "readline/tilde.h"
 
 void _initialize_inferiors (void);
 
@@ -275,8 +275,6 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
       inf->vfork_child = NULL;
     }
 
-  inf->has_exit_code = 0;
-  inf->exit_code = 0;
   inf->pending_detach = 0;
 }
 
@@ -322,6 +320,8 @@ void
 inferior_appeared (struct inferior *inf, int pid)
 {
   inf->pid = pid;
+  inf->has_exit_code = 0;
+  inf->exit_code = 0;
 
   observer_notify_inferior_appeared (inf);
 }
@@ -367,12 +367,15 @@ find_inferior_pid (int pid)
   return NULL;
 }
 
-/* Find an inferior bound to PSPACE.  */
+/* See inferior.h.  */
 
 struct inferior *
 find_inferior_for_program_space (struct program_space *pspace)
 {
-  struct inferior *inf;
+  struct inferior *inf = current_inferior ();
+
+  if (inf->pspace == pspace)
+    return inf;
 
   for (inf = inferior_list; inf != NULL; inf = inf->next)
     {
@@ -475,8 +478,8 @@ have_live_inferiors (void)
   return inf != NULL;
 }
 
-/* Prune away automatically added program spaces that aren't required
-   anymore.  */
+/* Prune away any unused inferiors, and then prune away no longer used
+   program spaces.  */
 
 void
 prune_inferiors (void)
@@ -587,9 +590,8 @@ print_inferior (struct ui_out *uiout, char *requested_inferiors)
       ui_out_field_string (uiout, "target-id",
                           inferior_pid_to_str (inf->pid));
 
-      if (inf->pspace->ebfd)
-       ui_out_field_string (uiout, "exec",
-                            bfd_get_filename (inf->pspace->ebfd));
+      if (inf->pspace->pspace_exec_filename != NULL)
+       ui_out_field_string (uiout, "exec", inf->pspace->pspace_exec_filename);
       else
        ui_out_field_skip (uiout, "exec");
 
@@ -703,8 +705,8 @@ inferior_command (char *args, int from_tty)
   printf_filtered (_("[Switching to inferior %d [%s] (%s)]\n"),
                   inf->num,
                   inferior_pid_to_str (inf->pid),
-                  (inf->pspace->ebfd
-                   ? bfd_get_filename (inf->pspace->ebfd)
+                  (inf->pspace->pspace_exec_filename != NULL
+                   ? inf->pspace->pspace_exec_filename
                    : _("<noexec>")));
 
   if (inf->pid != 0)
@@ -739,7 +741,7 @@ inferior_command (char *args, int from_tty)
   else if (inf->pid != 0)
     {
       ui_out_text (current_uiout, "\n");
-      print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+      print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
     }
 }
 
@@ -789,6 +791,8 @@ remove_inferior_command (char *args, int from_tty)
 
       delete_inferior_1 (inf, 1);
     }
+
+  prune_program_spaces ();
 }
 
 struct inferior *
@@ -850,7 +854,8 @@ add_inferior_command (char *args, int from_tty)
                  ++argv;
                  if (!*argv)
                    error (_("No argument to -exec"));
-                 exec = *argv;
+                 exec = tilde_expand (*argv);
+                 make_cleanup (xfree, exec);
                }
            }
          else