[PATCH] gdb: Fix missing first breakpoint in schedule-multiple mode

Ciaran Woodward ciaranwoodward@xmos.com
Mon Jul 25 16:22:31 GMT 2022


Rationale/background:
When using schedule-multiple (sched_multi) in gdb, all inferiors
are set to continue when the c command is used. However, before
this patch, only the 'current' inferior would have its
control->stop_soon field cleared. This field causes certain stops
to be ignored, and is only intended for initial attach.

By not clearing this field before continue, continuing with inferior 2
in focus and with inferior 1 hitting the next breakpoint, would cause
gdb to ignore the breakpoint and any attempt to stop the target with
Ctrl-C following that - even though the target was already stopped.
The only fix was to quit GDB and restart.

Solution:
With this patch, all inferiors being resumed have their
control->stop_soon fields cleared, so gdb does not ignore the
breakpoints of any inferior inadvertently.
---
 gdb/infrun.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 543cccc5311..894157ed1d1 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2808,18 +2808,18 @@ clear_proceed_status (int step)
 	 we're about to resume, implicitly and explicitly.  */
       for (thread_info *tp : all_non_exited_threads (resume_target, resume_ptid))
 	clear_proceed_status_thread (tp);
+
+      for(struct inferior* inferior : all_non_exited_inferiors(resume_target))
+        inferior->control.stop_soon = NO_STOP_QUIETLY;
     }
 
-  if (inferior_ptid != null_ptid)
+  if (non_stop && inferior_ptid != null_ptid)
     {
       struct inferior *inferior;
 
-      if (non_stop)
-	{
-	  /* If in non-stop mode, only delete the per-thread status of
-	     the current thread.  */
-	  clear_proceed_status_thread (inferior_thread ());
-	}
+      /* If in non-stop mode, only delete the per-thread status of
+         the current thread.  */
+      clear_proceed_status_thread (inferior_thread ());
 
       inferior = current_inferior ();
       inferior->control.stop_soon = NO_STOP_QUIETLY;
-- 
2.25.1



More information about the Gdb-patches mailing list