gdb/infrun: enable/disable thread events of all targets in stop_all_threads
[deliverable/binutils-gdb.git] / gdb / infrun.c
index c5bf2d0ad741b7c6ea5da06daf3cfa391a44db12..2a8e73c1111ced78f9dd74a80d83af45a0ad05b6 100644 (file)
@@ -4769,8 +4769,25 @@ stop_all_threads (void)
 
   scoped_restore_current_thread restore_thread;
 
-  target_thread_events (1);
-  SCOPE_EXIT { target_thread_events (0); };
+  /* Enable thread events of all targets.  */
+  for (auto *target : all_non_exited_process_targets ())
+    {
+      switch_to_target_no_thread (target);
+      target_thread_events (true);
+    }
+
+  SCOPE_EXIT
+    {
+      /* Disable thread events of all targets.  */
+      for (auto *target : all_non_exited_process_targets ())
+       {
+         switch_to_target_no_thread (target);
+         target_thread_events (false);
+       }
+
+      if (debug_infrun)
+       fprintf_unfiltered (gdb_stdlog, "infrun: stop_all_threads done\n");
+    };
 
   /* Request threads to stop, and then wait for the stops.  Because
      threads we already know about can spawn more threads while we're
@@ -4961,9 +4978,6 @@ stop_all_threads (void)
            }
        }
     }
-
-  if (debug_infrun)
-    fprintf_unfiltered (gdb_stdlog, "infrun: stop_all_threads done\n");
 }
 
 /* Handle a TARGET_WAITKIND_NO_RESUMED event.  */
This page took 0.024658 seconds and 4 git commands to generate.