#include "gdbthread.h"
#include "gdbcore.h"
#include "symfile.h"
+#include "environ.h"
void _initialize_inferiors (void);
{
discard_all_inferior_continuations (inf);
inferior_free_data (inf);
+ xfree (inf->args);
+ xfree (inf->terminal);
+ free_environ (inf->environment);
xfree (inf->private);
xfree (inf);
}
inf->next = inferior_list;
inferior_list = inf;
+ inf->environment = make_environ ();
+ init_environ (inf->environment);
+
inferior_alloc_data (inf);
+ observer_notify_inferior_added (inf);
+
if (pid != 0)
inferior_appeared (inf, pid);
/* If SILENT then be quiet -- don't announce a inferior death, or the
exit of its threads. */
-static void
+void
delete_inferior_1 (struct inferior *todel, int silent)
{
struct inferior *inf, *infprev;
else
inferior_list = inf->next;
+ observer_notify_inferior_removed (inf);
+
free_inferior (inf);
}
/* Notify the observers before removing the inferior from the list,
so that the observers have a chance to look it up. */
- observer_notify_inferior_exit (inf->pid);
+ observer_notify_inferior_exit (inf);
inf->pid = 0;
if (inf->vfork_parent != NULL)
{
inf->pid = pid;
- observer_notify_inferior_appeared (pid);
+ observer_notify_inferior_appeared (inf);
}
void
delete_inferior_1 (inf, 1);
}
+struct inferior *
+add_inferior_with_spaces (void)
+{
+ struct address_space *aspace;
+ struct program_space *pspace;
+ struct inferior *inf;
+
+ /* If all inferiors share an address space on this system, this
+ doesn't really return a new address space; otherwise, it
+ really does. */
+ aspace = maybe_new_address_space ();
+ pspace = add_program_space (aspace);
+ inf = add_inferior (0);
+ inf->pspace = pspace;
+ inf->aspace = pspace->aspace;
+
+ return inf;
+}
/* add-inferior [-copies N] [-exec FILENAME] */
for (i = 0; i < copies; ++i)
{
- struct address_space *aspace;
- struct program_space *pspace;
- struct inferior *inf;
-
- /* If all inferiors share an address space on this system, this
- doesn't really return a new address space; otherwise, it
- really does. */
- aspace = maybe_new_address_space ();
- pspace = add_program_space (aspace);
- inf = add_inferior (0);
- inf->pspace = pspace;
- inf->aspace = pspace->aspace;
+ struct inferior *inf = add_inferior_with_spaces ();
printf_filtered (_("Added inferior %d\n"), inf->num);
{
/* Switch over temporarily, while reading executable and
symbols.q */
- set_current_program_space (pspace);
+ set_current_program_space (inf->pspace);
set_current_inferior (inf);
switch_to_thread (null_ptid);