public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 09/10] i386-darwin-nat: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
  2017-03-14  3:19 ` [PATCH 10/10] i386-gnu-nat: " Simon Marchi
@ 2017-03-14  3:19 ` Simon Marchi
  2017-03-14  3:19 ` [PATCH 08/10] i386-bsd-nat: " Simon Marchi
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* i386-darwin-nat.c (i386_darwin_fetch_inferior_registers,
	i386_darwin_store_inferior_registers): Use ptid from regcache.
---
 gdb/i386-darwin-nat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index 4bffe6d74e..dc7ce32d64 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -50,7 +50,7 @@ static void
 i386_darwin_fetch_inferior_registers (struct target_ops *ops,
 				      struct regcache *regcache, int regno)
 {
-  thread_t current_thread = ptid_get_tid (inferior_ptid);
+  thread_t current_thread = ptid_get_tid (regcache_get_ptid (regcache));
   int fetched = 0;
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
 
@@ -167,7 +167,7 @@ static void
 i386_darwin_store_inferior_registers (struct target_ops *ops,
 				      struct regcache *regcache, int regno)
 {
-  thread_t current_thread = ptid_get_tid (inferior_ptid);
+  thread_t current_thread = ptid_get_tid (regcache_get_ptid (regcache));
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
 
 #ifdef BFD64
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 07/10] hppa-obsd-nat: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
                   ` (5 preceding siblings ...)
  2017-03-14  3:19 ` [PATCH 04/10] corelow: " Simon Marchi
@ 2017-03-14  3:19 ` Simon Marchi
  2017-03-14  3:37 ` [PATCH 06/10] hppa-nbsd-nat: " Simon Marchi
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* hppa-obsd-nat.c (hppaobsd_fetch_registers,
	hppaobsd_store_registers): Use ptid from regcache.
---
 gdb/hppa-obsd-nat.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/gdb/hppa-obsd-nat.c b/gdb/hppa-obsd-nat.c
index 66af86b0f7..7a255c9953 100644
--- a/gdb/hppa-obsd-nat.c
+++ b/gdb/hppa-obsd-nat.c
@@ -189,12 +189,13 @@ static void
 hppaobsd_fetch_registers (struct target_ops *ops,
 			  struct regcache *regcache, int regnum)
 {
+  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
   if (regnum == -1 || hppaobsd_gregset_supplies_p (regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
       hppaobsd_supply_gregset (regcache, &regs);
@@ -204,8 +205,7 @@ hppaobsd_fetch_registers (struct target_ops *ops,
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	perror_with_name (_("Couldn't get floating point status"));
 
       hppaobsd_supply_fpregset (regcache, &fpregs);
@@ -223,14 +223,12 @@ hppaobsd_store_registers (struct target_ops *ops,
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-                  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't get registers"));
 
       hppaobsd_collect_gregset (regcache, &regs, regnum);
 
-      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-	          (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't write registers"));
     }
 
@@ -238,14 +236,12 @@ hppaobsd_store_registers (struct target_ops *ops,
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	perror_with_name (_("Couldn't get floating point status"));
 
       hppaobsd_collect_fpregset (regcache, &fpregs, regnum);
 
-      if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	perror_with_name (_("Couldn't write floating point status"));
     }
 }
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid
@ 2017-03-14  3:19 Simon Marchi
  2017-03-14  3:19 ` [PATCH 10/10] i386-gnu-nat: " Simon Marchi
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* arm-linux-nat.c (fetch_fpregs, store_fpregs, fetch_regs,
	store_regs, fetch_wmmx_regs, store_wmmx_regs, fetch_vfp_regs,
	store_vfp_regs): Use ptid from regcache.
---
 gdb/arm-linux-nat.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index c8474a9f4f..ad3085a25c 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -76,7 +76,7 @@ fetch_fpregs (struct regcache *regcache)
   gdb_byte fp[ARM_LINUX_SIZEOF_NWFPE];
 
   /* Get the thread id for the ptrace call.  */
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = ptid_get_lwp (regcache_get_ptid (regcache));
 
   /* Read the floating point state.  */
   if (have_ptrace_getregset == TRIBOOL_TRUE)
