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;
inf->fake_pid_p = 0;
+ xfree (inf->priv);
+ inf->priv = NULL;
+
if (inf->vfork_parent != NULL)
{
inf->vfork_parent->vfork_child = NULL;
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;
}
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);
switch_to_thread (null_ptid);
exec_file_attach (exec, from_tty);
- symbol_file_add_main (exec, from_tty);
+ symbol_file_add_main (exec, add_flags);
}
}