[v6,1/3] gdb: add inferior parameter to target_is_non_stop_p
Commit Message
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(-)
@@ -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
@@ -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 ();