@@ -113,7 +113,7 @@ store_fpregs (const struct regcache *regcache)
   gdb_byte fp[ARM_LINUX_SIZEOF_NWFPE];
 
   /* Get the thread id for the ptrace call.  */
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = ptid_get_lwp (regcache_get_ptid (regcache));
 
   /* Read the floating point state.  */
   if (have_ptrace_getregset == TRIBOOL_TRUE)
@@ -167,7 +167,7 @@ fetch_regs (struct regcache *regcache)
   elf_gregset_t regs;
 
   /* Get the thread id for the ptrace call.  */
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = ptid_get_lwp (regcache_get_ptid (regcache));
 
   if (have_ptrace_getregset == TRIBOOL_TRUE)
     {
@@ -194,7 +194,7 @@ store_regs (const struct regcache *regcache)
   elf_gregset_t regs;
 
   /* Get the thread id for the ptrace call.  */
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = ptid_get_lwp (regcache_get_ptid (regcache));
 
   /* Fetch the general registers.  */
   if (have_ptrace_getregset == TRIBOOL_TRUE)
@@ -242,7 +242,7 @@ fetch_wmmx_regs (struct regcache *regcache)
   int ret, regno, tid;
 
   /* Get the thread id for the ptrace call.  */
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = ptid_get_lwp (regcache_get_ptid (regcache));
 
   ret = ptrace (PTRACE_GETWMMXREGS, tid, 0, regbuf);
   if (ret < 0)
@@ -268,7 +268,7 @@ store_wmmx_regs (const struct regcache *regcache)
   int ret, regno, tid;
 
   /* Get the thread id for the ptrace call.  */
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = ptid_get_lwp (regcache_get_ptid (regcache));
 
   ret = ptrace (PTRACE_GETWMMXREGS, tid, 0, regbuf);
   if (ret < 0)
@@ -307,7 +307,7 @@ fetch_vfp_regs (struct regcache *regcache)
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* Get the thread id for the ptrace call.  */
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = ptid_get_lwp (regcache_get_ptid (regcache));
 
   if (have_ptrace_getregset == TRIBOOL_TRUE)
     {
@@ -336,7 +336,7 @@ store_vfp_regs (const struct regcache *regcache)
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* Get the thread id for the ptrace call.  */
-  tid = ptid_get_lwp (inferior_ptid);
+  tid = ptid_get_lwp (regcache_get_ptid (regcache));
 
   if (have_ptrace_getregset == TRIBOOL_TRUE)
     {
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 04/10] corelow: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
                   ` (4 preceding siblings ...)
  2017-03-14  3:19 ` [PATCH 02/10] arm-nbsd-nat: " Simon Marchi
@ 2017-03-14  3:19 ` Simon Marchi
  2017-03-14  3:19 ` [PATCH 07/10] hppa-obsd-nat: " Simon Marchi
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* corelow.c (get_core_register_section): Use ptid from regcache,
	update doc.
---
 gdb/corelow.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gdb/corelow.c b/gdb/corelow.c
index ecde9542b5..656c7541a0 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -489,11 +489,11 @@ core_detach (struct target_ops *ops, const char *args, int from_tty)
    them to core_vec->core_read_registers, as the register set numbered
    WHICH.
 
-   If inferior_ptid's lwp member is zero, do the single-threaded
-   thing: look for a section named NAME.  If inferior_ptid's lwp
+   If ptid's lwp member is zero, do the single-threaded
+   thing: look for a section named NAME.  If ptid's lwp
    member is non-zero, do the multi-threaded thing: look for a section
    named "NAME/LWP", where LWP is the shortest ASCII decimal
-   representation of inferior_ptid's lwp member.
+   representation of ptid's lwp member.
 
    HUMAN_NAME is a human-readable name for the kind of registers the
    NAME section contains, for use in error messages.
@@ -517,12 +517,13 @@ get_core_register_section (struct regcache *regcache,
   char *contents;
   bool variable_size_section = (regset != NULL
 				&& regset->flags & REGSET_VARIABLE_SIZE);
+  ptid_t ptid = regcache_get_ptid (regcache);
 
   xfree (section_name);
 
-  if (ptid_get_lwp (inferior_ptid))
+  if (ptid_get_lwp (ptid))
     section_name = xstrprintf ("%s/%ld", name,
-			       ptid_get_lwp (inferior_ptid));
+			       ptid_get_lwp (ptid));
   else
     section_name = xstrdup (name);
 
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 02/10] arm-nbsd-nat: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
                   ` (3 preceding siblings ...)
  2017-03-14  3:19 ` [PATCH 03/10] bsd-uthread: " Simon Marchi
@ 2017-03-14  3:19 ` Simon Marchi
  2017-03-14  3:19 ` [PATCH 04/10] corelow: " Simon Marchi
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* arm-nbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register,
	fetch_fp_regs, store_register, store_regs, store_fp_register,
	store_fp_regs): Use ptid from regcache.
