public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
To: gdb-patches@sourceware.org
Cc: palves@redhat.com
Subject: [PATCH 1/2] gdb: define convenience function 'exists_non_stop_target'
Date: Thu, 06 Feb 2020 08:30:00 -0000	[thread overview]
Message-ID: <1580977799-4371-2-git-send-email-tankut.baris.aktemur@intel.com> (raw)
In-Reply-To: <1580977799-4371-1-git-send-email-tankut.baris.aktemur@intel.com>

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.
---
 gdb/target.c | 20 ++++++++++++++++++++
 gdb/target.h |  3 +++
 2 files changed, 23 insertions(+)

diff --git a/gdb/target.c b/gdb/target.c
index 470ef51d69e..a332521af3b 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3934,6 +3934,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 26b71cfeb09..40ca5cac8b1 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 ())
 
-- 
2.17.1

  parent reply	other threads:[~2020-02-06  8:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06  8:30 [PATCH 0/2] All threads not stopped when a process exits Tankut Baris Aktemur
2020-02-06  8:30 ` [PATCH 2/2] gdb/infrun: stop all threads if there exists a non-stop target Tankut Baris Aktemur
2020-04-01 18:10   ` Pedro Alves
2020-04-01 19:35     ` Aktemur, Tankut Baris
2020-02-06  8:30 ` Tankut Baris Aktemur [this message]
2020-03-03  8:35 ` [PING][PATCH 0/2] All threads not stopped when a process exits Tankut Baris Aktemur
2020-03-17 13:02 ` [PING^2][PATCH " Tankut Baris Aktemur
2020-04-01 13:34 ` [PING^3][PATCH " Tankut Baris Aktemur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1580977799-4371-2-git-send-email-tankut.baris.aktemur@intel.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).