Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org,	coypu@sdf.org
Subject: [PATCH v2 2/2] Enable support for x86 debug registers on NetBSD.
Date: Tue, 25 Jul 2017 16:51:00 -0000	[thread overview]
Message-ID: <20170725165051.9132-3-jhb@FreeBSD.org> (raw)
In-Reply-To: <20170725165051.9132-1-jhb@FreeBSD.org>

NetBSD recently added PT_GETDBREGS and PT_SETDBREGS ptrace operations
that match the existing ones supported by x86-bsd-nat.c.  NetBSD's
headers do not provide the DBREG_DRX helper macro, so define a local
version in x86-bsd-nat.c.  In addition, add the x86-nat.o and x86-dregs.o
object files to the native NetBSD x86 build targets.

gdb/ChangeLog:

	* configure.nat: Add "x86-nat.o x86-dregs.o" for NetBSD/amd64 and
	NetBSD/i386.
	* x86-bsd-nat.c [!DBREG_DRX && __NetBSD__]: Define DBREG_DRX.
---
 gdb/ChangeLog     | 6 ++++++
 gdb/configure.nat | 8 ++++----
 gdb/x86-bsd-nat.c | 9 +++++++--
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e06712d645..e24698ae30 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2017-07-25  John Baldwin  <jhb@FreeBSD.org>
 
+	* configure.nat: Add "x86-nat.o x86-dregs.o" for NetBSD/amd64 and
+	NetBSD/i386.
+	* x86-bsd-nat.c [!DBREG_DRX && __NetBSD__]: Define DBREG_DRX.
+
+2017-07-25  John Baldwin  <jhb@FreeBSD.org>
+
 	* bsd-kvm.o: Define _KMEMUSER.
 	* configure.ac: Define _KMEMUSER when checking for "struct lwp".
 	* configure: Regenerate.
diff --git a/gdb/configure.nat b/gdb/configure.nat
index b32c9aa849..b1dda30852 100644
--- a/gdb/configure.nat
+++ b/gdb/configure.nat
@@ -338,8 +338,8 @@ case ${gdb_host} in
 	case ${gdb_host_cpu} in
 	    i386)
 		# Host: NetBSD/amd64
-		NATDEPFILES="${NATDEPFILES} nbsd-nat.o amd64-nat.o \
-		x86-bsd-nat.o amd64-bsd-nat.o amd64-nbsd-nat.o"
+		NATDEPFILES="${NATDEPFILES} nbsd-nat.o amd64-nat.o x86-nat.o \
+		x86-dregs.o x86-bsd-nat.o amd64-bsd-nat.o amd64-nbsd-nat.o"
 		;;
 	    sparc)
 		# Host: NetBSD/sparc64
@@ -358,8 +358,8 @@ case ${gdb_host} in
 		;;
 	    i386)
 		# Host: NetBSD/i386 ELF
-		NATDEPFILES="${NATDEPFILES} nbsd-nat.o x86-bsd-nat.o \
-		i386-bsd-nat.o i386-nbsd-nat.o bsd-kvm.o"
+		NATDEPFILES="${NATDEPFILES} nbsd-nat.o x86-nat.o x86-dregs.o \
+		x86-bsd-nat.o i386-bsd-nat.o i386-nbsd-nat.o bsd-kvm.o"
 		LOADLIBES='-lkvm'
 		;;
 	    m68k)
diff --git a/gdb/x86-bsd-nat.c b/gdb/x86-bsd-nat.c
index 2ff661c179..1d37b2f05d 100644
--- a/gdb/x86-bsd-nat.c
+++ b/gdb/x86-bsd-nat.c
@@ -51,11 +51,16 @@ x86bsd_mourn_inferior (struct target_ops *ops)
   super_mourn_inferior (ops);
 }
 
-/* Not all versions of FreeBSD/i386 that support the debug registers
-   have this macro.  */
+/* Helper macro to access debug register X.  FreeBSD/amd64 and modern
+   versions of FreeBSD/i386 provide this macro in system headers.  Define
+   a local version for systems that do not provide it.  */
 #ifndef DBREG_DRX
+#ifdef __NetBSD__
+#define DBREG_DRX(d, x) ((d)->dr[x])
+#else
 #define DBREG_DRX(d, x) ((&d->dr0)[x])
 #endif
+#endif
 
 static unsigned long
 x86bsd_dr_get (ptid_t ptid, int regnum)
-- 
2.13.3


  reply	other threads:[~2017-07-25 16:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 16:51 [PATCH v2 0/2] Various build fixes for NetBSD John Baldwin
2017-07-25 16:51 ` John Baldwin [this message]
2017-07-25 16:51 ` [PATCH v2 1/2] Define _KMEMUSER before including BSD kernel headers John Baldwin
2017-09-04 12:50 ` [PATCH v2 0/2] Various build fixes for NetBSD Pedro Alves
2017-09-04 13:03   ` Kamil Rytarowski
2017-09-04 14:01     ` Pedro Alves
2017-09-04 14:34       ` Kamil Rytarowski
2017-09-04 17:08         ` John Baldwin
2017-09-04 13:27   ` John Baldwin
2017-09-04 20:04     ` coypu
2017-09-04 22:18       ` 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=20170725165051.9132-3-jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=coypu@sdf.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