/* Multi-process control for GDB, the GNU debugger.
- Copyright (C) 2008-2012 Free Software Foundation, Inc.
+ Copyright (C) 2008-2015 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbthread.h"
#include "ui-out.h"
#include "observer.h"
-#include "gdbthread.h"
#include "gdbcore.h"
#include "symfile.h"
#include "environ.h"
#include "cli/cli-utils.h"
#include "continuations.h"
+#include "arch-utils.h"
+#include "target-descriptions.h"
+#include "readline/tilde.h"
void _initialize_inferiors (void);
xfree (inf->args);
xfree (inf->terminal);
free_environ (inf->environment);
- xfree (inf->private);
+ target_desc_info_free (inf->tdesc_info);
+ xfree (inf->priv);
xfree (inf);
}
return 0;
}
-/* If SILENT then be quiet -- don't announce a inferior death, or the
- exit of its threads. */
-
void
-delete_inferior_1 (struct inferior *todel, int silent)
+delete_inferior (struct inferior *todel)
{
struct inferior *inf, *infprev;
struct delete_thread_of_inferior_arg arg;
return;
arg.pid = inf->pid;
- arg.silent = silent;
+ arg.silent = 1;
iterate_over_threads (delete_thread_of_inferior, &arg);
observer_notify_inferior_removed (inf);
- free_inferior (inf);
-}
-
-void
-delete_inferior (int pid)
-{
- struct inferior *inf = find_inferior_pid (pid);
-
- delete_inferior_1 (inf, 0);
-
- if (print_inferior_events)
- printf_unfiltered (_("[Inferior %d exited]\n"), pid);
-}
-
-void
-delete_inferior_silent (int pid)
-{
- struct inferior *inf = find_inferior_pid (pid);
+ /* If this program space is rendered useless, remove it. */
+ if (program_space_empty_p (inf->pspace))
+ delete_program_space (inf->pspace);
- delete_inferior_1 (inf, 1);
+ free_inferior (inf);
}
-
/* If SILENT then be quiet -- don't announce a inferior exit, or the
exit of its threads. */
inf->vfork_parent->vfork_child = NULL;
inf->vfork_parent = NULL;
}
+ if (inf->vfork_child != NULL)
+ {
+ inf->vfork_child->vfork_parent = NULL;
+ inf->vfork_child = NULL;
+ }
- inf->has_exit_code = 0;
- inf->exit_code = 0;
+ inf->pending_detach = 0;
}
void
{
struct inferior *inf = find_inferior_pid (pid);
- exit_inferior_1 (inf, 1);
+ exit_inferior_1 (inf, 0);
if (print_inferior_events)
printf_unfiltered (_("[Inferior %d detached]\n"), pid);
inferior_appeared (struct inferior *inf, int pid)
{
inf->pid = pid;
+ inf->has_exit_code = 0;
+ inf->exit_code = 0;
observer_notify_inferior_appeared (inf);
}
return NULL;
}
-/* Find an inferior bound to PSPACE. */
+/* See inferior.h */
+
+struct inferior *
+find_inferior_ptid (ptid_t ptid)
+{
+ return find_inferior_pid (ptid_get_pid (ptid));
+}
+
+/* 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)
{
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)
}
*ss_link = ss->next;
- delete_inferior_1 (ss, 1);
+ delete_inferior (ss);
ss = *ss_link;
}
-
- prune_program_spaces ();
}
/* Simply returns the count of 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");
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)
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);
}
}
continue;
}
- delete_inferior_1 (inf, 1);
+ delete_inferior (inf);
}
}
struct address_space *aspace;
struct program_space *pspace;
struct inferior *inf;
+ struct gdbarch_info info;
/* If all inferiors share an address space on this system, this
doesn't really return a new address space; otherwise, it
inf->pspace = pspace;
inf->aspace = pspace->aspace;
+ /* Setup the inferior's initial arch, based on information obtained
+ from the global "set ..." options. */
+ gdbarch_info_init (&info);
+ inf->gdbarch = gdbarch_find_by_info (info);
+ /* The "set ..." options reject invalid settings, so we should
+ always have a valid arch by now. */
+ gdb_assert (inf->gdbarch != NULL);
+
return inf;
}
++argv;
if (!*argv)
error (_("No argument to -exec"));
- exec = *argv;
+ exec = tilde_expand (*argv);
+ make_cleanup (xfree, exec);
}
}
else
inf = add_inferior (0);
inf->pspace = pspace;
inf->aspace = pspace->aspace;
+ inf->gdbarch = orginf->gdbarch;
+
+ /* If the original inferior had a user specified target
+ description, make the clone use it too. */
+ if (target_desc_info_from_user_p (inf->tdesc_info))
+ copy_inferior_target_desc_info (inf, orginf);
printf_filtered (_("Added inferior %d.\n"), inf->num);
current_inferior_ = add_inferior (0);
current_inferior_->pspace = current_program_space;
current_inferior_->aspace = current_program_space->aspace;
+ /* The architecture will be initialized shortly, by
+ initialize_current_architecture. */
add_info ("inferiors", info_inferiors_command,
_("IDs of specified inferiors (all inferiors if no argument)."));