[v6,1/3] gdb: add inferior parameter to target_is_non_stop_p

Message ID 20230322163504.560986-2-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
  This patch add a "inferior *inf" parameter to the target_is_non_stop_p
function.  The default value is nullptr so all existing calls remain
valid.

This will be used in the following patch.
---
 gdb/target.c | 9 ++++++++-
 gdb/target.h | 8 +++++---
 2 files changed, 13 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gdb/target.c b/gdb/target.c
index 0cebecfafc3..5e5d1054541 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -4391,8 +4391,15 @@  target_always_non_stop_p (void)
 /* See target.h.  */
 
 bool
-target_is_non_stop_p ()
+target_is_non_stop_p (inferior *inf)
 {
+  gdb::optional<scoped_restore_current_thread> restore_thread;
+  if (inf != nullptr && inf != current_inferior ())
+    {
+      restore_thread.emplace ();
+      switch_to_inferior_no_thread (inf);
+    }
+
   return ((non_stop
 	   || target_non_stop_enabled == AUTO_BOOLEAN_TRUE
 	   || (target_non_stop_enabled == AUTO_BOOLEAN_AUTO
diff --git a/gdb/target.h b/gdb/target.h
index 2dac86c394d..ffa6d95becd 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1892,10 +1892,12 @@  extern void target_thread_events (int enable);
    non-stop mode is enabled.  */
 extern enum auto_boolean target_non_stop_enabled;
 
-/* Is the target in non-stop mode?  Some targets control the inferior
+/* Is INF's target in non-stop mode?  Some targets control the inferior
    in non-stop mode even with "set non-stop off".  Always true if "set
-   non-stop" is on.  */
-extern bool target_is_non_stop_p ();
+   non-stop" is on.
+
+   If INF is nullptr, check the current inferior.  */
+extern bool target_is_non_stop_p (inferior *inf = nullptr);
 
 /* Return true if at least one inferior has a non-stop target.  */
 extern bool exists_non_stop_target ();