public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: define convenience function 'exists_non_stop_target'
@ 2020-04-01 19:34 Tankut Baris Aktemur
  0 siblings, 0 replies; only message in thread
From: Tankut Baris Aktemur @ 2020-04-01 19:34 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a0714d305fb78b3a2a74a2acd6d8c66da80a6387

commit a0714d305fb78b3a2a74a2acd6d8c66da80a6387
Author: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Date:   Wed Apr 1 21:33:05 2020 +0200

    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-04-01  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.

Diff:
---
 gdb/ChangeLog |  5 +++++
 gdb/target.c  | 20 ++++++++++++++++++++
 gdb/target.h  |  3 +++
 3 files changed, 28 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 65225a286a4..c7f4ac4f54f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-04-01  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.
+
 2020-04-01  Hannes Domani  <ssbssa@yahoo.de>
 
 	PR gdb/24789
diff --git a/gdb/target.c b/gdb/target.c
index 1abd8ffbc74..2dc356d935f 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3931,6 +3931,26 @@ target_is_non_stop_p (void)
 	      && 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 96e7210bfa0..9a1dd805af9 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1857,6 +1857,9 @@ extern enum auto_boolean target_non_stop_enabled;
    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 ())


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-01 19:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 19:34 [binutils-gdb] gdb: define convenience function 'exists_non_stop_target' Tankut Baris Aktemur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).