gdb/mi: remove warning about mi1
[binutils-gdb.git] / gdb / inferior.c
index 8962b6401e3498033f1865841dd7bb420b6c2320..ce4960a508aa2ce79afa85d3bbc15768717f6d75 100644 (file)
@@ -38,6 +38,7 @@
 #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;
@@ -189,6 +190,15 @@ inferior::do_all_continuations ()
     }
 }
 
+/* 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)
 {
@@ -196,7 +206,7 @@ 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);
@@ -237,28 +247,37 @@ inferior::find_thread (ptid_t ptid)
 /* 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
@@ -273,15 +292,23 @@ delete_inferior (struct inferior *inf)
   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;
@@ -307,27 +334,15 @@ exit_inferior_1 (struct inferior *inf, int silent)
   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"),
@@ -335,6 +350,15 @@ detach_inferior (inferior *inf)
                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)
 {
@@ -348,7 +372,7 @@ 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 *