iterate_over_threads (delete_thread_of_inferior, &arg);
- /* 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);
inf->pid = 0;
return _("<null>");
}
+/* See inferior.h. */
+
+void
+print_selected_inferior (struct ui_out *uiout)
+{
+ char buf[PATH_MAX + 256];
+ struct inferior *inf = current_inferior ();
+
+ xsnprintf (buf, sizeof (buf),
+ _("[Switching to inferior %d [%s] (%s)]\n"),
+ inf->num,
+ inferior_pid_to_str (inf->pid),
+ (inf->pspace->pspace_exec_filename != NULL
+ ? inf->pspace->pspace_exec_filename
+ : _("<noexec>")));
+ ui_out_text (uiout, buf);
+}
+
/* Prints the list of inferiors and their details on UIOUT. This is a
version of 'info_inferior_command' suitable for use from MI.
static void
detach_inferior_command (char *args, int from_tty)
{
- int num, pid;
struct thread_info *tp;
- struct get_number_or_range_state state;
if (!args || !*args)
error (_("Requires argument (inferior id(s) to detach)"));
- init_number_or_range (&state, args);
- while (!state.finished)
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
{
- num = get_number_or_range (&state);
+ int num = parser.get_number ();
if (!valid_gdb_inferior_id (num))
{
continue;
}
- pid = gdb_inferior_id_to_pid (num);
+ int pid = gdb_inferior_id_to_pid (num);
if (pid == 0)
{
warning (_("Inferior ID %d is not running."), num);
static void
kill_inferior_command (char *args, int from_tty)
{
- int num, pid;
struct thread_info *tp;
- struct get_number_or_range_state state;
if (!args || !*args)
error (_("Requires argument (inferior id(s) to kill)"));
- init_number_or_range (&state, args);
- while (!state.finished)
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
{
- num = get_number_or_range (&state);
+ int num = parser.get_number ();
if (!valid_gdb_inferior_id (num))
{
continue;
}
- pid = gdb_inferior_id_to_pid (num);
+ int pid = gdb_inferior_id_to_pid (num);
if (pid == 0)
{
warning (_("Inferior ID %d is not running."), num);
if (inf == NULL)
error (_("Inferior ID %d not known."), num);
- printf_filtered (_("[Switching to inferior %d [%s] (%s)]\n"),
- inf->num,
- inferior_pid_to_str (inf->pid),
- (inf->pspace->pspace_exec_filename != NULL
- ? inf->pspace->pspace_exec_filename
- : _("<noexec>")));
-
if (inf->pid != 0)
{
if (inf->pid != ptid_get_pid (inferior_ptid))
switch_to_thread (tp->ptid);
}
- printf_filtered (_("[Switching to thread %d (%s)] "),
- pid_to_thread_id (inferior_ptid),
- target_pid_to_str (inferior_ptid));
+ observer_notify_user_selected_context_changed
+ (USER_SELECTED_INFERIOR
+ | USER_SELECTED_THREAD
+ | USER_SELECTED_FRAME);
}
else
{
set_current_inferior (inf);
switch_to_thread (null_ptid);
set_current_program_space (inf->pspace);
- }
- if (inf->pid != 0 && is_running (inferior_ptid))
- ui_out_text (current_uiout, "(running)\n");
- else if (inf->pid != 0)
- {
- ui_out_text (current_uiout, "\n");
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
+ observer_notify_user_selected_context_changed (USER_SELECTED_INFERIOR);
}
}
static void
remove_inferior_command (char *args, int from_tty)
{
- int num;
- struct inferior *inf;
- struct get_number_or_range_state state;
-
if (args == NULL || *args == '\0')
error (_("Requires an argument (inferior id(s) to remove)"));
- init_number_or_range (&state, args);
- while (!state.finished)
+ number_or_range_parser parser (args);
+ while (!parser.finished ())
{
- num = get_number_or_range (&state);
- inf = find_inferior_id (num);
+ int num = parser.get_number ();
+ struct inferior *inf = find_inferior_id (num);
if (inf == NULL)
{
if (inf == current_inferior ())
{
- warning (_("Can not remove current symbol inferior %d."), num);
+ warning (_("Can not remove current inferior %d."), num);
continue;
}
fprintf_filtered (file, _("Printing of inferior events is %s.\n"), value);
}
+/* Return a new value for the selected inferior's id. */
+
+static struct value *
+inferior_id_make_value (struct gdbarch *gdbarch, struct internalvar *var,
+ void *ignore)
+{
+ struct inferior *inf = current_inferior ();
+
+ return value_from_longest (builtin_type (gdbarch)->builtin_int, inf->num);
+}
+
+/* Implementation of `$_inferior' variable. */
+
+static const struct internalvar_funcs inferior_funcs =
+{
+ inferior_id_make_value,
+ NULL,
+ NULL
+};
+
\f
void
show_print_inferior_events,
&setprintlist, &showprintlist);
+ create_internalvar_type_lazy ("_inferior", &inferior_funcs, NULL);
}