]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Pass ptid to to_prepare_to_store users/simark/ptid-in-fetch-store-regs
authorSimon Marchi <simon.marchi@ericsson.com>
Tue, 7 Mar 2017 18:46:08 +0000 (13:46 -0500)
committerSimon Marchi <simon.marchi@ericsson.com>
Tue, 7 Mar 2017 21:47:46 +0000 (16:47 -0500)
In the same vein as to_fetch_registers and to_store_registers, we can
update to_prepare_to_store to take the ptid of the thread whose register
we want to store as a parameter, rather than reading it from
inferior_ptid.

gdb/ChangeLog:

* target.h (struct target_ops) <to_prepare_to_store>: Add ptid_t
parameter.
(target_prepare_to_store): Likewise.
* target-delegates.c: Re-generate.
* inf-child.c (inf_child_prepare_to_store): Add ptid parameter.
* ppc-ravenscar-thread.c
(ppc_ravenscar_generic_prepare_to_store): Likewise.
* ravenscar-thread.c (ravenscar_prepare_to_store): Add ptid
parameter and use it instead of inferior_ptid.
* ravenscar-thread.h (struct ravenscar_arch_ops)
<to_prepare_to_store>: Add ptid parameter.
* record-btrace.c (record_btrace_prepare_to_store): Add ptid
parameter and use it instead of inferior_ptid.
* record-full.c (record_full_core_prepare_to_store): Add ptid
parameter.
* regcache.c (regcache_raw_write): Pass ptid to
target_prepare_to_store.
* remote-sim.c (gdbsim_prepare_to_store): Add ptid parameter.
* remote.c (remote_prepare_to_store): Add ptid parameter.
* sparc-ravenscar-thread.c (sparc_ravenscar_prepare_to_store):
Add ptid parameter.

12 files changed:
gdb/inf-child.c
gdb/ppc-ravenscar-thread.c
gdb/ravenscar-thread.c
gdb/ravenscar-thread.h
gdb/record-btrace.c
gdb/record-full.c
gdb/regcache.c
gdb/remote-sim.c
gdb/remote.c
gdb/sparc-ravenscar-thread.c
gdb/target-delegates.c
gdb/target.h

index 0f128c4905ea309c34010e60001c8e319bc39b74..e5bf2f9ecf446cf2b24f85f3f98e3f2f28b45626 100644 (file)
@@ -111,7 +111,8 @@ inf_child_post_attach (struct target_ops *self, int pid)
 
 static void
 inf_child_prepare_to_store (struct target_ops *self,
-                           struct regcache *regcache)
+                           struct regcache *regcache,
+                           ptid_t ptid)
 {
 }
 
index 1e4eb03cf14a358b254dd3de156edfb5567cdfc6..078182e6f5dfc2e965ca2fbc0e56862922deb22f 100644 (file)
@@ -173,7 +173,7 @@ ppc_ravenscar_generic_fetch_registers
    thread.  */
 
 static void
-ppc_ravenscar_generic_prepare_to_store (struct regcache *regcache)
+ppc_ravenscar_generic_prepare_to_store (struct regcache *regcache, ptid_t ptid)
 {
   /* Nothing to do.  */
 }
index 0660d03a5ea1be2a90b474b874381659b3b8effd..27554573d1a594ea00933945ca3d1da2eef921cb 100644 (file)
@@ -58,7 +58,8 @@ static char *ravenscar_extra_thread_info (struct target_ops *self,
                                          struct thread_info *tp);
 static int ravenscar_thread_alive (struct target_ops *ops, ptid_t ptid);
 static void ravenscar_prepare_to_store (struct target_ops *self,
-                                       struct regcache *regcache);
+                                       struct regcache *regcache,
+                                       ptid_t ptid);
 static void ravenscar_resume (struct target_ops *ops, ptid_t ptid, int step,
                              enum gdb_signal siggnal);
 static void ravenscar_mourn_inferior (struct target_ops *ops);
@@ -302,21 +303,22 @@ ravenscar_store_registers (struct target_ops *ops,
 
 static void
 ravenscar_prepare_to_store (struct target_ops *self,
-                           struct regcache *regcache)
+                           struct regcache *regcache,
+                           ptid_t ptid)
 {
   struct target_ops *beneath = find_target_beneath (self);
 
   if (!ravenscar_runtime_initialized ()
-      || ptid_equal (inferior_ptid, base_magic_null_ptid)
-      || ptid_equal (inferior_ptid, ravenscar_running_thread ()))
-    beneath->to_prepare_to_store (beneath, regcache);
+      || ptid_equal (ptid, base_magic_null_ptid)
+      || ptid_equal (ptid, ravenscar_running_thread ()))
+    beneath->to_prepare_to_store (beneath, regcache, ptid);
   else
     {
       struct gdbarch *gdbarch = get_regcache_arch (regcache);
       struct ravenscar_arch_ops *arch_ops
        = gdbarch_ravenscar_ops (gdbarch);
 
-      arch_ops->to_prepare_to_store (regcache);
+      arch_ops->to_prepare_to_store (regcache, ptid);
     }
 }
 
