`set print inferior-events'. */
static int print_inferior_events = 0;
-/* The Current Inferior. */
+/* The Current Inferior. This is a strong reference. I.e., whenever
+ an inferior is the current inferior, its refcount is
+ incremented. */
static struct inferior *current_inferior_ = NULL;
struct inferior*
/* There's always an inferior. */
gdb_assert (inf != NULL);
+ inf->incref ();
+ current_inferior_->decref ();
current_inferior_ = inf;
}
prune_inferiors (void)
{
struct inferior *ss, **ss_link;
- struct inferior *current = current_inferior ();
ss = inferior_list;
ss_link = &inferior_list;
while (ss)
{
- if (ss == current
+ if (!ss->deletable ()
|| !ss->removable
|| ss->pid != 0)
{
continue;
}
- if (inf == current_inferior ())
+ if (!inf->deletable ())
{
warning (_("Can not remove current inferior %d."), num);
continue;
that. Do this after initialize_progspace, due to the
current_program_space reference. */
current_inferior_ = add_inferior (0);
+ current_inferior_->incref ();
current_inferior_->pspace = current_program_space;
current_inferior_->aspace = current_program_space->aspace;
/* The architecture will be initialized shortly, by