Change inferior thread list to be a thread map
[deliverable/binutils-gdb.git] / gdb / inferior.c
index e7b49376e93dece2624e6ad1a363afce030da0f2..d268d031e2ca60dfd6276cebae747fd8d7296a10 100644 (file)
@@ -29,7 +29,7 @@
 #include "observable.h"
 #include "gdbcore.h"
 #include "symfile.h"
-#include "common/environ.h"
+#include "gdbsupport/environ.h"
 #include "cli/cli-utils.h"
 #include "continuations.h"
 #include "arch-utils.h"
@@ -46,7 +46,7 @@ struct inferior *inferior_list = NULL;
 static int highest_inferior_num;
 
 /* See inferior.h.  */
-int print_inferior_events = 1;
+bool print_inferior_events = true;
 
 /* The Current Inferior.  This is a strong reference.  I.e., whenever
    an inferior is the current inferior, its refcount is
@@ -148,8 +148,8 @@ delete_inferior (struct inferior *todel)
   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;
@@ -180,14 +180,16 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
   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;
@@ -208,6 +210,10 @@ exit_inferior_1 (struct inferior *inftoex, int silent)
   inf->pending_detach = 0;
   /* Reset it.  */
   inf->control = inferior_control_state (NO_STOP_QUIETLY);
+
+  /* Clear the register cache and the frame cache.  */
+  registers_changed ();
+  reinit_frame_cache ();
 }
 
 void
@@ -216,14 +222,6 @@ exit_inferior (inferior *inf)
   exit_inferior_1 (inf, 0);
 }
 
-void
-exit_inferior_silent (int pid)
-{
-  struct inferior *inf = find_inferior_pid (pid);
-
-  exit_inferior_1 (inf, 1);
-}
-
 void
 exit_inferior_silent (inferior *inf)
 {
@@ -374,24 +372,22 @@ have_live_inferiors (void)
 void
 prune_inferiors (void)
 {
-  struct inferior *ss, **ss_link;
+  inferior *ss;
 
   ss = inferior_list;
-  ss_link = &inferior_list;
   while (ss)
     {
       if (!ss->deletable ()
          || !ss->removable
          || ss->pid != 0)
        {
-         ss_link = &ss->next;
-         ss = *ss_link;
+         ss = ss->next;
          continue;
        }
 
-      *ss_link = ss->next;
+      inferior *ss_next = ss->next;
       delete_inferior (ss);
-      ss = *ss_link;
+      ss = ss_next;
     }
 }
 
@@ -477,7 +473,7 @@ print_inferior (struct ui_out *uiout, const char *requested_inferiors)
       else
        uiout->field_skip ("current");
 
-      uiout->field_int ("number", inf->num);
+      uiout->field_signed ("number", inf->num);
 
       uiout->field_string ("target-id", inferior_pid_to_str (inf->pid));
 
@@ -492,12 +488,12 @@ print_inferior (struct ui_out *uiout, const char *requested_inferiors)
       if (inf->vfork_parent)
        {
          uiout->text (_("\n\tis vfork child of inferior "));
-         uiout->field_int ("vfork-parent", inf->vfork_parent->num);
+         uiout->field_signed ("vfork-parent", inf->vfork_parent->num);
        }
       if (inf->vfork_child)
        {
          uiout->text (_("\n\tis vfork parent of inferior "));
-         uiout->field_int ("vfork-child", inf->vfork_child->num);
+         uiout->field_signed ("vfork-child", inf->vfork_child->num);
        }
 
       uiout->text ("\n");
@@ -596,7 +592,7 @@ inferior_command (const char *args, int from_tty)
     {
       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."));
 
This page took 0.025192 seconds and 4 git commands to generate.