From patchwork Tue Jun 28 22:55:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Baldwin X-Patchwork-Id: 13457 Received: (qmail 97134 invoked by alias); 28 Jun 2016 22:57:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 97031 invoked by uid 89); 28 Jun 2016 22:57:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=HX-Greylist:0400, HX-Greylist:EDT, Hx-languages-length:1921 X-HELO: bigwig.baldwin.cx Received: from bigwig.baldwin.cx (HELO bigwig.baldwin.cx) (96.47.65.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 28 Jun 2016 22:56:50 +0000 Received: from ralph.com (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 90729B96C for ; Tue, 28 Jun 2016 18:56:48 -0400 (EDT) From: John Baldwin 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 15:55:07 -0700 Message-Id: <20160628225507.80772-3-jhb@FreeBSD.org> In-Reply-To: <20160628225507.80772-1-jhb@FreeBSD.org> References: <20160628225507.80772-1-jhb@FreeBSD.org> X-IsSubscribed: yes 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 + * 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 + * 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 to make sure `struct fxsave64' is defined on NetBSD, since NetBSD's 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