gdb: fix vfork with multiple threads
[deliverable/binutils-gdb.git] / gdb / inferior.c
index 69baee34ce9d25dd26eda5fc78feadc853708e67..e1c70d553fde27c9fe12c398c108d24e8ad9f5ca 100644 (file)
@@ -31,7 +31,6 @@
 #include "symfile.h"
 #include "gdbsupport/environ.h"
 #include "cli/cli-utils.h"
-#include "continuations.h"
 #include "arch-utils.h"
 #include "target-descriptions.h"
 #include "readline/tilde.h"
@@ -74,9 +73,8 @@ inferior::~inferior ()
 {
   inferior *inf = this;
 
-  discard_all_inferior_continuations (inf);
+  m_continuations.clear ();
   inferior_free_data (inf);
-  xfree (inf->args);
   target_desc_info_free (inf->tdesc_info);
 }
 
@@ -106,6 +104,23 @@ inferior::tty ()
   return m_terminal.get ();
 }
 
+void
+inferior::add_continuation (std::function<void ()> &&cont)
+{
+  m_continuations.emplace_front (std::move (cont));
+}
+
+void
+inferior::do_all_continuations ()
+{
+  while (!m_continuations.empty ())
+    {
+      auto iter = m_continuations.begin ();
+      (*iter) ();
+      m_continuations.erase (iter);
+    }
+}
+
 struct inferior *
 add_inferior_silent (int pid)
 {
@@ -507,14 +522,14 @@ print_inferior (struct ui_out *uiout, const char *requested_inferiors)
 
       uiout->field_signed ("number", inf->num);
 
-      /* Because target_pid_to_str uses current_top_target,
+      /* Because target_pid_to_str uses the current inferior,
         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 ());
+      uiout->field_string ("connection-id", conn);
 
       if (inf->pspace->exec_filename != nullptr)
        uiout->field_string ("exec", inf->pspace->exec_filename.get ());
@@ -732,7 +747,6 @@ add_inferior_with_spaces (void)
   struct address_space *aspace;
   struct program_space *pspace;
   struct inferior *inf;
-  struct gdbarch_info info;
 
   /* If all inferiors share an address space on this system, this
      doesn't really return a new address space; otherwise, it
@@ -745,7 +759,7 @@ add_inferior_with_spaces (void)
 
   /* Setup the inferior's initial arch, based on information obtained
      from the global "set ..." options.  */
-  gdbarch_info_init (&info);
+  gdbarch_info info;
   inf->gdbarch = gdbarch_find_by_info (info);
   /* The "set ..." options reject invalid settings, so we should
      always have a valid arch by now.  */
This page took 0.024885 seconds and 4 git commands to generate.