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

Lancelot SIX via Gdb-patches
2023-03-22T16:35:52Z

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(-)

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);
--
2.34.1