+info_inferiors_command (char *args, int from_tty)
+{
+ print_inferior (current_uiout, args);
+}
+
+/* remove-inferior ID */
+
+static void
+remove_inferior_command (char *args, int from_tty)
+{
+ if (args == NULL || *args == '\0')
+ error (_("Requires an argument (inferior id(s) to remove)"));
+
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
+ {
+ int num = parser.get_number ();
+ struct inferior *inf = find_inferior_id (num);
+
+ if (inf == NULL)
+ {
+ warning (_("Inferior ID %d not known."), num);
+ continue;
+ }
+
+ if (inf == current_inferior ())
+ {
+ warning (_("Can not remove current inferior %d."), num);
+ continue;
+ }
+
+ if (inf->pid != 0)
+ {
+ warning (_("Can not remove active inferior %d."), num);
+ continue;
+ }
+
+ delete_inferior (inf);
+ }
+}
+
+struct inferior *
+add_inferior_with_spaces (void)
+{
+ 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
+ really does. */
+ aspace = maybe_new_address_space ();
+ pspace = add_program_space (aspace);
+ inf = add_inferior (0);
+ 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;
+}
+
+/* add-inferior [-copies N] [-exec FILENAME] */
+
+static void
+add_inferior_command (char *args, int from_tty)
+{
+ int i, copies = 1;
+ char *exec = NULL;
+ char **argv;
+ symfile_add_flags add_flags = 0;
+ struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
+
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
+
+ if (args)
+ {
+ argv = gdb_buildargv (args);
+ make_cleanup_freeargv (argv);
+
+ for (; *argv != NULL; argv++)
+ {
+ if (**argv == '-')
+ {
+ if (strcmp (*argv, "-copies") == 0)
+ {
+ ++argv;
+ if (!*argv)
+ error (_("No argument to -copies"));
+ copies = parse_and_eval_long (*argv);
+ }
+ else if (strcmp (*argv, "-exec") == 0)
+ {
+ ++argv;
+ if (!*argv)
+ error (_("No argument to -exec"));
+ exec = tilde_expand (*argv);
+ make_cleanup (xfree, exec);
+ }
+ }
+ else
+ error (_("Invalid argument"));
+ }
+ }
+
+ save_current_space_and_thread ();
+
+ for (i = 0; i < copies; ++i)
+ {
+ struct inferior *inf = add_inferior_with_spaces ();
+
+ printf_filtered (_("Added inferior %d\n"), inf->num);
+
+ if (exec != NULL)
+ {
+ /* Switch over temporarily, while reading executable and
+ symbols.q. */
+ set_current_program_space (inf->pspace);
+ set_current_inferior (inf);
+ switch_to_thread (null_ptid);
+
+ exec_file_attach (exec, from_tty);
+ symbol_file_add_main (exec, add_flags);
+ }
+ }
+
+ do_cleanups (old_chain);
+}
+
+/* clone-inferior [-copies N] [ID] */
+
+static void
+clone_inferior_command (char *args, int from_tty)