From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] Set debug registers on all threads belonging to the current inferior.
Date: Tue, 28 Jun 2016 22:57:00 -0000 [thread overview]
Message-ID: <20160628225507.80772-3-jhb@FreeBSD.org> (raw)
In-Reply-To: <20160628225507.80772-1-jhb@FreeBSD.org>
gdb/ChangeLog:
* x86bsd-nat.c: Include 'gdbthread.h'.
(x86bsd_dr_set): Set debug registers on all threads belonging to
the current inferior.
---
gdb/ChangeLog | 6 ++++++
gdb/x86bsd-nat.c | 12 +++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 50c441f..0d9a68b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2016-06-27 John Baldwin <jhb@FreeBSD.org>
+ * x86bsd-nat.c: Include 'gdbthread.h'.
+ (x86bsd_dr_set): Set debug registers on all threads belonging to
+ the current inferior.
+
+2016-06-27 John Baldwin <jhb@FreeBSD.org>
+
* Makefile.in [HFILES_NO_SRCDIR]: Replace 'amd64bsd-nat.h' with
'x86bsd-nat.h'.
* amd64bsd-nat.c: Include 'x86bsd-nat.h' instead of
diff --git a/gdb/x86bsd-nat.c b/gdb/x86bsd-nat.c
index 0c56848..7703ed5 100644
--- a/gdb/x86bsd-nat.c
+++ b/gdb/x86bsd-nat.c
@@ -19,6 +19,7 @@
#include "defs.h"
#include "inferior.h"
+#include "gdbthread.h"
/* We include <signal.h> to make sure `struct fxsave64' is defined on
NetBSD, since NetBSD's <machine/reg.h> needs it. */
@@ -71,6 +72,7 @@ x86bsd_dr_get (ptid_t ptid, int regnum)
static void
x86bsd_dr_set (int regnum, unsigned long value)
{
+ struct thread_info *thread;
struct dbreg dbregs;
if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
@@ -84,9 +86,13 @@ x86bsd_dr_set (int regnum, unsigned long value)
DBREG_DRX ((&dbregs), regnum) = value;
- if (ptrace (PT_SETDBREGS, get_ptrace_pid (inferior_ptid),
- (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
- perror_with_name (_("Couldn't write debug registers"));
+ ALL_NON_EXITED_THREADS(thread)
+ if (thread->inf == current_inferior ())
+ {
+ if (ptrace (PT_SETDBREGS, get_ptrace_pid (thread->ptid),
+ (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+ perror_with_name (_("Couldn't write debug registers"));
+ }
}
static void
--
2.8.4
next prev parent reply other threads:[~2016-06-28 22:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 22:57 [PATCH 0/2] Fix x86 debug registers on FreeBSD with threads John Baldwin
2016-06-28 22:57 ` [PATCH 1/2] Consolidate x86 debug register code for BSD native targets John Baldwin
2016-06-28 22:57 ` John Baldwin [this message]
2016-07-01 13:02 ` [PATCH 0/2] Fix x86 debug registers on FreeBSD with threads Pedro Alves
2016-07-01 14:58 ` John Baldwin
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=20160628225507.80772-3-jhb@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
/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