if (!inf)
return;
- for (thread_info *tp : inf->threads_safe ())
- delete_thread_silent (tp);
+ for (thread_info *tp : inf->threads ())
+ delete_thread_silent_noremove (tp);
if (infprev)
infprev->next = inf->next;
if (!inf)
return;
- for (thread_info *tp : inf->threads_safe ())
+ for (thread_info *tp : inf->threads ())
{
if (silent)
- delete_thread_silent (tp);
+ delete_thread_silent_noremove (tp);
else
- delete_thread (tp);
+ delete_thread_noremove (tp);
}
+ inf->thread_map.clear ();
+
gdb::observers::inferior_exit.notify (inf);
inf->pid = 0;
gdb::observers::inferior_appeared.notify (inf);
}
-void
-discard_all_inferiors (void)
-{
- for (inferior *inf : all_non_exited_inferiors ())
- exit_inferior_silent (inf);
-}
-
struct inferior *
find_inferior_id (int num)
{
inf->num, inferior_pid_to_str (inf->pid).c_str (), filename);
}
+/* Helper for print_inferior. Returns the 'connection-id' string for
+ PROC_TARGET. */
+
+static std::string
+uiout_field_connection (process_stratum_target *proc_target)
+{
+ if (proc_target == NULL)
+ {
+ return {};
+ }
+ else if (proc_target->connection_string () != NULL)
+ {
+ return string_printf ("%d (%s %s)",
+ proc_target->connection_number,
+ proc_target->shortname (),
+ proc_target->connection_string ());
+ }
+ else
+ {
+ return string_printf ("%d (%s)",
+ proc_target->connection_number,
+ proc_target->shortname ());
+ }
+}
+
/* Prints the list of inferiors and their details on UIOUT. This is a
version of 'info_inferior_command' suitable for use from MI.
print_inferior (struct ui_out *uiout, const char *requested_inferiors)
{
int inf_count = 0;
+ size_t connection_id_len = 20;
/* Compute number of inferiors we will print. */
for (inferior *inf : all_inferiors ())
if (!number_is_in_list (requested_inferiors, inf->num))
continue;
+ std::string conn = uiout_field_connection (inf->process_target ());
+ if (connection_id_len < conn.size ())
+ connection_id_len = conn.size ();
+
++inf_count;
}
return;
}
- ui_out_emit_table table_emitter (uiout, 4, inf_count, "inferiors");
+ ui_out_emit_table table_emitter (uiout, 5, inf_count, "inferiors");
uiout->table_header (1, ui_left, "current", "");
uiout->table_header (4, ui_left, "number", "Num");
uiout->table_header (17, ui_left, "target-id", "Description");
+ uiout->table_header (connection_id_len, ui_left,
+ "connection-id", "Connection");
uiout->table_header (17, ui_left, "exec", "Executable");
uiout->table_body ();
+
+ /* Restore the current thread after the loop because we switch the
+ inferior in the loop. */
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
+ inferior *current_inf = current_inferior ();
for (inferior *inf : all_inferiors ())
{
if (!number_is_in_list (requested_inferiors, inf->num))
ui_out_emit_tuple tuple_emitter (uiout, NULL);
- if (inf == current_inferior ())
+ if (inf == current_inf)
uiout->field_string ("current", "*");
else
uiout->field_skip ("current");
uiout->field_signed ("number", inf->num);
+ /* Because target_pid_to_str uses current_top_target,
+ switch the inferior. */
+ switch_to_inferior_no_thread (inf);
+
uiout->field_string ("target-id", inferior_pid_to_str (inf->pid));
+ std::string conn = uiout_field_connection (inf->process_target ());
+ uiout->field_string ("connection-id", conn.c_str ());
+
if (inf->pspace->pspace_exec_filename != NULL)
uiout->field_string ("exec", inf->pspace->pspace_exec_filename);
else
{
if (inf != current_inferior ())
{
- thread_info *tp = any_thread_of_inferior (inf);
+ thread_info *tp = first_thread_of_inferior (inf);
if (tp == NULL)
error (_("Inferior has no threads."));
/* Reuse the target for new inferior. */
if (!no_connection && proc_target != NULL)
- push_target (proc_target);
-
- printf_filtered (_("Added inferior %d\n"), new_inf->num);
+ {
+ push_target (proc_target);
+ if (proc_target->connection_string () != NULL)
+ printf_filtered (_("Added inferior %d on connection %d (%s %s)\n"),
+ new_inf->num,
+ proc_target->connection_number,
+ proc_target->shortname (),
+ proc_target->connection_string ());
+ else
+ printf_filtered (_("Added inferior %d on connection %d (%s)\n"),
+ new_inf->num,
+ proc_target->connection_number,
+ proc_target->shortname ());
+ }
+ else
+ printf_filtered (_("Added inferior %d\n"), new_inf->num);
}
/* add-inferior [-copies N] [-exec FILENAME] [-no-connection] */