index 2df88981a573fa405541aa1eeb66b4fc7c09b5ae..ab2f9a7c820bf20e62618e67ac03064fc3307191 100644 (file)
@@ -26,7 +26,7 @@ struct ravenscar_arch_ops
 {
   void (*to_fetch_registers) (struct regcache *, ptid_t, int);
   void (*to_store_registers) (struct regcache *, ptid_t, int);
-  void (*to_prepare_to_store) (struct regcache *);
+  void (*to_prepare_to_store) (struct regcache *, ptid_t);
 };
 
 #endif /* !defined (RAVENSCAR_THREAD_H) */
index 6c16148a252c462d4c88b96e16f07ed490fe3817..6674eac8a1751f9db02f9f65baff51cf0a5aa547 100644 (file)
@@ -1481,16 +1481,17 @@ record_btrace_store_registers (struct target_ops *ops,
 
 static void
 record_btrace_prepare_to_store (struct target_ops *ops,
-                               struct regcache *regcache)
+                               struct regcache *regcache,
+                               ptid_t ptid)
 {
   struct target_ops *t;
 
   if (!record_btrace_generating_corefile
-      && record_btrace_is_replaying (ops, inferior_ptid))
+      && record_btrace_is_replaying (ops, ptid))
     return;
 
   t = ops->beneath;
-  t->to_prepare_to_store (t, regcache);
+  t->to_prepare_to_store (t, regcache, ptid);
 }
 
 /* The branch trace frame cache.  */
index c55fb41b0142df641d0b44c01ebc48fb094b1338..220e996e3d8aafba2bc550ea9c7bd3a712e58a10 100644 (file)
@@ -2065,7 +2065,8 @@ record_full_core_fetch_registers (struct target_ops *ops,
 
 static void
 record_full_core_prepare_to_store (struct target_ops *self,
-                                  struct regcache *regcache)
+                                  struct regcache *regcache,
+                                  ptid_t ptid)
 {
 }
 
