[v6,2/3] gdb/infrun: Improve assertion in stop_all_threads

Message ID 20230322163504.560986-3-lancelot.six@amd.com
State New
Headers
Series interrupt all threads to generate core in non-stop targets |

Commit Message

Lancelot SIX March 22, 2023, 4:35 p.m. UTC
  The stop_all_threads function has an assertion to check that there is a
non-stop target.  However, when called with a non-NULL INF parameter, we
only need INF's target to be non-stop.

This patch updates the assertion.  If INF is non-NULL, check that INF's
target is non-stop, otherwise keep the assertion as before.
---
 gdb/infrun.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 5c9babb9104..a509e0d5bef 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5189,7 +5189,10 @@  stop_all_threads (const char *reason, inferior *inf)
   int pass;
   int iterations = 0;
 
-  gdb_assert (exists_non_stop_target ());
+  if (inf == nullptr)
+    gdb_assert (exists_non_stop_target ());
+  else
+    gdb_assert (target_is_non_stop_p (inf));
 
   INFRUN_SCOPED_DEBUG_START_END ("reason=%s, inf=%d", reason,
 				 inf != nullptr ? inf->num : -1);