diff mbox

[review] gdb: define convenience function 'exists_non_stop_target'

Message ID gerrit.1580903669000.Ia4db9e33f5cd2d15134d194dadee19ca6853b2d8@gnutoolchain-gerrit.osci.io
State New
Headers show

Commit Message

Simon Marchi (Code Review) Feb. 5, 2020, 11:54 a.m. UTC
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/765
......................................................................

gdb: define convenience function 'exists_non_stop_target'

Define a predicate function that returns true if there exists an
inferior with a non-stop target.

gdb/ChangeLog:
2020-02-05  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* target.h (exists_non_stop_target): New function declaration.
	* target.c (exists_non_stop_target): New function.

Change-Id: Ia4db9e33f5cd2d15134d194dadee19ca6853b2d8
---
M gdb/target.c
M gdb/target.h
2 files changed, 23 insertions(+), 0 deletions(-)

Comments

Simon Marchi (Code Review) Feb. 6, 2020, 7:52 a.m. UTC | #1
Tankut Baris Aktemur has abandoned this change. ( https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/765 )

Change subject: gdb: define convenience function 'exists_non_stop_target'
......................................................................


Abandoned

Will use send-email.
diff mbox

Patch

diff --git a/gdb/target.c b/gdb/target.c
index 470ef51..a332521 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3934,6 +3934,26 @@ 
 	      && target_always_non_stop_p ()));
 }
 
+/* See target.h.  */
+
+bool
+exists_non_stop_target ()
+{
+  if (target_is_non_stop_p ())
+    return true;
+
+  scoped_restore_current_thread restore_thread;
+
+  for (inferior *inf : all_inferiors ())
+    {
+      switch_to_inferior_no_thread (inf);
+      if (target_is_non_stop_p ())
+	return true;
+    }
+
+  return false;
+}
+
 /* Controls if targets can report that they always run in non-stop
    mode.  This is just for maintainers to use when debugging gdb.  */
 enum auto_boolean target_non_stop_enabled = AUTO_BOOLEAN_AUTO;
diff --git a/gdb/target.h b/gdb/target.h
index 26b71cf..40ca5ca 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1857,6 +1857,9 @@ 
    non-stop" is on.  */
 extern int target_is_non_stop_p (void);
 
+/* Return true if at least one inferior has a non-stop target.  */
+extern bool exists_non_stop_target ();
+
 #define target_execution_direction() \
   (current_top_target ()->execution_direction ())