index c8eb200fa271ff759b9e996db3308e0b407c36c2..1b017502b6110ae433deb4bd1df6ba1b28e786eb 100644 (file)
@@ -949,7 +949,7 @@ regcache_raw_write (struct regcache *regcache, int regnum,
   chain_before_save_inferior = save_inferior_ptid ();
   inferior_ptid = regcache->ptid;
 
-  target_prepare_to_store (regcache);
+  target_prepare_to_store (regcache, regcache->ptid);
   regcache_raw_set_cached_value (regcache, regnum, buf);
 
   /* Register a cleanup function for invalidating the register after it is
index b7ecdbb05f338aa7aebd2124b1c22a46b6423f17..81626f313598e319dabb54a57a943071866f03b5 100644 (file)
@@ -82,7 +82,8 @@ static void gdbsim_detach (struct target_ops *ops, const char *args,
                           int from_tty);
 
 static void gdbsim_prepare_to_store (struct target_ops *self,
-                                    struct regcache *regcache);
+                                    struct regcache *regcache,
+                                    ptid_t ptid);
 
 static void gdbsim_files_info (struct target_ops *target);
 
@@ -1060,7 +1061,8 @@ gdbsim_wait (struct target_ops *ops,
    debugged.  */
 
 static void
-gdbsim_prepare_to_store (struct target_ops *self, struct regcache *regcache)
+gdbsim_prepare_to_store (struct target_ops *self, struct regcache *regcache,
+                        ptid_t ptid)
 {
   /* Do nothing, since we can store individual regs.  */
 }
index b7ffa4a28fbfad19e4c10892c4278f3a2d018e2d..e4c4717e45b8a4e45301ce6817fcb79d00876c55 100644 (file)
@@ -106,7 +106,8 @@ static int getpkt_or_notif_sane (char **buf, long *sizeof_buf,
 static void remote_files_info (struct target_ops *ignore);
 
 static void remote_prepare_to_store (struct target_ops *self,
-                                    struct regcache *regcache);
+                                    struct regcache *regcache,
+                                    ptid_t ptid);
 
 static void remote_open_1 (const char *, int, struct target_ops *,
                           int extended_p);
@@ -7755,7 +7756,8 @@ remote_fetch_registers (struct target_ops *ops, struct regcache *regcache,
    first.  */
 
 static void
-remote_prepare_to_store (struct target_ops *self, struct regcache *regcache)
+remote_prepare_to_store (struct target_ops *self, struct regcache *regcache,
+                        ptid_t ptid)
 {
   struct remote_arch_state *rsa = get_remote_arch_state ();
   int i;
index 4e63ec5a3c464b20d1dc76a3109a7c3993aba168..9d340d2289a0d179df992bff798729a508a9544a 100644 (file)
@@ -25,7 +25,8 @@
 #include "ravenscar-thread.h"
 #include "sparc-ravenscar-thread.h"
 
-static void sparc_ravenscar_prepare_to_store (struct regcache *regcache);
+static void sparc_ravenscar_prepare_to_store (struct regcache *regcache,
+                                             ptid_t ptid);
 
 /* Register offsets from a referenced address (exempli gratia the
    Thread_Descriptor).  The referenced address depends on the register
@@ -141,7 +142,7 @@ sparc_ravenscar_fetch_registers (struct regcache *regcache, ptid_t ptid,
    thread.  */
 
 static void
-sparc_ravenscar_prepare_to_store (struct regcache *regcache)
+sparc_ravenscar_prepare_to_store (struct regcache *regcache, ptid_t ptid)
 {
   /* Nothing to do.  */
 }
index 3f1c236d8f30ac72ee5bef2d97786f132cf630ed..26534382b7b72168eaa58d97ed3f773ef64b5135 100644 (file)
@@ -216,27 +216,29 @@ debug_store_registers (struct target_ops *self, struct regcache *arg1, ptid_t ar
 }
 
 static void
-delegate_prepare_to_store (struct target_ops *self, struct regcache *arg1)
+delegate_prepare_to_store (struct target_ops *self, struct regcache *arg1, ptid_t arg2)
 {
   self = self->beneath;
-  self->to_prepare_to_store (self, arg1);
+  self->to_prepare_to_store (self, arg1, arg2);
 }
 
 static void
-tdefault_prepare_to_store (struct target_ops *self, struct regcache *arg1)
+tdefault_prepare_to_store (struct target_ops *self, struct regcache *arg1, ptid_t arg2)
 {
   noprocess ();
 }
 
 static void
-debug_prepare_to_store (struct target_ops *self, struct regcache *arg1)
+debug_prepare_to_store (struct target_ops *self, struct regcache *arg1, ptid_t arg2)
 {
   fprintf_unfiltered (gdb_stdlog, "-> %s->to_prepare_to_store (...)\n", debug_target.to_shortname);
-  debug_target.to_prepare_to_store (&debug_target, arg1);
+  debug_target.to_prepare_to_store (&debug_target, arg1, arg2);
   fprintf_unfiltered (gdb_stdlog, "<- %s->to_prepare_to_store (", debug_target.to_shortname);
   target_debug_print_struct_target_ops_p (&debug_target);
   fputs_unfiltered (", ", gdb_stdlog);
   target_debug_print_struct_regcache_p (arg1);
+  fputs_unfiltered (", ", gdb_stdlog);
+  target_debug_print_ptid_t (arg2);
   fputs_unfiltered (")\n", gdb_stdlog);
 }
 
index d6c07ad44d874c1fac3773bcb826fd32ff451898..4a0749de86860df390afa235d6c6fa30d367e684 100644 (file)
@@ -474,7 +474,7 @@ struct target_ops
     void (*to_store_registers) (struct target_ops *, struct regcache *, ptid_t,
                                int)
       TARGET_DEFAULT_NORETURN (noprocess ());
-    void (*to_prepare_to_store) (struct target_ops *, struct regcache *)
+    void (*to_prepare_to_store) (struct target_ops *, struct regcache *, ptid_t)
       TARGET_DEFAULT_NORETURN (noprocess ());
 
     void (*to_files_info) (struct target_ops *)
@@ -1401,8 +1401,8 @@ extern void target_store_registers (struct regcache *regcache, ptid_t ptid,
    that REGISTERS contains all the registers from the program being
    debugged.  */
 
-#define        target_prepare_to_store(regcache)       \
-     (*current_target.to_prepare_to_store) (&current_target, regcache)
+#define        target_prepare_to_store(regcache, ptid) \
+     (*current_target.to_prepare_to_store) (&current_target, regcache, ptid)
 
 /* Determine current address space of thread PTID.  */