#include "progspace-and-thread.h"
#include "gdbsupport/buildargv.h"
#include "cli/cli-style.h"
+#include "interps.h"
intrusive_list<inferior> inferior_list;
static int highest_inferior_num;
}
}
+/* Notify interpreters and observers that inferior INF was added. */
+
+static void
+notify_inferior_added (inferior *inf)
+{
+ interps_notify_inferior_added (inf);
+ gdb::observers::inferior_added.notify (inf);
+}
+
struct inferior *
add_inferior_silent (int pid)
{
inferior_list.push_back (*inf);
- gdb::observers::inferior_added.notify (inf);
+ notify_inferior_added (inf);
if (pid != 0)
inferior_appeared (inf, pid);
/* See inferior.h. */
void
-inferior::clear_thread_list (bool silent)
+inferior::clear_thread_list ()
{
thread_list.clear_and_dispose ([=] (thread_info *thr)
{
- threads_debug_printf ("deleting thread %s, silent = %d",
- thr->ptid.to_string ().c_str (), silent);
- set_thread_exited (thr, silent);
+ threads_debug_printf ("deleting thread %s",
+ thr->ptid.to_string ().c_str ());
+ set_thread_exited (thr, {}, true /* silent */);
if (thr->deletable ())
delete thr;
});
ptid_thread_map.clear ();
}
+/* Notify interpreters and observers that inferior INF was removed. */
+
+static void
+notify_inferior_removed (inferior *inf)
+{
+ interps_notify_inferior_removed (inf);
+ gdb::observers::inferior_removed.notify (inf);
+}
+
void
delete_inferior (struct inferior *inf)
{
- inf->clear_thread_list (true);
+ inf->clear_thread_list ();
auto it = inferior_list.iterator_to (*inf);
inferior_list.erase (it);
- gdb::observers::inferior_removed.notify (inf);
+ notify_inferior_removed (inf);
/* Pop all targets now, this ensures that inferior::unpush is called
correctly. As pop_all_targets ends up making a temporary switch to
delete inf;
}
-/* If SILENT then be quiet -- don't announce a inferior exit, or the
- exit of its threads. */
+/* Notify interpreters and observers that inferior INF disappeared. */
static void
-exit_inferior_1 (struct inferior *inf, int silent)
+notify_inferior_disappeared (inferior *inf)
{
- inf->clear_thread_list (silent);
-
+ interps_notify_inferior_disappeared (inf);
gdb::observers::inferior_exit.notify (inf);
+}
+
+/* See inferior.h. */
+
+void
+exit_inferior (struct inferior *inf)
+{
+ inf->clear_thread_list ();
+
+ notify_inferior_disappeared (inf);
inf->pid = 0;
inf->fake_pid_p = false;
reinit_frame_cache ();
}
-void
-exit_inferior (inferior *inf)
-{
- exit_inferior_1 (inf, 0);
-}
-
-void
-exit_inferior_silent (inferior *inf)
-{
- exit_inferior_1 (inf, 1);
-}
-
/* See inferior.h. */
void
detach_inferior (inferior *inf)
{
- /* Save the pid, since exit_inferior_1 will reset it. */
+ /* Save the pid, since exit_inferior will reset it. */
int pid = inf->pid;
- exit_inferior_1 (inf, 0);
+ exit_inferior (inf);
if (print_inferior_events)
gdb_printf (_("[Inferior %d (%s) detached]\n"),
target_pid_to_str (ptid_t (pid)).c_str ());
}
+/* Notify interpreters and observers that inferior INF appeared. */
+
+static void
+notify_inferior_appeared (inferior *inf)
+{
+ interps_notify_inferior_appeared (inf);
+ gdb::observers::inferior_appeared.notify (inf);
+}
+
void
inferior_appeared (struct inferior *inf, int pid)
{
inf->has_exit_code = false;
inf->exit_code = 0;
- gdb::observers::inferior_appeared.notify (inf);
+ notify_inferior_appeared (inf);
}
struct inferior *