From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org
Cc: palves@redhat.com
Subject: [PATCH v3 1/5] thread: add can_access_registers_ptid
Date: Mon, 30 Jan 2017 10:06:00 -0000 [thread overview]
Message-ID: <1485770743-6603-2-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1485770743-6603-1-git-send-email-markus.t.metzger@intel.com>
Add a function can_access_registers_ptid that behaves like
validate_registers_access but returns a boolean value instead of throwing an
exception.
2017-01-30 Markus Metzger <markus.t.metzger@intel.com>
* gdbthread.h (can_access_registers_ptid): New.
* thread.c (can_access_registers_ptid): New.
---
gdb/gdbthread.h | 4 ++++
gdb/thread.c | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 455cfd8..06ed78f 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -625,6 +625,10 @@ extern void thread_cancel_execution_command (struct thread_info *thr);
executing). */
extern void validate_registers_access (void);
+/* Check whether it makes sense to access a register of PTID at this point.
+ Returns true if registers may be accessed; false otherwise. */
+extern bool can_access_registers_ptid (ptid_t ptid);
+
/* Returns whether to show which thread hit the breakpoint, received a
signal, etc. and ended up causing a user-visible stop. This is
true iff we ever detected multiple threads. */
diff --git a/gdb/thread.c b/gdb/thread.c
index e45b257..99fe424 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1141,6 +1141,26 @@ validate_registers_access (void)
error (_("Selected thread is running."));
}
+/* See gdbthread.h. */
+
+bool
+can_access_registers_ptid (ptid_t ptid)
+{
+ /* No thread, no registers. */
+ if (ptid_equal (ptid, null_ptid))
+ return false;
+
+ /* Don't try to read from a dead thread. */
+ if (is_exited (ptid))
+ return false;
+
+ /* ... or from a spinning thread. FIXME: see validate_registers_access. */
+ if (is_executing (ptid))
+ return false;
+
+ return true;
+}
+
int
pc_in_thread_step_range (CORE_ADDR pc, struct thread_info *thread)
{
--
1.8.3.1
next prev parent reply other threads:[~2017-01-30 10:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-30 10:05 [PATCH v3 0/5] thread, btrace: allow "record btrace" for running threads Markus Metzger
2017-01-30 10:05 ` [PATCH v3 4/5] btrace, testsuite: fix extended-remote non-stop test Markus Metzger
2017-01-31 13:00 ` Pedro Alves
2017-01-30 10:06 ` [PATCH v3 5/5] btrace, testsuite: fix extended-remote fail Markus Metzger
2017-01-31 13:00 ` Pedro Alves
2017-01-31 16:06 ` Metzger, Markus T
2017-01-31 16:42 ` Pedro Alves
2017-01-30 10:06 ` Markus Metzger [this message]
2017-01-30 10:06 ` [PATCH v3 3/5] btrace: add unsupported/untested messages when skipping tests Markus Metzger
2017-01-31 13:00 ` Pedro Alves
2017-01-30 10:06 ` [PATCH v3 2/5] btrace: allow recording to be started (and stopped) for running threads Markus Metzger
2017-01-31 12:59 ` Pedro Alves
2017-01-31 16:06 ` Metzger, Markus T
2017-01-31 16:36 ` Pedro Alves
2017-02-01 8:53 ` Metzger, Markus T
2017-02-01 9:08 ` Metzger, Markus T
2017-02-01 10:40 ` Pedro Alves
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=1485770743-6603-2-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@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