/* 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.
#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);
+ target_desc_info_free (inf->tdesc_info);
xfree (inf->private);
xfree (inf);
}
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
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_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)
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);
}
}
delete_inferior_1 (inf, 1);
}
+
+ prune_program_spaces ();
}
struct inferior *
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)."));