---
 gdb/arm-nbsd-nat.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/gdb/arm-nbsd-nat.c b/gdb/arm-nbsd-nat.c
index 95bb1b2ad0..f0665289d8 100644
--- a/gdb/arm-nbsd-nat.c
+++ b/gdb/arm-nbsd-nat.c
@@ -77,7 +77,7 @@ fetch_register (struct regcache *regcache, int regno)
   struct reg inferior_registers;
   int ret;
 
-  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
 
   if (ret < 0)
@@ -130,7 +130,7 @@ fetch_regs (struct regcache *regcache)
   int ret;
   int regno;
 
-  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
 
   if (ret < 0)
@@ -148,7 +148,7 @@ fetch_fp_register (struct regcache *regcache, int regno)
   struct fpreg inferior_fp_registers;
   int ret;
 
-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_GETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
 
   if (ret < 0)
@@ -178,7 +178,7 @@ fetch_fp_regs (struct regcache *regcache)
   int ret;
   int regno;
 
-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_GETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
 
   if (ret < 0)
@@ -216,7 +216,7 @@ store_register (const struct regcache *regcache, int regno)
   struct reg inferior_registers;
   int ret;
 
-  ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_GETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
 
   if (ret < 0)
@@ -279,7 +279,7 @@ store_register (const struct regcache *regcache, int regno)
       break;
     }
 
-  ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_SETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
 
   if (ret < 0)
@@ -327,7 +327,7 @@ store_regs (const struct regcache *regcache)
       inferior_registers.r_pc = pc_val | psr_val;
     }
 
-  ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_SETREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_registers, 0);
 
   if (ret < 0)
@@ -340,7 +340,7 @@ store_fp_register (const struct regcache *regcache, int regno)
   struct fpreg inferior_fp_registers;
   int ret;
 
-  ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_GETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
 
   if (ret < 0)
@@ -362,7 +362,7 @@ store_fp_register (const struct regcache *regcache, int regno)
       break;
     }
 
-  ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_SETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
 
   if (ret < 0)
@@ -384,7 +384,7 @@ store_fp_regs (const struct regcache *regcache)
   regcache_raw_collect (regcache, ARM_FPS_REGNUM,
 			(char *) &inferior_fp_registers.fpr_fpsr);
 
