morse(6): correct email for original author
[dragonfly.git] / contrib / gdb-7 / gdb / inferior.c
blob9a61251a47e8e4f8b934dced23d9c6eb5674167c
1 /* Multi-process control for GDB, the GNU debugger.
3 Copyright (C) 2008-2013 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "defs.h"
21 #include "exec.h"
22 #include "inferior.h"
23 #include "target.h"
24 #include "command.h"
25 #include "completer.h"
26 #include "gdbcmd.h"
27 #include "gdbthread.h"
28 #include "ui-out.h"
29 #include "observer.h"
30 #include "gdbthread.h"
31 #include "gdbcore.h"
32 #include "symfile.h"
33 #include "environ.h"
34 #include "cli/cli-utils.h"
35 #include "continuations.h"
36 #include "arch-utils.h"
37 #include "target-descriptions.h"
39 void _initialize_inferiors (void);
41 /* Keep a registry of per-inferior data-pointers required by other GDB
42 modules. */
44 DEFINE_REGISTRY (inferior, REGISTRY_ACCESS_FIELD)
46 struct inferior *inferior_list = NULL;
47 static int highest_inferior_num;
49 /* Print notices on inferior events (attach, detach, etc.), set with
50 `set print inferior-events'. */
51 static int print_inferior_events = 0;
53 /* The Current Inferior. */
54 static struct inferior *current_inferior_ = NULL;
56 struct inferior*
57 current_inferior (void)
59 return current_inferior_;
62 void
63 set_current_inferior (struct inferior *inf)
65 /* There's always an inferior. */
66 gdb_assert (inf != NULL);
68 current_inferior_ = inf;
71 /* A cleanups callback, helper for save_current_program_space
72 below. */
74 static void
75 restore_inferior (void *arg)
77 struct inferior *saved_inferior = arg;
79 set_current_inferior (saved_inferior);
82 /* Save the current program space so that it may be restored by a later
83 call to do_cleanups. Returns the struct cleanup pointer needed for
84 later doing the cleanup. */
86 struct cleanup *
87 save_current_inferior (void)
89 struct cleanup *old_chain = make_cleanup (restore_inferior,
90 current_inferior_);
92 return old_chain;
95 static void
96 free_inferior (struct inferior *inf)
98 discard_all_inferior_continuations (inf);
99 inferior_free_data (inf);
100 xfree (inf->args);
101 xfree (inf->terminal);
102 free_environ (inf->environment);
103 target_desc_info_free (inf->tdesc_info);
104 xfree (inf->private);
105 xfree (inf);
108 void
109 init_inferior_list (void)
111 struct inferior *inf, *infnext;
113 highest_inferior_num = 0;
114 if (!inferior_list)
115 return;
117 for (inf = inferior_list; inf; inf = infnext)
119 infnext = inf->next;
120 free_inferior (inf);
123 inferior_list = NULL;
126 struct inferior *
127 add_inferior_silent (int pid)
129 struct inferior *inf;
131 inf = xmalloc (sizeof (*inf));
132 memset (inf, 0, sizeof (*inf));
133 inf->pid = pid;
135 inf->control.stop_soon = NO_STOP_QUIETLY;
137 inf->num = ++highest_inferior_num;
138 inf->next = inferior_list;
139 inferior_list = inf;
141 inf->environment = make_environ ();
142 init_environ (inf->environment);
144 inferior_alloc_data (inf);
146 observer_notify_inferior_added (inf);
148 if (pid != 0)
149 inferior_appeared (inf, pid);
151 return inf;
154 struct inferior *
155 add_inferior (int pid)
157 struct inferior *inf = add_inferior_silent (pid);
159 if (print_inferior_events)
160 printf_unfiltered (_("[New inferior %d]\n"), pid);
162 return inf;
165 struct delete_thread_of_inferior_arg
167 int pid;
168 int silent;
171 static int
172 delete_thread_of_inferior (struct thread_info *tp, void *data)
174 struct delete_thread_of_inferior_arg *arg = data;
176 if (ptid_get_pid (tp->ptid) == arg->pid)
178 if (arg->silent)
179 delete_thread_silent (tp->ptid);
180 else
181 delete_thread (tp->ptid);
184 return 0;
187 /* If SILENT then be quiet -- don't announce a inferior death, or the
188 exit of its threads. */
190 void
191 delete_inferior_1 (struct inferior *todel, int silent)
193 struct inferior *inf, *infprev;
194 struct delete_thread_of_inferior_arg arg;
196 infprev = NULL;
198 for (inf = inferior_list; inf; infprev = inf, inf = inf->next)
199 if (inf == todel)
200 break;
202 if (!inf)
203 return;
205 arg.pid = inf->pid;
206 arg.silent = silent;
208 iterate_over_threads (delete_thread_of_inferior, &arg);
210 if (infprev)
211 infprev->next = inf->next;
212 else
213 inferior_list = inf->next;
215 observer_notify_inferior_removed (inf);
217 free_inferior (inf);
220 void
221 delete_inferior (int pid)
223 struct inferior *inf = find_inferior_pid (pid);
225 delete_inferior_1 (inf, 0);
227 if (print_inferior_events)
228 printf_unfiltered (_("[Inferior %d exited]\n"), pid);
231 void
232 delete_inferior_silent (int pid)
234 struct inferior *inf = find_inferior_pid (pid);
236 delete_inferior_1 (inf, 1);
240 /* If SILENT then be quiet -- don't announce a inferior exit, or the
241 exit of its threads. */
243 static void
244 exit_inferior_1 (struct inferior *inftoex, int silent)
246 struct inferior *inf;
247 struct delete_thread_of_inferior_arg arg;
249 for (inf = inferior_list; inf; inf = inf->next)
250 if (inf == inftoex)
251 break;
253 if (!inf)
254 return;
256 arg.pid = inf->pid;
257 arg.silent = silent;
259 iterate_over_threads (delete_thread_of_inferior, &arg);
261 /* Notify the observers before removing the inferior from the list,
262 so that the observers have a chance to look it up. */
263 observer_notify_inferior_exit (inf);
265 inf->pid = 0;
266 inf->fake_pid_p = 0;
267 if (inf->vfork_parent != NULL)
269 inf->vfork_parent->vfork_child = NULL;
270 inf->vfork_parent = NULL;
272 if (inf->vfork_child != NULL)
274 inf->vfork_child->vfork_parent = NULL;
275 inf->vfork_child = NULL;
278 inf->has_exit_code = 0;
279 inf->exit_code = 0;
280 inf->pending_detach = 0;
283 void
284 exit_inferior (int pid)
286 struct inferior *inf = find_inferior_pid (pid);
288 exit_inferior_1 (inf, 0);
290 if (print_inferior_events)
291 printf_unfiltered (_("[Inferior %d exited]\n"), pid);
294 void
295 exit_inferior_silent (int pid)
297 struct inferior *inf = find_inferior_pid (pid);
299 exit_inferior_1 (inf, 1);
302 void
303 exit_inferior_num_silent (int num)
305 struct inferior *inf = find_inferior_id (num);
307 exit_inferior_1 (inf, 1);
310 void
311 detach_inferior (int pid)
313 struct inferior *inf = find_inferior_pid (pid);
315 exit_inferior_1 (inf, 1);
317 if (print_inferior_events)
318 printf_unfiltered (_("[Inferior %d detached]\n"), pid);
321 void
322 inferior_appeared (struct inferior *inf, int pid)
324 inf->pid = pid;
326 observer_notify_inferior_appeared (inf);
329 void
330 discard_all_inferiors (void)
332 struct inferior *inf;
334 for (inf = inferior_list; inf; inf = inf->next)
336 if (inf->pid != 0)
337 exit_inferior_silent (inf->pid);
341 struct inferior *
342 find_inferior_id (int num)
344 struct inferior *inf;
346 for (inf = inferior_list; inf; inf = inf->next)
347 if (inf->num == num)
348 return inf;
350 return NULL;
353 struct inferior *
354 find_inferior_pid (int pid)
356 struct inferior *inf;
358 /* Looking for inferior pid == 0 is always wrong, and indicative of
359 a bug somewhere else. There may be more than one with pid == 0,
360 for instance. */
361 gdb_assert (kernel_debugger || pid != 0);
363 for (inf = inferior_list; inf; inf = inf->next)
364 if (inf->pid == pid)
365 return inf;
367 return NULL;
370 /* Find an inferior bound to PSPACE. */
372 struct inferior *
373 find_inferior_for_program_space (struct program_space *pspace)
375 struct inferior *inf;
377 for (inf = inferior_list; inf != NULL; inf = inf->next)
379 if (inf->pspace == pspace)
380 return inf;
383 return NULL;
386 struct inferior *
387 iterate_over_inferiors (int (*callback) (struct inferior *, void *),
388 void *data)
390 struct inferior *inf, *infnext;
392 for (inf = inferior_list; inf; inf = infnext)
394 infnext = inf->next;
395 if ((*callback) (inf, data))
396 return inf;
399 return NULL;
403 valid_gdb_inferior_id (int num)
405 struct inferior *inf;
407 for (inf = inferior_list; inf; inf = inf->next)
408 if (inf->num == num)
409 return 1;
411 return 0;
415 pid_to_gdb_inferior_id (int pid)
417 struct inferior *inf;
419 for (inf = inferior_list; inf; inf = inf->next)
420 if (inf->pid == pid)
421 return inf->num;
423 return 0;
427 gdb_inferior_id_to_pid (int num)
429 struct inferior *inferior = find_inferior_id (num);
430 if (inferior)
431 return inferior->pid;
432 else
433 return -1;
437 in_inferior_list (int pid)
439 struct inferior *inf;
441 for (inf = inferior_list; inf; inf = inf->next)
442 if (inf->pid == pid)
443 return 1;
445 return 0;
449 have_inferiors (void)
451 struct inferior *inf;
453 for (inf = inferior_list; inf; inf = inf->next)
454 if (inf->pid != 0)
455 return 1;
457 return 0;
461 have_live_inferiors (void)
463 struct inferior *inf;
465 for (inf = inferior_list; inf; inf = inf->next)
466 if (inf->pid != 0)
468 struct thread_info *tp;
470 tp = any_thread_of_process (inf->pid);
471 if (tp && target_has_execution_1 (tp->ptid))
472 break;
475 return inf != NULL;
478 /* Prune away automatically added program spaces that aren't required
479 anymore. */
481 void
482 prune_inferiors (void)
484 struct inferior *ss, **ss_link;
485 struct inferior *current = current_inferior ();
487 ss = inferior_list;
488 ss_link = &inferior_list;
489 while (ss)
491 if (ss == current
492 || !ss->removable
493 || ss->pid != 0)
495 ss_link = &ss->next;
496 ss = *ss_link;
497 continue;
500 *ss_link = ss->next;
501 delete_inferior_1 (ss, 1);
502 ss = *ss_link;
505 prune_program_spaces ();
508 /* Simply returns the count of inferiors. */
511 number_of_inferiors (void)
513 struct inferior *inf;
514 int count = 0;
516 for (inf = inferior_list; inf != NULL; inf = inf->next)
517 count++;
519 return count;
522 /* Converts an inferior process id to a string. Like
523 target_pid_to_str, but special cases the null process. */
525 static char *
526 inferior_pid_to_str (int pid)
528 if (kernel_debugger || pid != 0)
529 return target_pid_to_str (pid_to_ptid (pid));
530 else
531 return _("<null>");
534 /* Prints the list of inferiors and their details on UIOUT. This is a
535 version of 'info_inferior_command' suitable for use from MI.
537 If REQUESTED_INFERIORS is not NULL, it's a list of GDB ids of the
538 inferiors that should be printed. Otherwise, all inferiors are
539 printed. */
541 static void
542 print_inferior (struct ui_out *uiout, char *requested_inferiors)
544 struct inferior *inf;
545 struct cleanup *old_chain;
546 int inf_count = 0;
548 /* Compute number of inferiors we will print. */
549 for (inf = inferior_list; inf; inf = inf->next)
551 if (!number_is_in_list (requested_inferiors, inf->num))
552 continue;
554 ++inf_count;
557 if (inf_count == 0)
559 ui_out_message (uiout, 0, "No inferiors.\n");
560 return;
563 old_chain = make_cleanup_ui_out_table_begin_end (uiout, 4, inf_count,
564 "inferiors");
565 ui_out_table_header (uiout, 1, ui_left, "current", "");
566 ui_out_table_header (uiout, 4, ui_left, "number", "Num");
567 ui_out_table_header (uiout, 17, ui_left, "target-id", "Description");
568 ui_out_table_header (uiout, 17, ui_left, "exec", "Executable");
570 ui_out_table_body (uiout);
571 for (inf = inferior_list; inf; inf = inf->next)
573 struct cleanup *chain2;
575 if (!number_is_in_list (requested_inferiors, inf->num))
576 continue;
578 chain2 = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
580 if (inf == current_inferior ())
581 ui_out_field_string (uiout, "current", "*");
582 else
583 ui_out_field_skip (uiout, "current");
585 ui_out_field_int (uiout, "number", inf->num);
587 ui_out_field_string (uiout, "target-id",
588 inferior_pid_to_str (inf->pid));
590 if (inf->pspace->pspace_exec_filename != NULL)
591 ui_out_field_string (uiout, "exec", inf->pspace->pspace_exec_filename);
592 else
593 ui_out_field_skip (uiout, "exec");
595 /* Print extra info that isn't really fit to always present in
596 tabular form. Currently we print the vfork parent/child
597 relationships, if any. */
598 if (inf->vfork_parent)
600 ui_out_text (uiout, _("\n\tis vfork child of inferior "));
601 ui_out_field_int (uiout, "vfork-parent", inf->vfork_parent->num);
603 if (inf->vfork_child)
605 ui_out_text (uiout, _("\n\tis vfork parent of inferior "));
606 ui_out_field_int (uiout, "vfork-child", inf->vfork_child->num);
609 ui_out_text (uiout, "\n");
610 do_cleanups (chain2);
613 do_cleanups (old_chain);
616 static void
617 detach_inferior_command (char *args, int from_tty)
619 int num, pid;
620 struct thread_info *tp;
621 struct get_number_or_range_state state;
623 if (!args || !*args)
624 error (_("Requires argument (inferior id(s) to detach)"));
626 init_number_or_range (&state, args);
627 while (!state.finished)
629 num = get_number_or_range (&state);
631 if (!valid_gdb_inferior_id (num))
633 warning (_("Inferior ID %d not known."), num);
634 continue;
637 pid = gdb_inferior_id_to_pid (num);
639 tp = any_thread_of_process (pid);
640 if (!tp)
642 warning (_("Inferior ID %d has no threads."), num);
643 continue;
646 switch_to_thread (tp->ptid);
648 detach_command (NULL, from_tty);
652 static void
653 kill_inferior_command (char *args, int from_tty)
655 int num, pid;
656 struct thread_info *tp;
657 struct get_number_or_range_state state;
659 if (!args || !*args)
660 error (_("Requires argument (inferior id(s) to kill)"));
662 init_number_or_range (&state, args);
663 while (!state.finished)
665 num = get_number_or_range (&state);
667 if (!valid_gdb_inferior_id (num))
669 warning (_("Inferior ID %d not known."), num);
670 continue;
673 pid = gdb_inferior_id_to_pid (num);
675 tp = any_thread_of_process (pid);
676 if (!tp)
678 warning (_("Inferior ID %d has no threads."), num);
679 continue;
682 switch_to_thread (tp->ptid);
684 target_kill ();
687 bfd_cache_close_all ();
690 static void
691 inferior_command (char *args, int from_tty)
693 struct inferior *inf;
694 int num;
696 num = parse_and_eval_long (args);
698 inf = find_inferior_id (num);
699 if (inf == NULL)
700 error (_("Inferior ID %d not known."), num);
702 printf_filtered (_("[Switching to inferior %d [%s] (%s)]\n"),
703 inf->num,
704 inferior_pid_to_str (inf->pid),
705 (inf->pspace->pspace_exec_filename != NULL
706 ? inf->pspace->pspace_exec_filename
707 : _("<noexec>")));
709 if (inf->pid != 0)
711 if (inf->pid != ptid_get_pid (inferior_ptid))
713 struct thread_info *tp;
715 tp = any_thread_of_process (inf->pid);
716 if (!tp)
717 error (_("Inferior has no threads."));
719 switch_to_thread (tp->ptid);
722 printf_filtered (_("[Switching to thread %d (%s)] "),
723 pid_to_thread_id (inferior_ptid),
724 target_pid_to_str (inferior_ptid));
726 else
728 struct inferior *inf;
730 inf = find_inferior_id (num);
731 set_current_inferior (inf);
732 switch_to_thread (null_ptid);
733 set_current_program_space (inf->pspace);
736 if (inf->pid != 0 && is_running (inferior_ptid))
737 ui_out_text (current_uiout, "(running)\n");
738 else if (inf->pid != 0)
740 ui_out_text (current_uiout, "\n");
741 print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
745 /* Print information about currently known inferiors. */
747 static void
748 info_inferiors_command (char *args, int from_tty)
750 print_inferior (current_uiout, args);
753 /* remove-inferior ID */
755 static void
756 remove_inferior_command (char *args, int from_tty)
758 int num;
759 struct inferior *inf;
760 struct get_number_or_range_state state;
762 if (args == NULL || *args == '\0')
763 error (_("Requires an argument (inferior id(s) to remove)"));
765 init_number_or_range (&state, args);
766 while (!state.finished)
768 num = get_number_or_range (&state);
769 inf = find_inferior_id (num);
771 if (inf == NULL)
773 warning (_("Inferior ID %d not known."), num);
774 continue;
777 if (inf == current_inferior ())
779 warning (_("Can not remove current symbol inferior %d."), num);
780 continue;
783 if (inf->pid != 0)
785 warning (_("Can not remove active inferior %d."), num);
786 continue;
789 delete_inferior_1 (inf, 1);
793 struct inferior *
794 add_inferior_with_spaces (void)
796 struct address_space *aspace;
797 struct program_space *pspace;
798 struct inferior *inf;
799 struct gdbarch_info info;
801 /* If all inferiors share an address space on this system, this
802 doesn't really return a new address space; otherwise, it
803 really does. */
804 aspace = maybe_new_address_space ();
805 pspace = add_program_space (aspace);
806 inf = add_inferior (0);
807 inf->pspace = pspace;
808 inf->aspace = pspace->aspace;
810 /* Setup the inferior's initial arch, based on information obtained
811 from the global "set ..." options. */
812 gdbarch_info_init (&info);
813 inf->gdbarch = gdbarch_find_by_info (info);
814 /* The "set ..." options reject invalid settings, so we should
815 always have a valid arch by now. */
816 gdb_assert (inf->gdbarch != NULL);
818 return inf;
821 /* add-inferior [-copies N] [-exec FILENAME] */
823 static void
824 add_inferior_command (char *args, int from_tty)
826 int i, copies = 1;
827 char *exec = NULL;
828 char **argv;
829 struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
831 if (args)
833 argv = gdb_buildargv (args);
834 make_cleanup_freeargv (argv);
836 for (; *argv != NULL; argv++)
838 if (**argv == '-')
840 if (strcmp (*argv, "-copies") == 0)
842 ++argv;
843 if (!*argv)
844 error (_("No argument to -copies"));
845 copies = parse_and_eval_long (*argv);
847 else if (strcmp (*argv, "-exec") == 0)
849 ++argv;
850 if (!*argv)
851 error (_("No argument to -exec"));
852 exec = *argv;
855 else
856 error (_("Invalid argument"));
860 save_current_space_and_thread ();
862 for (i = 0; i < copies; ++i)
864 struct inferior *inf = add_inferior_with_spaces ();
866 printf_filtered (_("Added inferior %d\n"), inf->num);
868 if (exec != NULL)
870 /* Switch over temporarily, while reading executable and
871 symbols.q. */
872 set_current_program_space (inf->pspace);
873 set_current_inferior (inf);
874 switch_to_thread (null_ptid);
876 exec_file_attach (exec, from_tty);
877 symbol_file_add_main (exec, from_tty);
881 do_cleanups (old_chain);
884 /* clone-inferior [-copies N] [ID] */
886 static void
887 clone_inferior_command (char *args, int from_tty)
889 int i, copies = 1;
890 char **argv;
891 struct inferior *orginf = NULL;
892 struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
894 if (args)
896 argv = gdb_buildargv (args);
897 make_cleanup_freeargv (argv);
899 for (; *argv != NULL; argv++)
901 if (**argv == '-')
903 if (strcmp (*argv, "-copies") == 0)
905 ++argv;
906 if (!*argv)
907 error (_("No argument to -copies"));
908 copies = parse_and_eval_long (*argv);
910 if (copies < 0)
911 error (_("Invalid copies number"));
914 else
916 if (orginf == NULL)
918 int num;
920 /* The first non-option (-) argument specified the
921 program space ID. */
922 num = parse_and_eval_long (*argv);
923 orginf = find_inferior_id (num);
925 if (orginf == NULL)
926 error (_("Inferior ID %d not known."), num);
927 continue;
929 else
930 error (_("Invalid argument"));
935 /* If no inferior id was specified, then the user wants to clone the
936 current inferior. */
937 if (orginf == NULL)
938 orginf = current_inferior ();
940 save_current_space_and_thread ();
942 for (i = 0; i < copies; ++i)
944 struct address_space *aspace;
945 struct program_space *pspace;
946 struct inferior *inf;
948 /* If all inferiors share an address space on this system, this
949 doesn't really return a new address space; otherwise, it
950 really does. */
951 aspace = maybe_new_address_space ();
952 pspace = add_program_space (aspace);
953 inf = add_inferior (0);
954 inf->pspace = pspace;
955 inf->aspace = pspace->aspace;
956 inf->gdbarch = orginf->gdbarch;
958 /* If the original inferior had a user specified target
959 description, make the clone use it too. */
960 if (target_desc_info_from_user_p (inf->tdesc_info))
961 copy_inferior_target_desc_info (inf, orginf);
963 printf_filtered (_("Added inferior %d.\n"), inf->num);
965 set_current_inferior (inf);
966 switch_to_thread (null_ptid);
967 clone_program_space (pspace, orginf->pspace);
970 do_cleanups (old_chain);
973 /* Print notices when new inferiors are created and die. */
974 static void
975 show_print_inferior_events (struct ui_file *file, int from_tty,
976 struct cmd_list_element *c, const char *value)
978 fprintf_filtered (file, _("Printing of inferior events is %s.\n"), value);
983 void
984 initialize_inferiors (void)
986 struct cmd_list_element *c = NULL;
988 /* There's always one inferior. Note that this function isn't an
989 automatic _initialize_foo function, since other _initialize_foo
990 routines may need to install their per-inferior data keys. We
991 can only allocate an inferior when all those modules have done
992 that. Do this after initialize_progspace, due to the
993 current_program_space reference. */
994 current_inferior_ = add_inferior (0);
995 current_inferior_->pspace = current_program_space;
996 current_inferior_->aspace = current_program_space->aspace;
997 /* The architecture will be initialized shortly, by
998 initialize_current_architecture. */
1000 add_info ("inferiors", info_inferiors_command,
1001 _("IDs of specified inferiors (all inferiors if no argument)."));
1003 c = add_com ("add-inferior", no_class, add_inferior_command, _("\
1004 Add a new inferior.\n\
1005 Usage: add-inferior [-copies <N>] [-exec <FILENAME>]\n\
1006 N is the optional number of inferiors to add, default is 1.\n\
1007 FILENAME is the file name of the executable to use\n\
1008 as main program."));
1009 set_cmd_completer (c, filename_completer);
1011 add_com ("remove-inferiors", no_class, remove_inferior_command, _("\
1012 Remove inferior ID (or list of IDs).\n\
1013 Usage: remove-inferiors ID..."));
1015 add_com ("clone-inferior", no_class, clone_inferior_command, _("\
1016 Clone inferior ID.\n\
1017 Usage: clone-inferior [-copies <N>] [ID]\n\
1018 Add N copies of inferior ID. The new inferior has the same\n\
1019 executable loaded as the copied inferior. If -copies is not specified,\n\
1020 adds 1 copy. If ID is not specified, it is the current inferior\n\
1021 that is cloned."));
1023 add_cmd ("inferiors", class_run, detach_inferior_command, _("\
1024 Detach from inferior ID (or list of IDS)."),
1025 &detachlist);
1027 add_cmd ("inferiors", class_run, kill_inferior_command, _("\
1028 Kill inferior ID (or list of IDs)."),
1029 &killlist);
1031 add_cmd ("inferior", class_run, inferior_command, _("\
1032 Use this command to switch between inferiors.\n\
1033 The new inferior ID must be currently known."),
1034 &cmdlist);
1036 add_setshow_boolean_cmd ("inferior-events", no_class,
1037 &print_inferior_events, _("\
1038 Set printing of inferior events (e.g., inferior start and exit)."), _("\
1039 Show printing of inferior events (e.g., inferior start and exit)."), NULL,
1040 NULL,
1041 show_print_inferior_events,
1042 &setprintlist, &showprintlist);