gdb: define convenience function 'exists_non_stop_target'
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Wed, 1 Apr 2020 19:33:05 +0000 (21:33 +0200)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Wed, 1 Apr 2020 19:33:05 +0000 (21:33 +0200)
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.

gdb/ChangeLog
gdb/target.c
gdb/target.h

index 65225a286a448c8003d06493a73609f9c0aa2b30..c7f4ac4f54f9e0f7cb06c1c656b1ce3ed47a8fd1 100644 (file)
@@ -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
index 1abd8ffbc74e7090b635f1626b66e43809bc6573..2dc356d935f90bc56cb0c4af8415fbf7fb8b977a 100644 (file)
@@ -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;
index 96e7210bfa0c212f2581ecdb2c692e0dec8d2739..9a1dd805af908fe42e5c5fa23f183b320a6308fe 100644 (file)
@@ -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 ())
 
This page took 0.031681 seconds and 4 git commands to generate.