-  ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
+  ret = ptrace (PT_SETFPREGS, ptid_get_pid (regcache_get_ptid (regcache)),
 		(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
 
   if (ret < 0)
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 10/10] i386-gnu-nat: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
@ 2017-03-14  3:19 ` Simon Marchi
  2017-03-14  3:19 ` [PATCH 09/10] i386-darwin-nat: " Simon Marchi
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* i386-gnu-nat.c (gnu_fetch_registers, gnu_store_registers): Use
	ptid from regcache.
---
 gdb/i386-gnu-nat.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gdb/i386-gnu-nat.c b/gdb/i386-gnu-nat.c
index 6953eeb78e..3bce88a206 100644
--- a/gdb/i386-gnu-nat.c
+++ b/gdb/i386-gnu-nat.c
@@ -91,15 +91,15 @@ gnu_fetch_registers (struct target_ops *ops,
 		     struct regcache *regcache, int regno)
 {
   struct proc *thread;
+  ptid_t ptid = regcache_get_ptid (regcache);
 
   /* Make sure we know about new threads.  */
   inf_update_procs (gnu_current_inf);
 
-  thread = inf_tid_to_thread (gnu_current_inf,
-			      ptid_get_lwp (inferior_ptid));
+  thread = inf_tid_to_thread (gnu_current_inf, ptid_get_lwp (ptid));
   if (!thread)
     error (_("Can't fetch registers from thread %s: No such thread"),
-	   target_pid_to_str (inferior_ptid));
+	   target_pid_to_str (ptid));
 
   if (regno < I386_NUM_GREGS || regno == -1)
     {
@@ -184,15 +184,15 @@ gnu_store_registers (struct target_ops *ops,
 {
   struct proc *thread;
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  ptid_t ptid = regcache_get_ptid (regcache);
 
   /* Make sure we know about new threads.  */
   inf_update_procs (gnu_current_inf);
 
-  thread = inf_tid_to_thread (gnu_current_inf,
-			      ptid_get_lwp (inferior_ptid));
+  thread = inf_tid_to_thread (gnu_current_inf, ptid_get_lwp (ptid));
   if (!thread)
     error (_("Couldn't store registers into thread %s: No such thread"),
-	   target_pid_to_str (inferior_ptid));
+	   target_pid_to_str (ptid));
 
   if (regno < I386_NUM_GREGS || regno == -1)
     {
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 03/10] bsd-uthread: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
                   ` (2 preceding siblings ...)
  2017-03-14  3:19 ` [PATCH 08/10] i386-bsd-nat: " Simon Marchi
@ 2017-03-14  3:19 ` Simon Marchi
  2017-03-14  3:19 ` [PATCH 02/10] arm-nbsd-nat: " Simon Marchi
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This is one of the rare to_fetch/store_registers implementations that will
still rely (for now) on inferior_ptid (because of the memory read/write
operations).  We therefore have to add a save/restore of inferior_ptid.  We'll
be able to remove it when we make the memory operations accept the ptid as a
parameter.

gdb/ChangeLog:

	* bsd-uthread.c (bsd_uthread_fetch_registers,
	bsd_uthread_store_registers): Use ptid from regcache, set and
	restore inferior_ptid.
---
 gdb/bsd-uthread.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 20eecd3879..08b8f36969 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -290,9 +290,15 @@ bsd_uthread_fetch_registers (struct target_ops *ops,
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct bsd_uthread_ops *uthread_ops
     = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
-  CORE_ADDR addr = ptid_get_tid (inferior_ptid);
+  ptid_t ptid = regcache_get_ptid (regcache);
+  CORE_ADDR addr = ptid_get_tid (ptid);
   struct target_ops *beneath = find_target_beneath (ops);
   CORE_ADDR active_addr;
+  struct cleanup *cleanup = save_inferior_ptid ();
+
+  /* We are doing operations (e.g. reading memory) that rely on
+     inferior_ptid.  */
+  inferior_ptid = ptid;
 
   /* Always fetch the appropriate registers from the layer beneath.  */
   beneath->to_fetch_registers (beneath, regcache, regnum);
@@ -309,6 +315,8 @@ bsd_uthread_fetch_registers (struct target_ops *ops,
       uthread_ops->supply_uthread (regcache, regnum,
 				   addr + bsd_uthread_thread_ctx_offset);
     }
+
+  do_cleanups (cleanup);
 }
 
 static void
@@ -319,8 +327,14 @@ bsd_uthread_store_registers (struct target_ops *ops,
   struct bsd_uthread_ops *uthread_ops
     = (struct bsd_uthread_ops *) gdbarch_data (gdbarch, bsd_uthread_data);
   struct target_ops *beneath = find_target_beneath (ops);
-  CORE_ADDR addr = ptid_get_tid (inferior_ptid);
+  ptid_t ptid = regcache_get_ptid (regcache);
+  CORE_ADDR addr = ptid_get_tid (ptid);
   CORE_ADDR active_addr;
+  struct cleanup *cleanup = save_inferior_ptid ();
+
+  /* We are doing operations (e.g. reading memory) that rely on
+     inferior_ptid.  */
+  inferior_ptid = ptid;
 
   active_addr = bsd_uthread_read_memory_address (bsd_uthread_thread_run_addr);
   if (addr != 0 && addr != active_addr)
@@ -335,6 +349,8 @@ bsd_uthread_store_registers (struct target_ops *ops,
          request to the layer beneath.  */
       beneath->to_store_registers (beneath, regcache, regnum);
     }
+
+  do_cleanups (cleanup);
 }
 
 static ptid_t
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 08/10] i386-bsd-nat: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
  2017-03-14  3:19 ` [PATCH 10/10] i386-gnu-nat: " Simon Marchi
  2017-03-14  3:19 ` [PATCH 09/10] i386-darwin-nat: " Simon Marchi
@ 2017-03-14  3:19 ` Simon Marchi
  2017-03-14  3:19 ` [PATCH 03/10] bsd-uthread: " Simon Marchi
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* i386-bsd-nat.c (i386bsd_fetch_inferior_registers,
	i386bsd_store_inferior_registers): Use ptid from regcache.
---
 gdb/i386-bsd-nat.c | 37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/gdb/i386-bsd-nat.c b/gdb/i386-bsd-nat.c
index 186856cc5f..1de6c780c0 100644
--- a/gdb/i386-bsd-nat.c
+++ b/gdb/i386-bsd-nat.c
@@ -131,12 +131,13 @@ static void
 i386bsd_fetch_inferior_registers (struct target_ops *ops,
 				  struct regcache *regcache, int regnum)
 {
+  pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
+
   if (regnum == -1 || GETREGS_SUPPLIES (regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
       i386bsd_supply_gregset (regcache, &regs);
@@ -157,7 +158,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
 	  void *xstateregs;
 
 	  xstateregs = alloca (x86bsd_xsave_len);
-	  if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid),
+	  if (ptrace (PT_GETXSTATE, pid,
 		      (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
 	    perror_with_name (_("Couldn't get extended state status"));
 
@@ -168,8 +169,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
       
 #ifdef HAVE_PT_GETXMMREGS
       if (have_ptrace_xmmregs != 0
-	  && ptrace(PT_GETXMMREGS, get_ptrace_pid (inferior_ptid),
-		    (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
+	  && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
 	{
 	  have_ptrace_xmmregs = 1;
 	  i387_supply_fxsave (regcache, -1, xmmregs);
@@ -178,8 +178,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops,
 	{
 	  have_ptrace_xmmregs = 0;
 #endif
-          if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
-		      (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+          if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	    perror_with_name (_("Couldn't get floating point status"));
 
 	  i387_supply_fsave (regcache, -1, &fpregs);
@@ -196,18 +195,18 @@ static void
 i386bsd_store_inferior_registers (struct target_ops *ops,
 				  struct regcache *regcache, int regnum)
 {
+  pid_t pid = get_ptrace_pid (regcache_get_ptid (regcache));
+
   if (regnum == -1 || GETREGS_SUPPLIES (regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, get_ptrace_pid (inferior_ptid),
-                  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't get registers"));
 
       i386bsd_collect_gregset (regcache, &regs, regnum);
 
-      if (ptrace (PT_SETREGS, get_ptrace_pid (inferior_ptid),
-	          (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't write registers"));
 
       if (regnum != -1)
@@ -227,13 +226,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
 	  void *xstateregs;
 
 	  xstateregs = alloca (x86bsd_xsave_len);
-	  if (ptrace (PT_GETXSTATE, get_ptrace_pid (inferior_ptid),
+	  if (ptrace (PT_GETXSTATE, pid,
 		      (PTRACE_TYPE_ARG3) xstateregs, 0) == -1)
 	    perror_with_name (_("Couldn't get extended state status"));
 
 	  i387_collect_xsave (regcache, -1, xstateregs, 0);
 
-	  if (ptrace (PT_SETXSTATE, get_ptrace_pid (inferior_ptid),
+	  if (ptrace (PT_SETXSTATE, pid,
 		      (PTRACE_TYPE_ARG3) xstateregs, x86bsd_xsave_len) == -1)
 	    perror_with_name (_("Couldn't write extended state status"));
 	  return;
@@ -242,29 +241,25 @@ i386bsd_store_inferior_registers (struct target_ops *ops,
 
 #ifdef HAVE_PT_GETXMMREGS
       if (have_ptrace_xmmregs != 0
-	  && ptrace(PT_GETXMMREGS, get_ptrace_pid (inferior_ptid),
-		    (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
+	  && ptrace(PT_GETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
 	{
 	  have_ptrace_xmmregs = 1;
 
 	  i387_collect_fxsave (regcache, regnum, xmmregs);
 
-	  if (ptrace (PT_SETXMMREGS, get_ptrace_pid (inferior_ptid),
-		      (PTRACE_TYPE_ARG3) xmmregs, 0) == -1)
+	  if (ptrace (PT_SETXMMREGS, pid, (PTRACE_TYPE_ARG3) xmmregs, 0) == -1)
             perror_with_name (_("Couldn't write XMM registers"));
 	}
       else
 	{
 	  have_ptrace_xmmregs = 0;
 #endif
-          if (ptrace (PT_GETFPREGS, get_ptrace_pid (inferior_ptid),
-		      (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+          if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	    perror_with_name (_("Couldn't get floating point status"));
 
           i387_collect_fsave (regcache, regnum, &fpregs);
 
-          if (ptrace (PT_SETFPREGS, get_ptrace_pid (inferior_ptid),
-		      (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+          if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	    perror_with_name (_("Couldn't write floating point status"));
 #ifdef HAVE_PT_GETXMMREGS
         }
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 05/10] hppa-linux-nat: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
                   ` (7 preceding siblings ...)
  2017-03-14  3:37 ` [PATCH 06/10] hppa-nbsd-nat: " Simon Marchi
@ 2017-03-14  3:37 ` Simon Marchi
  2017-03-17 14:45 ` [PATCH 01/10] arm-linux-nat.c: " Pedro Alves
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* hppa-linux-nat.c (fetch_register, store_register): Use ptid
	from regcache.  Use get_ptrace_pid.
---
 gdb/hppa-linux-nat.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c
index 17d9ced9e5..c8eb93c51c 100644
--- a/gdb/hppa-linux-nat.c
+++ b/gdb/hppa-linux-nat.c
@@ -23,6 +23,7 @@
 #include "inferior.h"
 #include "target.h"
 #include "linux-nat.h"
+#include "inf-ptrace.h"
 
 #include <sys/procfs.h>
 #include "nat/gdb_ptrace.h"
@@ -213,7 +214,7 @@ static void
 fetch_register (struct regcache *regcache, int regno)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  int tid;
+  pid_t tid;
   int val;
 
   if (gdbarch_cannot_fetch_register (gdbarch, regno))
@@ -222,10 +223,7 @@ fetch_register (struct regcache *regcache, int regno)
       return;
     }
 
-  /* GNU/Linux LWP ID's are process ID's.  */
-  tid = ptid_get_lwp (inferior_ptid);
-  if (tid == 0)
-    tid = ptid_get_pid (inferior_ptid); /* Not a threaded program.  */
+  tid = get_ptrace_pid (regcache_get_ptid (regcache));
 
   errno = 0;
   val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0);
@@ -243,16 +241,13 @@ static void
 store_register (const struct regcache *regcache, int regno)
 {
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
-  int tid;
+  pid_t tid;
   int val;
 
   if (gdbarch_cannot_store_register (gdbarch, regno))
     return;
 
-  /* GNU/Linux LWP ID's are process ID's.  */
-  tid = ptid_get_lwp (inferior_ptid);
-  if (tid == 0)
-    tid = ptid_get_pid (inferior_ptid); /* Not a threaded program.  */
+  tid = get_ptrace_pid (regcache_get_ptid (regcache));
 
   errno = 0;
   regcache_raw_collect (regcache, regno, &val);
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 06/10] hppa-nbsd-nat: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
                   ` (6 preceding siblings ...)
  2017-03-14  3:19 ` [PATCH 07/10] hppa-obsd-nat: " Simon Marchi
@ 2017-03-14  3:37 ` Simon Marchi
  2017-03-14  3:37 ` [PATCH 05/10] hppa-linux-nat: " Simon Marchi
  2017-03-17 14:45 ` [PATCH 01/10] arm-linux-nat.c: " Pedro Alves
  9 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-14  3:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

gdb/ChangeLog:

	* hppa-nbsd-nat.c (hppanbsd_fetch_registers,
	hppanbsd_store_registers): Use ptid from regcache.
---
 gdb/hppa-nbsd-nat.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/gdb/hppa-nbsd-nat.c b/gdb/hppa-nbsd-nat.c
index 200bc6881e..54c776cf59 100644
--- a/gdb/hppa-nbsd-nat.c
+++ b/gdb/hppa-nbsd-nat.c
@@ -163,12 +163,13 @@ hppanbsd_fetch_registers (struct target_ops *ops,
 			  struct regcache *regcache, int regnum)
 
 {
+  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
   if (regnum == -1 || hppanbsd_gregset_supplies_p (regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
 	perror_with_name (_("Couldn't get registers"));
 
       hppanbsd_supply_gregset (regcache, &regs);
@@ -178,8 +179,7 @@ hppanbsd_fetch_registers (struct target_ops *ops,
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	perror_with_name (_("Couldn't get floating point status"));
 
       hppanbsd_supply_fpregset (regcache, &fpregs);
@@ -193,18 +193,18 @@ static void
 hppanbsd_store_registers (struct target_ops *ops,
 			  struct regcache *regcache, int regnum)
 {
+  pid_t pid = ptid_get_pid (regcache_get_ptid (regcache));
+
   if (regnum == -1 || hppanbsd_gregset_supplies_p (regnum))
     {
       struct reg regs;
 
-      if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
-                  (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_GETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't get registers"));
 
       hppanbsd_collect_gregset (regcache, &regs, regnum);
 
-      if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
-	          (PTRACE_TYPE_ARG3) &regs, 0) == -1)
+      if (ptrace (PT_SETREGS, pid, (PTRACE_TYPE_ARG3) &regs, 0) == -1)
         perror_with_name (_("Couldn't write registers"));
     }
 
@@ -212,14 +212,12 @@ hppanbsd_store_registers (struct target_ops *ops,
     {
       struct fpreg fpregs;
 
-      if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	perror_with_name (_("Couldn't get floating point status"));
 
       hppanbsd_collect_fpregset (regcache, &fpregs, regnum);
 
-      if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
-		  (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
+      if (ptrace (PT_SETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
 	perror_with_name (_("Couldn't write floating point status"));
     }
 }
-- 
2.12.0

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid
  2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
                   ` (8 preceding siblings ...)
  2017-03-14  3:37 ` [PATCH 05/10] hppa-linux-nat: " Simon Marchi
@ 2017-03-17 14:45 ` Pedro Alves
  2017-03-17 17:57   ` Simon Marchi
  9 siblings, 1 reply; 12+ messages in thread
From: Pedro Alves @ 2017-03-17 14:45 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

OK (the whole series).

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of  inferior_ptid
  2017-03-17 14:45 ` [PATCH 01/10] arm-linux-nat.c: " Pedro Alves
@ 2017-03-17 17:57   ` Simon Marchi
  0 siblings, 0 replies; 12+ messages in thread
From: Simon Marchi @ 2017-03-17 17:57 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On 2017-03-17 10:45, Pedro Alves wrote:
> OK (the whole series).
> 
> Thanks,
> Pedro Alves

Thanks, pushed.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-03-17 17:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14  3:19 [PATCH 01/10] arm-linux-nat.c: Use ptid from regcache instead of inferior_ptid Simon Marchi
2017-03-14  3:19 ` [PATCH 10/10] i386-gnu-nat: " Simon Marchi
2017-03-14  3:19 ` [PATCH 09/10] i386-darwin-nat: " Simon Marchi
2017-03-14  3:19 ` [PATCH 08/10] i386-bsd-nat: " Simon Marchi
2017-03-14  3:19 ` [PATCH 03/10] bsd-uthread: " Simon Marchi
2017-03-14  3:19 ` [PATCH 02/10] arm-nbsd-nat: " Simon Marchi
2017-03-14  3:19 ` [PATCH 04/10] corelow: " Simon Marchi
2017-03-14  3:19 ` [PATCH 07/10] hppa-obsd-nat: " Simon Marchi
2017-03-14  3:37 ` [PATCH 06/10] hppa-nbsd-nat: " Simon Marchi
2017-03-14  3:37 ` [PATCH 05/10] hppa-linux-nat: " Simon Marchi
2017-03-17 14:45 ` [PATCH 01/10] arm-linux-nat.c: " Pedro Alves
2017-03-17 17:57   ` Simon Marchi

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