public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Add support for NetBSD threads in x86-bsd-nat.c
@ 2020-03-14 13:23 Kamil Rytarowski
  0 siblings, 0 replies; only message in thread
From: Kamil Rytarowski @ 2020-03-14 13:23 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=013f99f035c49b000ca058db80ad15e00aa330dc

commit 013f99f035c49b000ca058db80ad15e00aa330dc
Author: Kamil Rytarowski <n54@gmx.com>
Date:   Sat Mar 14 14:17:16 2020 +0100

    Add support for NetBSD threads in x86-bsd-nat.c
    
    NetBSD ptrace(2) PT_GETDBREGS/PT_SETDBREGS accepts thread id (LWP)
    as the 4th argument for threads.
    
    gdb/ChangeLog:
    
            * x86-bsd-nat.c (x86bsd_dr_get): New variable lwp and pass
            it to the ptrace call.
            * x86-bsd-nat.c (x86bsd_dr_set): Likewise.

Diff:
---
 gdb/ChangeLog     |  6 ++++++
 gdb/x86-bsd-nat.c | 20 +++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 34212357c84..49e033533e2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2020-03-14  Kamil Rytarowski  <n54@gmx.com>
+
+	* x86-bsd-nat.c (x86bsd_dr_get): New variable lwp and pass
+	it to the ptrace call.
+	* x86-bsd-nat.c (x86bsd_dr_set): Likewise.
+
 2020-03-14  Kamil Rytarowski  <n54@gmx.com>
 
 	* vax-bsd-nat.c (vaxbsd_supply_gregset): New variable lwp and pass
diff --git a/gdb/x86-bsd-nat.c b/gdb/x86-bsd-nat.c
index 2bb8f8a2347..640a3c28110 100644
--- a/gdb/x86-bsd-nat.c
+++ b/gdb/x86-bsd-nat.c
@@ -56,9 +56,14 @@ static unsigned long
 x86bsd_dr_get (ptid_t ptid, int regnum)
 {
   struct dbreg dbregs;
+#ifdef __NetBSD__
+  int lwp = inferior_ptid.lwp ();
+#else
+  int lwp = 0;
+#endif
 
   if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
-	      (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+	      (PTRACE_TYPE_ARG3) &dbregs, lwp) == -1)
     perror_with_name (_("Couldn't read debug registers"));
 
   return DBREG_DRX ((&dbregs), regnum);
@@ -68,9 +73,14 @@ static void
 x86bsd_dr_set (int regnum, unsigned long value)
 {
   struct dbreg dbregs;
+#ifdef __NetBSD__
+  int lwp = inferior_ptid.lwp ();
+#else
+  int lwp = 0;
+#endif
 
   if (ptrace (PT_GETDBREGS, get_ptrace_pid (inferior_ptid),
-              (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+              (PTRACE_TYPE_ARG3) &dbregs, lwp) == -1)
     perror_with_name (_("Couldn't get debug registers"));
 
   /* For some mysterious reason, some of the reserved bits in the
@@ -82,8 +92,12 @@ x86bsd_dr_set (int regnum, unsigned long value)
 
   for (thread_info *thread : current_inferior ()->non_exited_threads ())
     {
+#ifdef __NetBSD__
+      lwp = thread->ptid.lwp ();
+#endif
+
       if (ptrace (PT_SETDBREGS, get_ptrace_pid (thread->ptid),
-		  (PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
+		  (PTRACE_TYPE_ARG3) &dbregs, lwp) == -1)
 	perror_with_name (_("Couldn't write debug registers"));
     }
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-14 13:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-14 13:23 [binutils-gdb] Add support for NetBSD threads in x86-bsd-nat.c Kamil Rytarowski

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).