GDB (xrefs)
/tmp/gdb-8.1/gdb/inferior.c
Go to the documentation of this file.
1 /* Multi-process control for GDB, the GNU debugger.
2 
3  Copyright (C) 2008-2018 Free Software Foundation, Inc.
4 
5  This file is part of GDB.
6 
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.
11 
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.
16 
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/>. */
19 
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 "gdbcore.h"
31 #include "symfile.h"
32 #include "environ.h"
33 #include "cli/cli-utils.h"
34 #include "continuations.h"
35 #include "arch-utils.h"
36 #include "target-descriptions.h"
37 #include "readline/tilde.h"
38 #include "progspace-and-thread.h"
39 
40 /* Keep a registry of per-inferior data-pointers required by other GDB
41  modules. */
42 
44 
45 struct inferior *inferior_list = NULL;
47 
48 /* Print notices on inferior events (attach, detach, etc.), set with
49  `set print inferior-events'. */
50 static int print_inferior_events = 0;
51 
52 /* The Current Inferior. This is a strong reference. I.e., whenever
53  an inferior is the current inferior, its refcount is
54  incremented. */
55 static struct inferior *current_inferior_ = NULL;
56 
57 struct inferior*
59 {
60  return current_inferior_;
61 }
62 
63 void
65 {
66  /* There's always an inferior. */
67  gdb_assert (inf != NULL);
68 
69  inf->incref ();
72 }
73 
75 
77 {
78  inferior *inf = this;
79 
81  inferior_free_data (inf);
82  xfree (inf->args);
83  xfree (inf->terminal);
84  target_desc_info_free (inf->tdesc_info);
85 }
86 
88  : num (++highest_inferior_num),
89  pid (pid_),
90  environment (gdb_environ::from_host_environ ()),
91  registry_data ()
92 {
93  inferior_alloc_data (this);
94 }
95 
96 struct inferior *
98 {
99  inferior *inf = new inferior (pid);
100 
101  if (inferior_list == NULL)
102  inferior_list = inf;
103  else
104  {
105  inferior *last;
106 
107  for (last = inferior_list; last->next != NULL; last = last->next)
108  ;
109  last->next = inf;
110  }
111 
113 
114  if (pid != 0)
116 
117  return inf;
118 }
119 
120 struct inferior *
122 {
123  struct inferior *inf = add_inferior_silent (pid);
124 
126  printf_unfiltered (_("[New inferior %d]\n"), pid);
127 
128  return inf;
129 }
130 
132 {
133  int pid;
134  int silent;
135 };
136 
137 static int
138 delete_thread_of_inferior (struct thread_info *tp, void *data)
139 {
141  = (struct delete_thread_of_inferior_arg *) data;
142 
143  if (ptid_get_pid (tp->ptid) == arg->pid)
144  {
145  if (arg->silent)
147  else
148  delete_thread (tp->ptid);
149  }
150 
151  return 0;
152 }
153 
154 void
155 delete_inferior (struct inferior *todel)
156 {
157  struct inferior *inf, *infprev;
159 
160  infprev = NULL;
161 
162  for (inf = inferior_list; inf; infprev = inf, inf = inf->next)
163  if (inf == todel)
164  break;
165 
166  if (!inf)
167  return;
168 
169  arg.pid = inf->pid;
170  arg.silent = 1;
171 
173 
174  if (infprev)
175  infprev->next = inf->next;
176  else
177  inferior_list = inf->next;
178 
180 
181  /* If this program space is rendered useless, remove it. */
182  if (program_space_empty_p (inf->pspace))
183  delete_program_space (inf->pspace);
184 
185  delete inf;
186 }
187 
188 /* If SILENT then be quiet -- don't announce a inferior exit, or the
189  exit of its threads. */
190 
191 static void
192 exit_inferior_1 (struct inferior *inftoex, int silent)
193 {
194  struct inferior *inf;
196 
197  for (inf = inferior_list; inf; inf = inf->next)
198  if (inf == inftoex)
199  break;
200 
201  if (!inf)
202  return;
203 
204  arg.pid = inf->pid;
205  arg.silent = silent;
206 
208 
210 
211  inf->pid = 0;
212  inf->fake_pid_p = 0;
213  inf->priv = NULL;
214 
215  if (inf->vfork_parent != NULL)
216  {
217  inf->vfork_parent->vfork_child = NULL;
218  inf->vfork_parent = NULL;
219  }
220  if (inf->vfork_child != NULL)
221  {
222  inf->vfork_child->vfork_parent = NULL;
223  inf->vfork_child = NULL;
224  }
225 
226  inf->pending_detach = 0;
227 }
228 
229 void
231 {
232  struct inferior *inf = find_inferior_pid (pid);
233 
234  exit_inferior_1 (inf, 0);
235 
237  printf_unfiltered (_("[Inferior %d exited]\n"), pid);
238 }
239 
240 void
242 {
243  struct inferior *inf = find_inferior_pid (pid);
244 
245  exit_inferior_1 (inf, 1);
246 }
247 
248 void
250 {
251  struct inferior *inf = find_inferior_id (num);
252 
253  exit_inferior_1 (inf, 1);
254 }
255 
256 void
258 {
259  struct inferior *inf = find_inferior_pid (pid);
260 
261  exit_inferior_1 (inf, 0);
262 
264  printf_unfiltered (_("[Inferior %d detached]\n"), pid);
265 }
266 
267 void
269 {
270  inf->pid = pid;
271  inf->has_exit_code = 0;
272  inf->exit_code = 0;
273 
275 }
276 
277 void
279 {
280  struct inferior *inf;
281 
282  for (inf = inferior_list; inf; inf = inf->next)
283  {
284  if (inf->pid != 0)
286  }
287 }
288 
289 struct inferior *
291 {
292  struct inferior *inf;
293 
294  for (inf = inferior_list; inf; inf = inf->next)
295  if (inf->num == num)
296  return inf;
297 
298  return NULL;
299 }
300 
301 struct inferior *
303 {
304  struct inferior *inf;
305 
306  /* Looking for inferior pid == 0 is always wrong, and indicative of
307  a bug somewhere else. There may be more than one with pid == 0,
308  for instance. */
309  gdb_assert (pid != 0);
310 
311  for (inf = inferior_list; inf; inf = inf->next)
312  if (inf->pid == pid)
313  return inf;
314 
315  return NULL;
316 }
317 
318 /* See inferior.h */
319 
320 struct inferior *
322 {
323  return find_inferior_pid (ptid_get_pid (ptid));
324 }
325 
326 /* See inferior.h. */
327 
328 struct inferior *
330 {
331  struct inferior *inf = current_inferior ();
332 
333  if (inf->pspace == pspace)
334  return inf;
335 
336  for (inf = inferior_list; inf != NULL; inf = inf->next)
337  {
338  if (inf->pspace == pspace)
339  return inf;
340  }
341 
342  return NULL;
343 }
344 
345 struct inferior *
346 iterate_over_inferiors (int (*callback) (struct inferior *, void *),
347  void *data)
348 {
349  struct inferior *inf, *infnext;
350 
351  for (inf = inferior_list; inf; inf = infnext)
352  {
353  infnext = inf->next;
354  if ((*callback) (inf, data))
355  return inf;
356  }
357 
358  return NULL;
359 }
360 
361 int
363 {
364  struct inferior *inf;
365 
366  for (inf = inferior_list; inf; inf = inf->next)
367  if (inf->num == num)
368  return 1;
369 
370  return 0;
371 }
372 
373 int
375 {
376  struct inferior *inf;
377 
378  for (inf = inferior_list; inf; inf = inf->next)
379  if (inf->pid == pid)
380  return inf->num;
381 
382  return 0;
383 }
384 
385 int
387 {
389  if (inferior)
390  return inferior->pid;
391  else
392  return -1;
393 }
394 
395 int
397 {
398  struct inferior *inf;
399 
400  for (inf = inferior_list; inf; inf = inf->next)
401  if (inf->pid == pid)
402  return 1;
403 
404  return 0;
405 }
406 
407 int
409 {
410  struct inferior *inf;
411 
412  for (inf = inferior_list; inf; inf = inf->next)
413  if (inf->pid != 0)
414  return 1;
415 
416  return 0;
417 }
418 
419 /* Return the number of live inferiors. We account for the case
420  where an inferior might have a non-zero pid but no threads, as
421  in the middle of a 'mourn' operation. */
422 
423 int
425 {
426  struct inferior *inf;
427  int num_inf = 0;
428 
429  for (inf = inferior_list; inf; inf = inf->next)
430  if (inf->pid != 0)
431  {
432  struct thread_info *tp;
433 
435  if (tp && ptid_get_pid (tp->ptid) == inf->pid)
436  if (target_has_execution_1 (tp->ptid))
437  {
438  /* Found a live thread in this inferior, go to the next
439  inferior. */
440  ++num_inf;
441  break;
442  }
443  }
444 
445  return num_inf;
446 }
447 
448 /* Return true if there is at least one live inferior. */
449 
450 int
452 {
453  return number_of_live_inferiors () > 0;
454 }
455 
456 /* Prune away any unused inferiors, and then prune away no longer used
457  program spaces. */
458 
459 void
461 {
462  struct inferior *ss, **ss_link;
463 
464  ss = inferior_list;
465  ss_link = &inferior_list;
466  while (ss)
467  {
468  if (!ss->deletable ()
469  || !ss->removable
470  || ss->pid != 0)
471  {
472  ss_link = &ss->next;
473  ss = *ss_link;
474  continue;
475  }
476 
477  *ss_link = ss->next;
478  delete_inferior (ss);
479  ss = *ss_link;
480  }
481 }
482 
483 /* Simply returns the count of inferiors. */
484 
485 int
487 {
488  struct inferior *inf;
489  int count = 0;
490 
491  for (inf = inferior_list; inf != NULL; inf = inf->next)
492  count++;
493 
494  return count;
495 }
496 
497 /* Converts an inferior process id to a string. Like
498  target_pid_to_str, but special cases the null process. */
499 
500 static const char *
502 {
503  if (pid != 0)
504  return target_pid_to_str (pid_to_ptid (pid));
505  else
506  return _("<null>");
507 }
508 
509 /* See inferior.h. */
510 
511 void
513 {
514  struct inferior *inf = current_inferior ();
515  const char *filename = inf->pspace->pspace_exec_filename;
516 
517  if (filename == NULL)
518  filename = _("<noexec>");
519 
520  uiout->message (_("[Switching to inferior %d [%s] (%s)]\n"),
521  inf->num, inferior_pid_to_str (inf->pid), filename);
522 }
523 
524 /* Prints the list of inferiors and their details on UIOUT. This is a
525  version of 'info_inferior_command' suitable for use from MI.
526 
527  If REQUESTED_INFERIORS is not NULL, it's a list of GDB ids of the
528  inferiors that should be printed. Otherwise, all inferiors are
529  printed. */
530 
531 static void
532 print_inferior (struct ui_out *uiout, const char *requested_inferiors)
533 {
534  struct inferior *inf;
535  int inf_count = 0;
536 
537  /* Compute number of inferiors we will print. */
538  for (inf = inferior_list; inf; inf = inf->next)
539  {
540  if (!number_is_in_list (requested_inferiors, inf->num))
541  continue;
542 
543  ++inf_count;
544  }
545 
546  if (inf_count == 0)
547  {
548  uiout->message ("No inferiors.\n");
549  return;
550  }
551 
552  ui_out_emit_table table_emitter (uiout, 4, inf_count, "inferiors");
553  uiout->table_header (1, ui_left, "current", "");
554  uiout->table_header (4, ui_left, "number", "Num");
555  uiout->table_header (17, ui_left, "target-id", "Description");
556  uiout->table_header (17, ui_left, "exec", "Executable");
557 
558  uiout->table_body ();
559  for (inf = inferior_list; inf; inf = inf->next)
560  {
561  if (!number_is_in_list (requested_inferiors, inf->num))
562  continue;
563 
564  ui_out_emit_tuple tuple_emitter (uiout, NULL);
565 
566  if (inf == current_inferior ())
567  uiout->field_string ("current", "*");
568  else
569  uiout->field_skip ("current");
570 
571  uiout->field_int ("number", inf->num);
572 
573  uiout->field_string ("target-id", inferior_pid_to_str (inf->pid));
574 
575  if (inf->pspace->pspace_exec_filename != NULL)
576  uiout->field_string ("exec", inf->pspace->pspace_exec_filename);
577  else
578  uiout->field_skip ("exec");
579 
580  /* Print extra info that isn't really fit to always present in
581  tabular form. Currently we print the vfork parent/child
582  relationships, if any. */
583  if (inf->vfork_parent)
584  {
585  uiout->text (_("\n\tis vfork child of inferior "));
586  uiout->field_int ("vfork-parent", inf->vfork_parent->num);
587  }
588  if (inf->vfork_child)
589  {
590  uiout->text (_("\n\tis vfork parent of inferior "));
591  uiout->field_int ("vfork-child", inf->vfork_child->num);
592  }
593 
594  uiout->text ("\n");
595  }
596 }
597 
598 static void
599 detach_inferior_command (const char *args, int from_tty)
600 {
601  struct thread_info *tp;
602 
603  if (!args || !*args)
604  error (_("Requires argument (inferior id(s) to detach)"));
605 
606  number_or_range_parser parser (args);
607  while (!parser.finished ())
608  {
609  int num = parser.get_number ();
610 
611  if (!valid_gdb_inferior_id (num))
612  {
613  warning (_("Inferior ID %d not known."), num);
614  continue;
615  }
616 
617  int pid = gdb_inferior_id_to_pid (num);
618  if (pid == 0)
619  {
620  warning (_("Inferior ID %d is not running."), num);
621  continue;
622  }
623 
624  tp = any_thread_of_process (pid);
625  if (!tp)
626  {
627  warning (_("Inferior ID %d has no threads."), num);
628  continue;
629  }
630 
631  switch_to_thread (tp->ptid);
632 
633  detach_command (NULL, from_tty);
634  }
635 }
636 
637 static void
638 kill_inferior_command (const char *args, int from_tty)
639 {
640  struct thread_info *tp;
641 
642  if (!args || !*args)
643  error (_("Requires argument (inferior id(s) to kill)"));
644 
645  number_or_range_parser parser (args);
646  while (!parser.finished ())
647  {
648  int num = parser.get_number ();
649 
650  if (!valid_gdb_inferior_id (num))
651  {
652  warning (_("Inferior ID %d not known."), num);
653  continue;
654  }
655 
656  int pid = gdb_inferior_id_to_pid (num);
657  if (pid == 0)
658  {
659  warning (_("Inferior ID %d is not running."), num);
660  continue;
661  }
662 
663  tp = any_thread_of_process (pid);
664  if (!tp)
665  {
666  warning (_("Inferior ID %d has no threads."), num);
667  continue;
668  }
669 
670  switch_to_thread (tp->ptid);
671 
672  target_kill ();
673  }
674 
675  bfd_cache_close_all ();
676 }
677 
678 static void
679 inferior_command (const char *args, int from_tty)
680 {
681  struct inferior *inf;
682  int num;
683 
685 
687  if (inf == NULL)
688  error (_("Inferior ID %d not known."), num);
689 
690  if (inf->pid != 0)
691  {
692  if (inf->pid != ptid_get_pid (inferior_ptid))
693  {
694  struct thread_info *tp;
695 
696  tp = any_thread_of_process (inf->pid);
697  if (!tp)
698  error (_("Inferior has no threads."));
699 
700  switch_to_thread (tp->ptid);
701  }
702 
707  }
708  else
709  {
712  set_current_program_space (inf->pspace);
713 
715  }
716 }
717 
718 /* Print information about currently known inferiors. */
719 
720 static void
721 info_inferiors_command (const char *args, int from_tty)
722 {
724 }
725 
726 /* remove-inferior ID */
727 
728 static void
729 remove_inferior_command (const char *args, int from_tty)
730 {
731  if (args == NULL || *args == '\0')
732  error (_("Requires an argument (inferior id(s) to remove)"));
733 
734  number_or_range_parser parser (args);
735  while (!parser.finished ())
736  {
737  int num = parser.get_number ();
738  struct inferior *inf = find_inferior_id (num);
739 
740  if (inf == NULL)
741  {
742  warning (_("Inferior ID %d not known."), num);
743  continue;
744  }
745 
746  if (!inf->deletable ())
747  {
748  warning (_("Can not remove current inferior %d."), num);
749  continue;
750  }
751 
752  if (inf->pid != 0)
753  {
754  warning (_("Can not remove active inferior %d."), num);
755  continue;
756  }
757 
759  }
760 }
761 
762 struct inferior *
764 {
765  struct address_space *aspace;
766  struct program_space *pspace;
767  struct inferior *inf;
768  struct gdbarch_info info;
769 
770  /* If all inferiors share an address space on this system, this
771  doesn't really return a new address space; otherwise, it
772  really does. */
773  aspace = maybe_new_address_space ();
774  pspace = add_program_space (aspace);
775  inf = add_inferior (0);
776  inf->pspace = pspace;
777  inf->aspace = pspace->aspace;
778 
779  /* Setup the inferior's initial arch, based on information obtained
780  from the global "set ..." options. */
781  gdbarch_info_init (&info);
782  inf->gdbarch = gdbarch_find_by_info (info);
783  /* The "set ..." options reject invalid settings, so we should
784  always have a valid arch by now. */
785  gdb_assert (inf->gdbarch != NULL);
786 
787  return inf;
788 }
789 
790 /* add-inferior [-copies N] [-exec FILENAME] */
791 
792 static void
793 add_inferior_command (const char *args, int from_tty)
794 {
795  int i, copies = 1;
797  symfile_add_flags add_flags = 0;
798 
799  if (from_tty)
800  add_flags |= SYMFILE_VERBOSE;
801 
802  if (args)
803  {
804  gdb_argv built_argv (args);
805 
806  for (char **argv = built_argv.get (); *argv != NULL; argv++)
807  {
808  if (**argv == '-')
809  {
810  if (strcmp (*argv, "-copies") == 0)
811  {
812  ++argv;
813  if (!*argv)
814  error (_("No argument to -copies"));
815  copies = parse_and_eval_long (*argv);
816  }
817  else if (strcmp (*argv, "-exec") == 0)
818  {
819  ++argv;
820  if (!*argv)
821  error (_("No argument to -exec"));
822  exec.reset (tilde_expand (*argv));
823  }
824  }
825  else
826  error (_("Invalid argument"));
827  }
828  }
829 
830  scoped_restore_current_pspace_and_thread restore_pspace_thread;
831 
832  for (i = 0; i < copies; ++i)
833  {
835 
836  printf_filtered (_("Added inferior %d\n"), inf->num);
837 
838  if (exec != NULL)
839  {
840  /* Switch over temporarily, while reading executable and
841  symbols.q. */
842  set_current_program_space (inf->pspace);
845 
846  exec_file_attach (exec.get (), from_tty);
847  symbol_file_add_main (exec.get (), add_flags);
848  }
849  }
850 }
851 
852 /* clone-inferior [-copies N] [ID] */
853 
854 static void
855 clone_inferior_command (const char *args, int from_tty)
856 {
857  int i, copies = 1;
858  struct inferior *orginf = NULL;
859 
860  if (args)
861  {
862  gdb_argv built_argv (args);
863 
864  char **argv = built_argv.get ();
865  for (; *argv != NULL; argv++)
866  {
867  if (**argv == '-')
868  {
869  if (strcmp (*argv, "-copies") == 0)
870  {
871  ++argv;
872  if (!*argv)
873  error (_("No argument to -copies"));
874  copies = parse_and_eval_long (*argv);
875 
876  if (copies < 0)
877  error (_("Invalid copies number"));
878  }
879  }
880  else
881  {
882  if (orginf == NULL)
883  {
884  int num;
885 
886  /* The first non-option (-) argument specified the
887  program space ID. */
889  orginf = find_inferior_id (num);
890 
891  if (orginf == NULL)
892  error (_("Inferior ID %d not known."), num);
893  continue;
894  }
895  else
896  error (_("Invalid argument"));
897  }
898  }
899  }
900 
901  /* If no inferior id was specified, then the user wants to clone the
902  current inferior. */
903  if (orginf == NULL)
904  orginf = current_inferior ();
905 
906  scoped_restore_current_pspace_and_thread restore_pspace_thread;
907 
908  for (i = 0; i < copies; ++i)
909  {
910  struct address_space *aspace;
911  struct program_space *pspace;
912  struct inferior *inf;
913 
914  /* If all inferiors share an address space on this system, this
915  doesn't really return a new address space; otherwise, it
916  really does. */
919  inf = add_inferior (0);
920  inf->pspace = pspace;
921  inf->aspace = pspace->aspace;
922  inf->gdbarch = orginf->gdbarch;
923 
924  /* If the original inferior had a user specified target
925  description, make the clone use it too. */
926  if (target_desc_info_from_user_p (inf->tdesc_info))
928 
929  printf_filtered (_("Added inferior %d.\n"), inf->num);
930 
933  clone_program_space (pspace, orginf->pspace);
934  }
935 }
936 
937 /* Print notices when new inferiors are created and die. */
938 static void
939 show_print_inferior_events (struct ui_file *file, int from_tty,
940  struct cmd_list_element *c, const char *value)
941 {
942  fprintf_filtered (file, _("Printing of inferior events is %s.\n"), value);
943 }
944 
945 /* Return a new value for the selected inferior's id. */
946 
947 static struct value *
949  void *ignore)
950 {
951  struct inferior *inf = current_inferior ();
952 
953  return value_from_longest (builtin_type (gdbarch)->builtin_int, inf->num);
954 }
955 
956 /* Implementation of `$_inferior' variable. */
957 
958 static const struct internalvar_funcs inferior_funcs =
959 {
961  NULL,
962  NULL
963 };
964 
965 
966 
967 void
969 {
970  struct cmd_list_element *c = NULL;
971 
972  /* There's always one inferior. Note that this function isn't an
973  automatic _initialize_foo function, since other _initialize_foo
974  routines may need to install their per-inferior data keys. We
975  can only allocate an inferior when all those modules have done
976  that. Do this after initialize_progspace, due to the
977  current_program_space reference. */
982  /* The architecture will be initialized shortly, by
983  initialize_current_architecture. */
984 
985  add_info ("inferiors", info_inferiors_command,
986  _("IDs of specified inferiors (all inferiors if no argument)."));
987 
988  c = add_com ("add-inferior", no_class, add_inferior_command, _("\
989 Add a new inferior.\n\
990 Usage: add-inferior [-copies <N>] [-exec <FILENAME>]\n\
991 N is the optional number of inferiors to add, default is 1.\n\
992 FILENAME is the file name of the executable to use\n\
993 as main program."));
995 
996  add_com ("remove-inferiors", no_class, remove_inferior_command, _("\
997 Remove inferior ID (or list of IDs).\n\
998 Usage: remove-inferiors ID..."));
999 
1000  add_com ("clone-inferior", no_class, clone_inferior_command, _("\
1001 Clone inferior ID.\n\
1002 Usage: clone-inferior [-copies <N>] [ID]\n\
1003 Add N copies of inferior ID. The new inferior has the same\n\
1004 executable loaded as the copied inferior. If -copies is not specified,\n\
1005 adds 1 copy. If ID is not specified, it is the current inferior\n\
1006 that is cloned."));
1007 
1008  add_cmd ("inferiors", class_run, detach_inferior_command, _("\
1009 Detach from inferior ID (or list of IDS)."),
1010  &detachlist);
1011 
1012  add_cmd ("inferiors", class_run, kill_inferior_command, _("\
1013 Kill inferior ID (or list of IDs)."),
1014  &killlist);
1015 
1016  add_cmd ("inferior", class_run, inferior_command, _("\
1017 Use this command to switch between inferiors.\n\
1018 The new inferior ID must be currently known."),
1019  &cmdlist);
1020 
1021  add_setshow_boolean_cmd ("inferior-events", no_class,
1023 Set printing of inferior events (e.g., inferior start and exit)."), _("\
1024 Show printing of inferior events (e.g., inferior start and exit)."), NULL,
1025  NULL,
1028 
1029  create_internalvar_type_lazy ("_inferior", &inferior_funcs, NULL);
1030 }
static void clone_inferior_command(const char *args, int from_tty)
Definition: inferior.c:855
static int delete_thread_of_inferior(struct thread_info *tp, void *data)
Definition: inferior.c:138
static void info_inferiors_command(const char *args, int from_tty)
Definition: inferior.c:721
int have_live_inferiors(void)
Definition: inferior.c:451
struct address_space * maybe_new_address_space(void)
Definition: progspace.c:73
void detach_command(const char *args, int from_tty)
Definition: infcmd.c:2968
int valid_gdb_inferior_id(int num)
Definition: inferior.c:362
int have_inferiors(void)
Definition: inferior.c:408
#define DEFINE_REGISTRY(TAG, ACCESS)
Definition: registry.h:154
void field_string(const char *fldname, const char *string)
Definition: ui-out.c:544
struct address_space * aspace
Definition: progspace.h:166
int ptid_get_pid(const ptid_t &ptid)
Definition: ptid.c:47
void delete_thread(ptid_t)
Definition: thread.c:476
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
Definition: gnu-nat.c:1824
void xfree(void *)
static void detach_inferior_command(const char *args, int from_tty)
Definition: inferior.c:599
~inferior()
Definition: inferior.c:76
int number_is_in_list(const char *list, int number)
Definition: cli-utils.c:227
void copy_inferior_target_desc_info(struct inferior *destinf, struct inferior *srcinf)
void warning(const char *fmt,...)
Definition: errors.c:26
int target_desc_info_from_user_p(struct target_desc_info *info)
void delete_thread_silent(ptid_t)
Definition: thread.c:482
struct inferior * add_inferior_silent(int pid)
Definition: inferior.c:97
void field_skip(const char *fldname)
Definition: ui-out.c:532
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
Definition: cli-decode.c:886
struct gdbarch * gdbarch_find_by_info(struct gdbarch_info info)
Definition: gdbarch.c:5332
int pid
Definition: inferior.h:328
void table_header(int width, ui_align align, const std::string &col_name, const std::string &col_hdr)
Definition: ui-out.c:365
#define REGISTRY_ACCESS_FIELD(CONTAINER)
Definition: registry.h:85
void observer_notify_user_selected_context_changed(user_selected_what selection)
static void remove_inferior_command(const char *args, int from_tty)
Definition: inferior.c:729
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition: cli-decode.c:262
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition: completer.c:152
void symbol_file_add_main(const char *args, symfile_add_flags add_flags)
Definition: symfile.c:1288
struct inferior * find_inferior_ptid(ptid_t ptid)
Definition: inferior.c:321
struct cmd_list_element * cmdlist
Definition: cli-cmds.c:79
struct inferior * iterate_over_inferiors(int(*callback)(struct inferior *, void *), void *data)
Definition: inferior.c:346
void target_kill(void)
Definition: target.c:420
bool removable
Definition: inferior.h:343
int program_space_empty_p(struct program_space *pspace)
Definition: progspace.c:206
#define _(String)
Definition: gdb_locale.h:35
void delete_program_space(struct program_space *pspace)
Definition: progspace.c:218
static const struct internalvar_funcs inferior_funcs
Definition: inferior.c:958
int number_of_inferiors(void)
Definition: inferior.c:486
Definition: ui-out.h:44
int target_has_execution_1(ptid_t the_ptid)
Definition: target.c:296
static void inferior_command(const char *args, int from_tty)
Definition: inferior.c:679
void text(const char *string)
Definition: ui-out.c:581
struct address_space * aspace
Definition: inferior.h:346
void observer_notify_inferior_added(struct inferior *inf)
void printf_filtered(const char *format,...)
Definition: utils.c:2045
struct program_space * add_program_space(struct address_space *aspace)
Definition: progspace.c:113
void set_current_program_space(struct program_space *pspace)
Definition: progspace.c:190
static int print_inferior_events
Definition: inferior.c:50
struct program_space * pspace
Definition: inferior.h:349
struct thread_info * iterate_over_threads(thread_callback_func, void *)
Definition: thread.c:551
void switch_to_thread(ptid_t ptid)
Definition: thread.c:1445
void discard_all_inferior_continuations(struct inferior *inf)
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
static int highest_inferior_num
Definition: inferior.c:46
void delete_inferior(struct inferior *todel)
Definition: inferior.c:155
void fprintf_filtered(struct ui_file *stream, const char *format,...)
Definition: utils.c:2008
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition: cli-decode.c:160
struct inferior * add_inferior(int pid)
Definition: inferior.c:121
Definition: ptid.h:35
static void print_inferior(struct ui_out *uiout, const char *requested_inferiors)
Definition: inferior.c:532
bool finished() const
Definition: cli-utils.h:78
inferior(int pid)
Definition: inferior.c:87
void discard_all_inferiors(void)
Definition: inferior.c:278
ptid_t pid_to_ptid(int pid)
Definition: ptid.c:39
#define current_uiout
Definition: ui-out.h:39
void prune_inferiors(void)
Definition: inferior.c:460
struct inferior * find_inferior_pid(int pid)
Definition: inferior.c:302
struct inferior * inferior_list
Definition: inferior.c:45
static void show_print_inferior_events(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition: inferior.c:939
Definition: gnu-nat.c:174
static struct inferior * current_inferior_
Definition: inferior.c:55
struct value * value_from_longest(struct type *type, LONGEST num)
Definition: value.c:3534
struct gdbarch * gdbarch
Definition: inferior.h:437
ptid_t ptid
Definition: gdbthread.h:219
struct cmd_list_element * setprintlist
Definition: cli-cmds.c:149
void exit_inferior(int pid)
Definition: inferior.c:230
void printf_unfiltered(const char *format,...)
Definition: utils.c:2056
int num
Definition: inferior.h:324
int pid_to_gdb_inferior_id(int pid)
Definition: inferior.c:374
void observer_notify_inferior_removed(struct inferior *inf)
void target_desc_info_free(struct target_desc_info *tdesc_info)
virtual ~private_inferior()=0
int number_of_live_inferiors(void)
Definition: inferior.c:424
void print_selected_inferior(struct ui_out *uiout)
Definition: inferior.c:512
struct program_space * clone_program_space(struct program_space *dest, struct program_space *src)
Definition: progspace.c:170
#define gdb_assert(expr)
Definition: gdb_assert.h:32
Definition: value.c:169
static void kill_inferior_command(const char *args, int from_tty)
Definition: inferior.c:638
Definition: ui-out.h:77
void exec_file_attach(const char *filename, int from_tty)
Definition: exec.c:244
int in_inferior_list(int pid)
Definition: inferior.c:396
struct cmd_list_element * detachlist
Definition: cli-cmds.c:103
struct inferior * next
Definition: inferior.h:320
ptid_t null_ptid
Definition: ptid.c:25
#define ALL_NON_EXITED_THREADS(T)
Definition: gdbthread.h:490
pid_t pid
Definition: gnu-nat.c:187
void field_int(const char *fldname, int value)
Definition: ui-out.c:486
void gdbarch_info_init(struct gdbarch_info *info)
Definition: arch-utils.c:725
ptid_t inferior_ptid
Definition: infcmd.c:94
void detach_inferior(int pid)
Definition: inferior.c:257
void table_body()
Definition: ui-out.c:379
const char * target_pid_to_str(ptid_t ptid)
Definition: target.c:2194
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition: cli-decode.c:569
bool deletable() const
Definition: inferior.h:317
void initialize_inferiors(void)
Definition: inferior.c:968
int gdb_inferior_id_to_pid(int num)
Definition: inferior.c:386
void message(const char *format,...) ATTRIBUTE_PRINTF(2
Definition: ui-out.c:587
struct inferior * add_inferior_with_spaces(void)
Definition: inferior.c:763
void exit_inferior_num_silent(int num)
Definition: inferior.c:249
struct inferior * find_inferior_id(int num)
Definition: inferior.c:290
struct cmd_list_element * showprintlist
Definition: cli-cmds.c:151
struct inferior * current_inferior(void)
Definition: inferior.c:58
struct program_space * current_program_space
Definition: progspace.c:35
void exit_inferior_silent(int pid)
Definition: inferior.c:241
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
Definition: corelow.c:879
static void add_inferior_command(const char *args, int from_tty)
Definition: inferior.c:793
char ** get()
Definition: utils.h:177
struct inferior * find_inferior_for_program_space(struct program_space *pspace)
Definition: inferior.c:329
char * args
Definition: inferior.h:352
argv
Definition: __init__.py:63
struct cmd_list_element * killlist
Definition: cli-cmds.c:107
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc)
Definition: cli-decode.c:902
static const char * inferior_pid_to_str(int pid)
Definition: inferior.c:501
struct internalvar * create_internalvar_type_lazy(const char *name, const struct internalvar_funcs *funcs, void *data)
Definition: value.c:2177
struct thread_info * any_thread_of_process(int pid)
Definition: thread.c:656
void error(const char *fmt,...)
Definition: errors.c:38
void set_current_inferior(struct inferior *inf)
Definition: inferior.c:64
void observer_notify_inferior_appeared(struct inferior *inf)
void inferior_appeared(struct inferior *inf, int pid)
Definition: inferior.c:268
static struct value * inferior_id_make_value(struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
Definition: inferior.c:948
static void exit_inferior_1(struct inferior *inftoex, int silent)
Definition: inferior.c:192
void observer_notify_inferior_exit(struct inferior *inf)
LONGEST parse_and_eval_long(const char *exp)
Definition: eval.c:111