public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Kamil Rytarowski <krytarowski@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Add support for NetBSD threads in arm-nbsd-nat.c
Date: Sat, 14 Mar 2020 14:46:25 +0000 (GMT)	[thread overview]
Message-ID: <20200314144626.01E02393FC3C@sourceware.org> (raw)

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

commit 75c56d3d1298de72aa67555f2c723a80b4818e04
Author: Kamil Rytarowski <n54@gmx.com>
Date:   Sat Mar 14 15:44:28 2020 +0100

    Add support for NetBSD threads in arm-nbsd-nat.c
    
    NetBSD ptrace(2) accepts thread id (LWP) as the 4th argument for threads.
    
    gdb/ChangeLog:
    
            * arm-nbsd-nat.c (fetch_register): New variable lwp and pass
            it to the ptrace call.
            * arm-nbsd-nat.c (fetch_fp_register): Likewise.
            * arm-nbsd-nat.c (fetch_fp_regs): Likewise.
            * arm-nbsd-nat.c (store_register): Likewise.
            * arm-nbsd-nat.c (store_regs): Likewise.
            * arm-nbsd-nat.c (store_fp_register): Likewise.
            * arm-nbsd-nat.c (store_fp_regs): Likewise.

Diff:
---
 gdb/ChangeLog      | 11 +++++++++++
 gdb/arm-nbsd-nat.c | 26 +++++++++++++++++---------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 66ef062f16e..10f52ebbcef 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2020-03-14  Kamil Rytarowski  <n54@gmx.com>
+
+	* arm-nbsd-nat.c (fetch_register): New variable lwp and pass
+	it to the ptrace call.
+	* arm-nbsd-nat.c (fetch_fp_register): Likewise.
+	* arm-nbsd-nat.c (fetch_fp_regs): Likewise.
+	* arm-nbsd-nat.c (store_register): Likewise.
+	* arm-nbsd-nat.c (store_regs): Likewise.
+	* arm-nbsd-nat.c (store_fp_register): Likewise.
+	* arm-nbsd-nat.c (store_fp_regs): Likewise.
+
 2020-03-14  Kamil Rytarowski  <n54@gmx.com>
 
 	* arm-nbsd-nat.c (arm_netbsd_nat_target): Inherit from
diff --git a/gdb/arm-nbsd-nat.c b/gdb/arm-nbsd-nat.c
index e7cd23693b6..a8a67e6e852 100644
--- a/gdb/arm-nbsd-nat.c
+++ b/gdb/arm-nbsd-nat.c
@@ -66,9 +66,10 @@ fetch_register (struct regcache *regcache, int regno)
 {
   struct reg inferior_registers;
   int ret;
+  int lwp = regcache->ptid ().lwp ();
 
   ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+		(PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     {
@@ -83,8 +84,10 @@ static void
 fetch_fp_register (struct regcache *regcache, int regno)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
+
   int ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-		    (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+		    (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   struct vfpreg &vfp = inferior_fp_registers.fpr_vfp;
 
@@ -111,11 +114,12 @@ static void
 fetch_fp_regs (struct regcache *regcache)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
   int regno;
 
   ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+		(PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   if (ret < 0)
     {
@@ -149,10 +153,11 @@ store_register (const struct regcache *regcache, int regno)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   struct reg inferior_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
 
   ret = ptrace (PT_GETREGS, regcache->ptid ().pid (),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+		(PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     {
@@ -210,7 +215,7 @@ store_register (const struct regcache *regcache, int regno)
     }
 
   ret = ptrace (PT_SETREGS, regcache->ptid ().pid (),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+		(PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to write register %d to inferior"), regno);
@@ -221,6 +226,7 @@ store_regs (const struct regcache *regcache)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   struct reg inferior_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret;
   int regno;
 
@@ -252,7 +258,7 @@ store_regs (const struct regcache *regcache)
     }
 
   ret = ptrace (PT_SETREGS, regcache->ptid ().pid (),
-		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
+		(PTRACE_TYPE_ARG3) &inferior_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to store general registers"));
@@ -262,8 +268,9 @@ static void
 store_fp_register (const struct regcache *regcache, int regno)
 {
   struct fpreg inferior_fp_registers;
+  int lwp = regcache->ptid ().lwp ();
   int ret = ptrace (PT_GETFPREGS, regcache->ptid ().pid (),
-		    (PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+		    (PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
   struct vfpreg &vfp = inferior_fp_registers.fpr_vfp;
 
   if (ret < 0)
@@ -285,7 +292,7 @@ store_fp_register (const struct regcache *regcache, int regno)
     warning (_("Invalid register number."));
 
   ret = ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
-		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
+		(PTRACE_TYPE_ARG3) &inferior_fp_registers, lwp);
 
   if (ret < 0)
     warning (_("unable to write register %d to inferior"), regno);
@@ -295,6 +302,7 @@ static void
 store_fp_regs (const struct regcache *regcache)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
+  int lwp = regcache->ptid ().lwp ();
   if (tdep->vfp_register_count == 0)
     return;
 
@@ -307,7 +315,7 @@ store_fp_regs (const struct regcache *regcache)
 			 (char *) &fpregs.fpr_vfp.vfp_fpscr);
 
   int ret = ptrace (PT_SETFPREGS, regcache->ptid ().pid (),
-		    (PTRACE_TYPE_ARG3) &fpregs, 0);
+		    (PTRACE_TYPE_ARG3) &fpregs, lwp);
 
   if (ret < 0)
     warning (_("unable to store floating-point registers"));


                 reply	other threads:[~2020-03-14 14:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200314144626.01E02393FC3C@sourceware.org \
    --to=krytarowski@sourceware.org \
    --cc=gdb-cvs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).