From: Lancelot SIX <lancelot.six@amd.com>
To: <gdb-patches@sourceware.org>
Cc: <lsix@lancelotsix.com>, Lancelot SIX <lancelot.six@amd.com>
Subject: [PATCH v6 1/3] gdb: add inferior parameter to target_is_non_stop_p
Date: Wed, 22 Mar 2023 16:35:02 +0000 [thread overview]
Message-ID: <20230322163504.560986-2-lancelot.six@amd.com> (raw)
In-Reply-To: <20230322163504.560986-1-lancelot.six@amd.com>
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(-)
diff --git a/gdb/target.c b/gdb/target.c
index 0cebecfafc3..5e5d1054541 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -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
diff --git a/gdb/target.h b/gdb/target.h
index 2dac86c394d..ffa6d95becd 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -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 ();
--
2.34.1
next prev parent reply other threads:[~2023-03-22 16:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 16:51 [PATCH v5] gdb/gcore: interrupt all threads before generating the corefile Lancelot SIX
2023-02-10 14:36 ` [PING] " Lancelot SIX
2023-02-10 21:46 ` Simon Marchi
2023-03-22 16:35 ` [PATCH v6 0/3] interrupt all threads to generate core in non-stop targets Lancelot SIX
2023-03-22 16:35 ` Lancelot SIX [this message]
2023-03-22 16:35 ` [PATCH v6 2/3] gdb/infrun: Improve assertion in stop_all_threads Lancelot SIX
2023-03-22 16:35 ` [PATCH v6 3/3] gdb/gcore: interrupt all threads to generate core in non-stop targets Lancelot SIX
2023-03-22 16:44 ` Eli Zaretskii
2023-03-22 16:59 ` Lancelot SIX
2023-05-10 18:46 ` Lancelot SIX
2023-05-10 19:05 ` Eli Zaretskii
2023-05-10 19:08 ` Lancelot SIX
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=20230322163504.560986-2-lancelot.six@amd.com \
--to=lancelot.six@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.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).