gdb/testsuite: make test names unique in gdb.python/py-format-string.exp
[deliverable/binutils-gdb.git] / gdb / sparc-nat.c
index fadcfd344740013494abc64deed314ef8bebcf64..fa3b32cee18427ad89480ae9d45c1a663790aafc 100644 (file)
@@ -1,6 +1,6 @@
 /* Native-dependent code for SPARC.
 
-   Copyright (C) 2003-2020 Free Software Foundation, Inc.
+   Copyright (C) 2003-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -78,7 +78,7 @@ typedef struct fp_status fpregset_t;
 #define PTRACE_SETFPREGS PT_SETFPREGS
 #endif
 
-static int
+static PTRACE_TYPE_RET
 gdb_ptrace (PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG3 addr)
 {
 #ifdef __NetBSD__
@@ -147,7 +147,8 @@ sparc32_fpregset_supplies_p (struct gdbarch *gdbarch, int regnum)
    for all registers (including the floating-point registers).  */
 
 void
-sparc_fetch_inferior_registers (struct regcache *regcache, int regnum)
+sparc_fetch_inferior_registers (process_stratum_target *proc_target,
+                               regcache *regcache, int regnum)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   ptid_t ptid = regcache->ptid ();
@@ -167,6 +168,12 @@ sparc_fetch_inferior_registers (struct regcache *regcache, int regnum)
       if (gdb_ptrace (PTRACE_GETREGS, ptid, (PTRACE_TYPE_ARG3) &regs) == -1)
        perror_with_name (_("Couldn't get registers"));
 
+      /* Deep down, sparc_supply_rwindow reads memory, so needs the global
+        thread context to be set.  */
+      thread_info *thread = find_thread_ptid (proc_target, ptid);
+      scoped_restore_current_thread restore_thread;
+      switch_to_thread (thread);
+
       sparc_supply_gregset (sparc_gregmap, regcache, -1, &regs);
       if (regnum != -1)
        return;
@@ -184,7 +191,8 @@ sparc_fetch_inferior_registers (struct regcache *regcache, int regnum)
 }
 
 void
-sparc_store_inferior_registers (struct regcache *regcache, int regnum)
+sparc_store_inferior_registers (process_stratum_target *proc_target,
+                               regcache *regcache, int regnum)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   ptid_t ptid = regcache->ptid ();
@@ -208,6 +216,13 @@ sparc_store_inferior_registers (struct regcache *regcache, int regnum)
          ULONGEST sp;
 
          regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp);
+
+         /* Deep down, sparc_collect_rwindow writes memory, so needs the global
+            thread context to be set.  */
+         thread_info *thread = find_thread_ptid (proc_target, ptid);
+         scoped_restore_current_thread restore_thread;
+         switch_to_thread (thread);
+
          sparc_collect_rwindow (regcache, sp, regnum);
        }
 
This page took 0.024869 seconds and 4 git commands to generate.