Multi-target support
[deliverable/binutils-gdb.git] / gdb / exec.c
index 906ae616b0f79d0c2149a62960fe08be019f3904..468f9f57f76cceee2156f77887d58dcd0cb595fe 100644 (file)
@@ -547,10 +547,23 @@ add_target_sections (void *owner,
          table->sections[space + i].owner = owner;
        }
 
+      scoped_restore_current_thread restore_thread;
+      program_space *curr_pspace = current_program_space;
+
       /* If these are the first file sections we can provide memory
-        from, push the file_stratum target.  */
-      if (!target_is_pushed (&exec_ops))
-       push_target (&exec_ops);
+        from, push the file_stratum target.  Must do this in all
+        inferiors sharing the program space.  */
+      for (inferior *inf : all_inferiors ())
+       {
+         if (inf->pspace != curr_pspace)
+           continue;
+
+         if (inf->target_is_pushed (&exec_ops))
+           continue;
+
+         switch_to_inferior_no_thread (inf);
+         push_target (&exec_ops);
+       }
     }
 }
 
@@ -628,21 +641,39 @@ remove_target_sections (void *owner)
       old_count = resize_section_table (table, dest - src);
 
       /* If we don't have any more sections to read memory from,
-        remove the file_stratum target from the stack.  */
+        remove the file_stratum target from the stack of each
+        inferior sharing the program space.  */
       if (old_count + (dest - src) == 0)
        {
-         struct program_space *pspace;
+         scoped_restore_current_thread restore_thread;
+         program_space *curr_pspace = current_program_space;
+
+         for (inferior *inf : all_inferiors ())
+           {
+             if (inf->pspace != curr_pspace)
+               continue;
 
-         ALL_PSPACES (pspace)
-           if (pspace->target_sections.sections
-               != pspace->target_sections.sections_end)
-             return;
+             if (inf->pspace->target_sections.sections
+                 != inf->pspace->target_sections.sections_end)
+               continue;
 
-         unpush_target (&exec_ops);
+             switch_to_inferior_no_thread (inf);
+             unpush_target (&exec_ops);
+           }
        }
     }
 }
 
+/* See exec.h.  */
+
+void
+exec_on_vfork ()
+{
+  if (current_program_space->target_sections.sections
+      != current_program_space->target_sections.sections_end)
+    push_target (&exec_ops);
+}
+
 \f
 
 enum target_xfer_status
This page took 0.025283 seconds and 4 git commands to generate.