]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* regcache.c (struct regcache): Add ptid_t member.
authorUlrich Weigand <uweigand@de.ibm.com>
Sat, 16 Jun 2007 17:16:26 +0000 (17:16 +0000)
committerUlrich Weigand <uweigand@de.ibm.com>
Sat, 16 Jun 2007 17:16:26 +0000 (17:16 +0000)
(regcache_xmalloc): Initialize it.
(regcache_cpy_no_passthrough): Do not refer to current_regcache.
(regcache_dup): Likewise.
(regcache_dup_no_passthrough): Likewise.
(current_regcache): Make static.
(registers_ptid): Remove variable.
(get_thread_regcache): New function.
(get_current_regcache): New function.
(registers_changed): Implement by freeing current regcache.
(regcache_raw_read): Do not refer to current_regcache.  Set
inferior_ptid to regcache->ptid while calling target routines.
(regcache_raw_write): Likewise.
(regcache_raw_supply): Do not refer to current_regcache.
(read_pc_pid): Use thread regcache.  Do not modify inferior_ptid.
(write_pc_pid): Likewise.
(build_regcache): Remove.
(_initialize_regcache): Do not call DEPRECATED_REGISTER_GDBARCH_SWAP
or deprecated_register_gdbarch_swap.  Do not initialize
registers_ptid.
* regcache.h (get_current_regcache): Add prototype.
(get_thread_regcache): Likewise.
(current_regcache): Remove declaration.

* corelow.c (core_open): Replace current_regcache by
get_current_regcache ().
* frame.c (frame_pop): Likewise.
(put_frame_register): Likewise.
(get_current_frame, create_new_frame): Likewise.
* mi/mi-main.c (mi_cmd_data_write_register_values): Likewise.
* stack.c (return_command): Likewise.
* infcall.c (call_function_by_hand): Likewise.
* infrun.c (resume): Likewise.
(save_inferior_status, restore_inferior_status): Likewise.
* linux-fork.c (fork_load_infrun_state): Likewise.
(fork_save_infrun_state): Likewise.
* win32-nat.c (win32_resume): Likewise.
* i386fbsd-nat.c (i386fbsd_resume): Likewise.
* monitor.c (monitor_wait): Likewise.
* remote.c (remote_wait): Likewise.
* remote-mips.c (mips_wait): Likewise.

* bsd-kvm.c (bsd_kvm_open): Likewise
(bsd_kvm_proc_cmd, bsd_kvm_pcb_cmd): Likewise.
* fbsd-nat.c (fbsd_make_corefile_notes): Likewise.
* i386-linux-nat.c (i386_linux_resume): Likewise.
* ia64-linux-nat.c (ia64_linux_insert_watchpoint): Likewise.
(ia64_linux_stopped_data_address): Likewise.

* frv-tdep.c (frv_fdpic_loadmap_addresses): Likewise.
* m32c-tdep.c (m32c_virtual_frame_pointer): Likewise.
* mep-tdep.c (current_me_module, current_options): Likewise.
* mips-tdep.c (deprecated_mips_set_processor_regs_hack): Likewise.

* linux-nat.c (linux_nat_do_thread_registers): Use thread
regcache instead of current_regcache.  Call target_fetch_registers.
(linux_nat_corefile_thread_callback): Update call site.
(linux_nat_do_registers): Likewise.
* procfs.c (procfs_do_thread_registers): Use thread regcache instead
of current_regcache.
(procfs_make_note_section): Likewise.
* proc-service.c (ps_lgetregs, ps_lsetregs): Likewise.
(ps_lgetfpregs, ps_lsetfpregs): Likewise.
* sol-thread.c (ps_lgetregs, ps_lsetregs): Likewise.
(ps_lgetfpregs, ps_lsetfpregs): Likewise.

28 files changed:
gdb/ChangeLog
gdb/bsd-kvm.c
gdb/corelow.c
gdb/fbsd-nat.c
gdb/frame.c
gdb/frv-tdep.c
gdb/i386-linux-nat.c
gdb/i386fbsd-nat.c
gdb/ia64-linux-nat.c
gdb/infcall.c
gdb/infrun.c
gdb/linux-fork.c
gdb/linux-nat.c
gdb/m32c-tdep.c
gdb/mep-tdep.c
gdb/mi/mi-main.c
gdb/mips-tdep.c
gdb/monitor.c
gdb/proc-service.c
gdb/procfs.c
gdb/regcache.c
gdb/regcache.h
gdb/remote-mips.c
gdb/remote.c
gdb/sol-thread.c
gdb/stack.c
gdb/win32-nat.c
gdb/windows-nat.c

index ebb43c9ce8be0a07af39f03c1a8c44750321240c..8b086d751064d91d97cf37d2fd3ccf8c77d71a1b 100644 (file)
@@ -1,3 +1,71 @@
+2007-06-16  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * regcache.c (struct regcache): Add ptid_t member.
+       (regcache_xmalloc): Initialize it.
+       (regcache_cpy_no_passthrough): Do not refer to current_regcache.
+       (regcache_dup): Likewise.
+       (regcache_dup_no_passthrough): Likewise.
+       (current_regcache): Make static.
+       (registers_ptid): Remove variable.
+       (get_thread_regcache): New function.
+       (get_current_regcache): New function.
+       (registers_changed): Implement by freeing current regcache.
+       (regcache_raw_read): Do not refer to current_regcache.  Set 
+       inferior_ptid to regcache->ptid while calling target routines.
+       (regcache_raw_write): Likewise.
+       (regcache_raw_supply): Do not refer to current_regcache.
+       (read_pc_pid): Use thread regcache.  Do not modify inferior_ptid.
+       (write_pc_pid): Likewise.
+       (build_regcache): Remove.
+       (_initialize_regcache): Do not call DEPRECATED_REGISTER_GDBARCH_SWAP
+       or deprecated_register_gdbarch_swap.  Do not initialize
+       registers_ptid.
+       * regcache.h (get_current_regcache): Add prototype.
+       (get_thread_regcache): Likewise.
+       (current_regcache): Remove declaration.
+
+       * corelow.c (core_open): Replace current_regcache by
+       get_current_regcache ().
+       * frame.c (frame_pop): Likewise.
+       (put_frame_register): Likewise.
+       (get_current_frame, create_new_frame): Likewise.
+       * mi/mi-main.c (mi_cmd_data_write_register_values): Likewise.
+       * stack.c (return_command): Likewise.
+       * infcall.c (call_function_by_hand): Likewise.
+       * infrun.c (resume): Likewise.
+       (save_inferior_status, restore_inferior_status): Likewise.
+       * linux-fork.c (fork_load_infrun_state): Likewise.
+       (fork_save_infrun_state): Likewise.
+       * win32-nat.c (win32_resume): Likewise.
+       * i386fbsd-nat.c (i386fbsd_resume): Likewise.
+       * monitor.c (monitor_wait): Likewise.
+       * remote.c (remote_wait): Likewise.
+       * remote-mips.c (mips_wait): Likewise.
+
+       * bsd-kvm.c (bsd_kvm_open): Likewise
+       (bsd_kvm_proc_cmd, bsd_kvm_pcb_cmd): Likewise.
+       * fbsd-nat.c (fbsd_make_corefile_notes): Likewise.
+       * i386-linux-nat.c (i386_linux_resume): Likewise.
+       * ia64-linux-nat.c (ia64_linux_insert_watchpoint): Likewise.
+       (ia64_linux_stopped_data_address): Likewise.
+
+       * frv-tdep.c (frv_fdpic_loadmap_addresses): Likewise.
+       * m32c-tdep.c (m32c_virtual_frame_pointer): Likewise.
+       * mep-tdep.c (current_me_module, current_options): Likewise.
+       * mips-tdep.c (deprecated_mips_set_processor_regs_hack): Likewise.
+
+       * linux-nat.c (linux_nat_do_thread_registers): Use thread
+       regcache instead of current_regcache.  Call target_fetch_registers.
+       (linux_nat_corefile_thread_callback): Update call site.
+       (linux_nat_do_registers): Likewise.
+       * procfs.c (procfs_do_thread_registers): Use thread regcache instead
+       of current_regcache.
+       (procfs_make_note_section): Likewise.
+       * proc-service.c (ps_lgetregs, ps_lsetregs): Likewise.
+       (ps_lgetfpregs, ps_lsetfpregs): Likewise.
+       * sol-thread.c (ps_lgetregs, ps_lsetregs): Likewise.
+       (ps_lgetfpregs, ps_lsetfpregs): Likewise.
+
 2007-06-15  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * regcache.c (read_register, read_register_pid): Remove.
index 910b3d0a19749d055413a9f68fdac150325da20a..5e4c57d9c6deb818f59137fd2914df6a6ed5537e 100644 (file)
@@ -91,7 +91,7 @@ bsd_kvm_open (char *filename, int from_tty)
   core_kd = temp_kd;
   push_target (&bsd_kvm_ops);
 
-  target_fetch_registers (current_regcache, -1);
+  target_fetch_registers (get_current_regcache (), -1);
 
   reinit_frame_cache ();
   print_stack_frame (get_selected_frame (NULL), -1, 1);
@@ -273,7 +273,7 @@ bsd_kvm_proc_cmd (char *arg, int fromtty)
   if (kvm_read (core_kd, addr, &bsd_kvm_paddr, sizeof bsd_kvm_paddr) == -1)
     error (("%s"), kvm_geterr (core_kd));
 
-  target_fetch_registers (current_regcache, -1);
+  target_fetch_registers (get_current_regcache (), -1);
 
   reinit_frame_cache ();
   print_stack_frame (get_selected_frame (NULL), -1, 1);
@@ -293,7 +293,7 @@ bsd_kvm_pcb_cmd (char *arg, int fromtty)
 
   bsd_kvm_paddr = (struct pcb *)(u_long) parse_and_eval_address (arg);
 
-  target_fetch_registers (current_regcache, -1);
+  target_fetch_registers (get_current_regcache (), -1);
 
   reinit_frame_cache ();
   print_stack_frame (get_selected_frame (NULL), -1, 1);
index 82e6d7d983387b5423d2ea5ab7abdfdc71c95da3..d85b14b4e0a5461d5eadb5ee5c5cd9b9d97b4a7b 100644 (file)
@@ -375,7 +375,7 @@ core_open (char *filename, int from_tty)
   if (ontop)
     {
       /* Fetch all registers from core file.  */
-      target_fetch_registers (current_regcache, -1);
+      target_fetch_registers (get_current_regcache (), -1);
 
       /* Now, set up the frame cache, and print the top of stack.  */
       reinit_frame_cache ();
index 06e2151b471fcd0cf2eef957d57404a5f173d64b..cef15ccbf75577add9dae8bd65cd64ef6f40b028 100644 (file)
@@ -146,7 +146,7 @@ char *
 fbsd_make_corefile_notes (bfd *obfd, int *note_size)
 {
   struct gdbarch *gdbarch = current_gdbarch;
-  const struct regcache *regcache = current_regcache;
+  const struct regcache *regcache = get_current_regcache ();
   gregset_t gregs;
   fpregset_t fpregs;
   char *note_data = NULL;
index 42a44d42219be8c32cfc408edc85af595f7bffac..4e26f5a7832528eae53032422d89c00960314a3a 100644 (file)
@@ -526,7 +526,7 @@ frame_pop (struct frame_info *this_frame)
 
   /* Make a copy of all the register values unwound from this frame.
      Save them in a scratch buffer so that there isn't a race between
-     trying to extract the old values from the current_regcache while
+     trying to extract the old values from the current regcache while
      at the same time writing new values into that same cache.  */
   scratch = frame_save_as_regcache (prev_frame);
   cleanups = make_cleanup_regcache_xfree (scratch);
@@ -541,7 +541,7 @@ frame_pop (struct frame_info *this_frame)
      (arguably a bug in the target code mind).  */
   /* Now copy those saved registers into the current regcache.
      Here, regcache_cpy() calls regcache_restore().  */
-  regcache_cpy (current_regcache, scratch);
+  regcache_cpy (get_current_regcache (), scratch);
   do_cleanups (cleanups);
 
   /* We've made right mess of GDB's local state, just discard
@@ -714,7 +714,7 @@ put_frame_register (struct frame_info *frame, int regnum,
        break;
       }
     case lval_register:
-      regcache_cooked_write (current_regcache, realnum, buf);
+      regcache_cooked_write (get_current_regcache (), realnum, buf);
       break;
     default:
       error (_("Attempt to assign to an unmodifiable value."));
@@ -919,7 +919,7 @@ get_current_frame (void)
   if (current_frame == NULL)
     {
       struct frame_info *sentinel_frame =
-       create_sentinel_frame (current_regcache);
+       create_sentinel_frame (get_current_regcache ());
       if (catch_exceptions (uiout, unwind_to_current_frame, sentinel_frame,
                            RETURN_MASK_ERROR) != 0)
        {
@@ -1031,7 +1031,7 @@ create_new_frame (CORE_ADDR addr, CORE_ADDR pc)
 
   fi = FRAME_OBSTACK_ZALLOC (struct frame_info);
 
-  fi->next = create_sentinel_frame (current_regcache);
+  fi->next = create_sentinel_frame (get_current_regcache ());
 
   /* Select/initialize both the unwind function and the frame's type
      based on the PC.  */
index 7cb7b3287895570c83c8f717a2aff467828d30d7..b339bb9a1bfab77db434926f1aeefdbb57ac871b 100644 (file)
@@ -112,17 +112,19 @@ frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch, CORE_ADDR *interp_addr,
     return -1;
   else
     {
+      struct regcache *regcache = get_current_regcache ();
+
       if (interp_addr != NULL)
        {
          ULONGEST val;
-         regcache_cooked_read_unsigned (current_regcache,
+         regcache_cooked_read_unsigned (regcache,
                                         fdpic_loadmap_interp_regnum, &val);
          *interp_addr = val;
        }
       if (exec_addr != NULL)
        {
          ULONGEST val;
-         regcache_cooked_read_unsigned (current_regcache,
+         regcache_cooked_read_unsigned (regcache,
                                         fdpic_loadmap_exec_regnum, &val);
          *exec_addr = val;
        }
index 1541cfc890414ff3e05a68acb0ae510817b5bc5b..7a2be097eb5a3bc557b5c5dcfa973e40b9c855bd 100644 (file)
@@ -738,14 +738,12 @@ i386_linux_resume (ptid_t ptid, int step, enum target_signal signal)
 
   if (step)
     {
-      struct cleanup *old_chain = save_inferior_ptid ();
-      struct regcache *regcache = current_regcache;
+      struct regcache *regcache = get_thread_regcache (pid_to_ptid (pid));
       ULONGEST pc;
       gdb_byte buf[LINUX_SYSCALL_LEN];
 
       request = PTRACE_SINGLESTEP;
 
-      inferior_ptid = pid_to_ptid (pid);
       regcache_cooked_read_unsigned (regcache, PC_REGNUM, &pc);
 
       /* Returning from a signal trampoline is done by calling a
@@ -784,8 +782,6 @@ i386_linux_resume (ptid_t ptid, int step, enum target_signal signal)
              write_memory (addr, (gdb_byte *) &eflags, 4);
            }
        }
-
-      do_cleanups (old_chain);
     }
 
   if (ptrace (request, pid, 0, target_signal_to_host (signal)) == -1)
index 111170413c076c48aad4d9860e07f7ca4483d9ae..c3bdf53c3ebcee9dd3f7ade34d747d42f9d259a3 100644 (file)
@@ -49,6 +49,7 @@ i386fbsd_resume (ptid_t ptid, int step, enum target_signal signal)
 
   if (!step)
     {
+      struct regcache *regcache = get_current_regcache ();
       ULONGEST eflags;
 
       /* Workaround for a bug in FreeBSD.  Make sure that the trace
@@ -61,10 +62,10 @@ i386fbsd_resume (ptid_t ptid, int step, enum target_signal signal)
         never goes through the kernel's trap() function which would
         normally clear it.  */
 
-      regcache_cooked_read_unsigned (current_regcache, I386_EFLAGS_REGNUM,
+      regcache_cooked_read_unsigned (regcache, I386_EFLAGS_REGNUM,
                                     &eflags);
       if (eflags & 0x0100)
-       regcache_cooked_write_unsigned (current_regcache, I386_EFLAGS_REGNUM,
+       regcache_cooked_write_unsigned (regcache, I386_EFLAGS_REGNUM,
                                        eflags & ~0x0100);
 
       request = PT_CONTINUE;
index d50fc2968c791c941291b7beb9a1991cf5627ce7..f42ca0ffc3087aafcff4660d6af3f1c5757c37bf 100644 (file)
@@ -595,7 +595,7 @@ ia64_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw)
     }
 
   store_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask);
-  enable_watchpoints_in_psr (current_regcache);
+  enable_watchpoints_in_psr (get_current_regcache ());
 
   return 0;
 }
@@ -632,7 +632,7 @@ ia64_linux_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
   int tid;
   struct siginfo siginfo;
   ptid_t ptid = inferior_ptid;
-  struct regcache *regcache = current_regcache;
+  struct regcache *regcache = get_current_regcache ();
 
   tid = TIDGET(ptid);
   if (tid == 0)
index 2805e4b4f89f28600f18a4d4b2282a7d10c02668..525cf2fd8e81a1f86dd6c470c44e882638181e2d 100644 (file)
@@ -469,7 +469,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
        {
          sp = push_dummy_code (current_gdbarch, sp, funaddr,
                                using_gcc, args, nargs, values_type,
-                               &real_pc, &bp_addr, current_regcache);
+                               &real_pc, &bp_addr, get_current_regcache ());
          dummy_addr = sp;
        }
       else
@@ -477,7 +477,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
          dummy_addr = sp;
          sp = push_dummy_code (current_gdbarch, sp, funaddr,
                                using_gcc, args, nargs, values_type,
-                               &real_pc, &bp_addr, current_regcache);
+                               &real_pc, &bp_addr, get_current_regcache ());
        }
       break;
     case AT_ENTRY_POINT:
@@ -672,9 +672,9 @@ You must use a pointer to function type variable. Command ignored."), arg_name);
   /* Create the dummy stack frame.  Pass in the call dummy address as,
      presumably, the ABI code knows where, in the call dummy, the
      return address should be pointed.  */
-  sp = gdbarch_push_dummy_call (current_gdbarch, function, current_regcache,
-                               bp_addr, nargs, args, sp, struct_return,
-                               struct_addr);
+  sp = gdbarch_push_dummy_call (current_gdbarch, function,
+                               get_current_regcache (), bp_addr, nargs, args,
+                               sp, struct_return, struct_addr);
 
   /* Set up a frame ID for the dummy frame so we can pass it to
      set_momentary_breakpoint.  We need to give the breakpoint a frame
index 2c1b32f844c384e5e1a1ffc16bdeabf8fc22bdad..1557dc70f419e9d2216acdab1ec6b8fd83cfbddb 100644 (file)
@@ -528,7 +528,8 @@ resume (int step, enum target_signal sig)
   if (breakpoint_here_p (read_pc ()) == permanent_breakpoint_here)
     {
       if (gdbarch_skip_permanent_breakpoint_p (current_gdbarch))
-       gdbarch_skip_permanent_breakpoint (current_gdbarch, current_regcache);
+       gdbarch_skip_permanent_breakpoint (current_gdbarch,
+                                          get_current_regcache ());
       else
        error (_("\
 The program is stopped at a permanent breakpoint, but GDB does not know\n\
@@ -3218,7 +3219,7 @@ Further execution is probably impossible.\n"));
   if (proceed_to_finish)
     /* NB: The copy goes through to the target picking up the value of
        all the registers.  */
-    regcache_cpy (stop_registers, current_regcache);
+    regcache_cpy (stop_registers, get_current_regcache ());
 
   if (stop_stack_dummy)
     {
@@ -3675,7 +3676,7 @@ save_inferior_status (int restore_stack_info)
 
   inf_status->stop_registers = regcache_dup_no_passthrough (stop_registers);
 
-  inf_status->registers = regcache_dup (current_regcache);
+  inf_status->registers = regcache_dup (get_current_regcache ());
 
   inf_status->selected_frame_id = get_frame_id (get_selected_frame (NULL));
   return inf_status;
@@ -3730,7 +3731,7 @@ restore_inferior_status (struct inferior_status *inf_status)
      (and perhaps other times).  */
   if (target_has_execution)
     /* NB: The register write goes through to the target.  */
-    regcache_cpy (current_regcache, inf_status->registers);
+    regcache_cpy (get_current_regcache (), inf_status->registers);
   regcache_xfree (inf_status->registers);
 
   /* FIXME: If we are being called after stopping in a function which
index 0da442a993a40b98a578028da1880ac80c660740..9f0c0d11277eced146b911e91a5c5b61fbdd6b99 100644 (file)
@@ -245,7 +245,7 @@ fork_load_infrun_state (struct fork_info *fp)
   linux_nat_switch_fork (inferior_ptid);
 
   if (fp->savedregs && fp->clobber_regs)
-    regcache_cpy (current_regcache, fp->savedregs);
+    regcache_cpy (get_current_regcache (), fp->savedregs);
 
   registers_changed ();
   reinit_frame_cache ();
@@ -278,7 +278,7 @@ fork_save_infrun_state (struct fork_info *fp, int clobber_regs)
   if (fp->savedregs)
     regcache_xfree (fp->savedregs);
 
-  fp->savedregs = regcache_dup (current_regcache);
+  fp->savedregs = regcache_dup (get_current_regcache ());
   fp->clobber_regs = clobber_regs;
   fp->pc = read_pc ();
 
index c2f67de169866aab2e92411d08d156a8169bfad0..e8cc7c55b575ccf65d6fd78f04647442467ded21 100644 (file)
@@ -2583,19 +2583,26 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
   gdb_fpxregset_t fpxregs;
 #endif
   unsigned long lwp = ptid_get_lwp (ptid);
-  struct gdbarch *gdbarch = current_gdbarch;
+  struct regcache *regcache = get_thread_regcache (ptid);
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
   const struct regset *regset;
   int core_regset_p;
+  struct cleanup *old_chain;
+
+  old_chain = save_inferior_ptid ();
+  inferior_ptid = ptid;
+  target_fetch_registers (regcache, -1);
+  do_cleanups (old_chain);
 
   core_regset_p = gdbarch_regset_from_core_section_p (gdbarch);
   if (core_regset_p
       && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg",
                                                     sizeof (gregs))) != NULL
       && regset->collect_regset != NULL)
-    regset->collect_regset (regset, current_regcache, -1,
+    regset->collect_regset (regset, regcache, -1,
                            &gregs, sizeof (gregs));
   else
-    fill_gregset (current_regcache, &gregs, -1);
+    fill_gregset (regcache, &gregs, -1);
 
   note_data = (char *) elfcore_write_prstatus (obfd,
                                               note_data,
@@ -2607,10 +2614,10 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
       && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2",
                                                     sizeof (fpregs))) != NULL
       && regset->collect_regset != NULL)
-    regset->collect_regset (regset, current_regcache, -1,
+    regset->collect_regset (regset, regcache, -1,
                            &fpregs, sizeof (fpregs));
   else
-    fill_fpregset (current_regcache, &fpregs, -1);
+    fill_fpregset (regcache, &fpregs, -1);
 
   note_data = (char *) elfcore_write_prfpreg (obfd,
                                              note_data,
@@ -2622,10 +2629,10 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid,
       && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg-xfp",
                                                     sizeof (fpxregs))) != NULL
       && regset->collect_regset != NULL)
-    regset->collect_regset (regset, current_regcache, -1,
+    regset->collect_regset (regset, regcache, -1,
                            &fpxregs, sizeof (fpxregs));
   else
-    fill_fpxregset (current_regcache, &fpxregs, -1);
+    fill_fpxregset (regcache, &fpxregs, -1);
 
   note_data = (char *) elfcore_write_prxfpreg (obfd,
                                               note_data,
@@ -2650,21 +2657,12 @@ static int
 linux_nat_corefile_thread_callback (struct lwp_info *ti, void *data)
 {
   struct linux_nat_corefile_thread_data *args = data;
-  ptid_t saved_ptid = inferior_ptid;
 
-  inferior_ptid = ti->ptid;
-  registers_changed ();
-  /* FIXME should not be necessary; fill_gregset should do it automatically. */
-  target_fetch_registers (current_regcache, -1);
   args->note_data = linux_nat_do_thread_registers (args->obfd,
                                                   ti->ptid,
                                                   args->note_data,
                                                   args->note_size);
   args->num_notes++;
-  inferior_ptid = saved_ptid;
-  registers_changed ();
-  /* FIXME should not be necessary; fill_gregset should do it automatically. */
-  target_fetch_registers (current_regcache, -1);
 
   return 0;
 }
@@ -2675,15 +2673,11 @@ static char *
 linux_nat_do_registers (bfd *obfd, ptid_t ptid,
                        char *note_data, int *note_size)
 {
-  registers_changed ();
-  /* FIXME should not be necessary; fill_gregset should do it automatically. */
-  target_fetch_registers (current_regcache, -1);
   return linux_nat_do_thread_registers (obfd,
                                        ptid_build (ptid_get_pid (inferior_ptid),
                                                    ptid_get_pid (inferior_ptid),
                                                    0),
                                        note_data, note_size);
-  return note_data;
 }
 
 /* Fills the "to_make_corefile_note" target vector.  Builds the note
index d66e0d9554a26da755b4259d7eaf73e2c280e7f0..2ff2685a608d7bf7a377fcbfe8d448d2904158d5 100644 (file)
@@ -2535,6 +2535,7 @@ m32c_virtual_frame_pointer (CORE_ADDR pc,
   CORE_ADDR func_addr, func_end, sal_end;
   struct m32c_prologue p;
 
+  struct regcache *regcache = get_current_regcache ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   
   if (!find_pc_partial_function (pc, &name, &func_addr, &func_end))
@@ -2544,15 +2545,15 @@ m32c_virtual_frame_pointer (CORE_ADDR pc,
   switch (p.kind)
     {
     case prologue_with_frame_ptr:
-      *frame_regnum = m32c_banked_register (tdep->fb, current_regcache)->num;
+      *frame_regnum = m32c_banked_register (tdep->fb, regcache)->num;
       *frame_offset = p.frame_ptr_offset;
       break;
     case prologue_sans_frame_ptr:
-      *frame_regnum = m32c_banked_register (tdep->sp, current_regcache)->num;
+      *frame_regnum = m32c_banked_register (tdep->sp, regcache)->num;
       *frame_offset = p.frame_size;
       break;
     default:
-      *frame_regnum = m32c_banked_register (tdep->sp, current_regcache)->num;
+      *frame_regnum = m32c_banked_register (tdep->sp, regcache)->num;
       *frame_offset = 0;
       break;
     }
index fd0398985477ca588eb64569f72df0428f6ebcec..b42b02c8a4432a13a0b7adc225bc2a5827cfedbc 100644 (file)
@@ -852,7 +852,7 @@ current_me_module ()
   if (target_has_registers)
     {
       ULONGEST regval;
-      regcache_cooked_read_unsigned (current_regcache,
+      regcache_cooked_read_unsigned (get_current_regcache (),
                                     MEP_MODULE_REGNUM, &regval);
       return regval;
     }
@@ -875,7 +875,7 @@ current_options ()
   if (target_has_registers)
     {
       ULONGEST regval;
-      regcache_cooked_read_unsigned (current_regcache,
+      regcache_cooked_read_unsigned (get_current_regcache (),
                                     MEP_OPT_REGNUM, &regval);
       return regval;
     }
index 1193b0c2042cced1181ce9e2bd5be1b2bcd52e96..9c5aeb9f221b8853c0de3ec9221b5629aca8c885 100644 (file)
@@ -634,7 +634,7 @@ mi_cmd_data_write_register_values (char *command, char **argv, int argc)
          value = parse_and_eval_address (argv[i + 1]);
 
          /* Write it down.  */
-         regcache_cooked_write_signed (current_regcache, regnum, value);
+         regcache_cooked_write_signed (get_current_regcache (), regnum, value);
        }
       else
        {
index 0597191f52fc4e77a6c131b2184917d0c7f31106..3ef2fc0ad5d783ec70c186411ea4c545f81472b4 100644 (file)
@@ -4434,7 +4434,7 @@ deprecated_mips_set_processor_regs_hack (void)
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   ULONGEST prid;
 
-  regcache_cooked_read_unsigned (current_regcache,
+  regcache_cooked_read_unsigned (get_current_regcache (),
                                 MIPS_PRID_REGNUM, &prid);
   if ((prid & ~0xf) == 0x700)
     tdep->mips_processor_reg_names = mips_r3041_reg_names;
index 30493f4270b324381a526c0df3333e6ec1c55a67..efcd047f23c94ebdcb48143acf76889587b2f5f2 100644 (file)
@@ -1109,10 +1109,10 @@ monitor_wait (ptid_t ptid, struct target_waitstatus *status)
     }
 
   if (current_monitor->register_pattern)
-    parse_register_dump (current_regcache, buf, resp_len);
+    parse_register_dump (get_current_regcache (), buf, resp_len);
 #else
   monitor_debug ("Wait fetching registers after stop\n");
-  monitor_dump_regs (current_regcache);
+  monitor_dump_regs (get_current_regcache ());
 #endif
 
   status->kind = TARGET_WAITKIND_STOPPED;
index d38ade538bb60f2bda071d97d8d6cc716b202cbb..630100dfbf23ebc14806a699670336fab5919da6 100644 (file)
@@ -257,11 +257,13 @@ ps_err_e
 ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
 {
   struct cleanup *old_chain = save_inferior_ptid ();
+  struct regcache *regcache;
 
   inferior_ptid = BUILD_LWP (lwpid, ph->pid);
+  regcache = get_thread_regcache (inferior_ptid);
 
-  target_fetch_registers (current_regcache, -1);
-  fill_gregset (current_regcache, (gdb_gregset_t *) gregset, -1);
+  target_fetch_registers (regcache, -1);
+  fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
 
   do_cleanups (old_chain);
   return PS_OK;
@@ -274,11 +276,13 @@ ps_err_e
 ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset)
 {
   struct cleanup *old_chain = save_inferior_ptid ();
+  struct regcache *regcache;
 
   inferior_ptid = BUILD_LWP (lwpid, ph->pid);
+  regcache = get_thread_regcache (inferior_ptid);
 
-  supply_gregset (current_regcache, (const gdb_gregset_t *) gregset);
-  target_store_registers (current_regcache, -1);
+  supply_gregset (regcache, (const gdb_gregset_t *) gregset);
+  target_store_registers (regcache, -1);
 
   do_cleanups (old_chain);
   return PS_OK;
@@ -292,11 +296,13 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
               gdb_prfpregset_t *fpregset)
 {
   struct cleanup *old_chain = save_inferior_ptid ();
+  struct regcache *regcache;
 
   inferior_ptid = BUILD_LWP (lwpid, ph->pid);
+  regcache = get_thread_regcache (inferior_ptid);
 
-  target_fetch_registers (current_regcache, -1);
-  fill_fpregset (current_regcache, (gdb_fpregset_t *) fpregset, -1);
+  target_fetch_registers (regcache, -1);
+  fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
 
   do_cleanups (old_chain);
   return PS_OK;
@@ -310,11 +316,13 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
               const gdb_prfpregset_t *fpregset)
 {
   struct cleanup *old_chain = save_inferior_ptid ();
+  struct regcache *regcache;
 
   inferior_ptid = BUILD_LWP (lwpid, ph->pid);
+  regcache = get_thread_regcache (inferior_ptid);
 
-  supply_fpregset (current_regcache, (const gdb_fpregset_t *) fpregset);
-  target_store_registers (current_regcache, -1);
+  supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
+  target_store_registers (regcache, -1);
 
   do_cleanups (old_chain);
   return PS_OK;
index cbb59b87bcc2162ddcef953f699094685af16e08..b3a3fc27174db1e8f9cef98c0293af87b8a70bad 100644 (file)
@@ -6013,13 +6013,14 @@ static char *
 procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
                            char *note_data, int *note_size)
 {
+  struct regcache *regcache = get_thread_regcache (ptid);
   gdb_gregset_t gregs;
   gdb_fpregset_t fpregs;
   unsigned long merged_pid;
 
   merged_pid = TIDGET (ptid) << 16 | PIDGET (ptid);
 
-  fill_gregset (current_regcache, &gregs, -1);
+  fill_gregset (regcache, &gregs, -1);
 #if defined (UNIXWARE)
   note_data = (char *) elfcore_write_lwpstatus (obfd,
                                                note_data,
@@ -6035,7 +6036,7 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid,
                                               stop_signal,
                                               &gregs);
 #endif
-  fill_fpregset (current_regcache, &fpregs, -1);
+  fill_fpregset (regcache, &fpregs, -1);
   note_data = (char *) elfcore_write_prfpreg (obfd,
                                              note_data,
                                              note_size,
@@ -6106,7 +6107,7 @@ procfs_make_note_section (bfd *obfd, int *note_size)
                                               psargs);
 
 #ifdef UNIXWARE
-  fill_gregset (current_regcache, &gregs, -1);
+  fill_gregset (get_current_regcache (), &gregs, -1);
   note_data = elfcore_write_pstatus (obfd, note_data, note_size,
                                     PIDGET (inferior_ptid),
                                     stop_signal, &gregs);
index 5a1073bbef59323bb2f332cfc93ca127b166ecd7..6c0fca82acaf0a8c8b2a626970babbc4413862ff 100644 (file)
@@ -203,6 +203,9 @@ struct regcache
      regcache_cpy().  The actual contents are determined by the
      reggroup_save and reggroup_restore methods.  */
   int readonly_p;
+  /* If this is a read-write cache, which thread's registers is
+     it connected to?  */
+  ptid_t ptid;
 };
 
 struct regcache *
@@ -219,6 +222,7 @@ regcache_xmalloc (struct gdbarch *gdbarch)
   regcache->register_valid_p
     = XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte);
   regcache->readonly_p = 1;
+  regcache->ptid = minus_one_ptid;
   return regcache;
 }
 
@@ -357,9 +361,9 @@ regcache_cpy_no_passthrough (struct regcache *dst, struct regcache *src)
   gdb_assert (src != NULL && dst != NULL);
   gdb_assert (src->descr->gdbarch == dst->descr->gdbarch);
   /* NOTE: cagney/2002-05-17: Don't let the caller do a no-passthrough
-     move of data into the current_regcache().  Doing this would be
+     move of data into the current regcache.  Doing this would be
      silly - it would mean that valid_p would be completely invalid.  */
-  gdb_assert (dst != current_regcache);
+  gdb_assert (dst->readonly_p);
   memcpy (dst->registers, src->registers, dst->descr->sizeof_raw_registers);
   memcpy (dst->register_valid_p, src->register_valid_p,
          dst->descr->sizeof_raw_register_valid_p);
@@ -369,7 +373,6 @@ struct regcache *
 regcache_dup (struct regcache *src)
 {
   struct regcache *newbuf;
-  gdb_assert (current_regcache != NULL);
   newbuf = regcache_xmalloc (src->descr->gdbarch);
   regcache_cpy (newbuf, src);
   return newbuf;
@@ -379,7 +382,6 @@ struct regcache *
 regcache_dup_no_passthrough (struct regcache *src)
 {
   struct regcache *newbuf;
-  gdb_assert (current_regcache != NULL);
   newbuf = regcache_xmalloc (src->descr->gdbarch);
   regcache_cpy_no_passthrough (newbuf, src);
   return newbuf;
@@ -412,16 +414,38 @@ regcache_invalidate (struct regcache *regcache, int regnum)
 /* Global structure containing the current regcache.  */
 /* FIXME: cagney/2002-05-11: The two global arrays registers[] and
    deprecated_register_valid[] currently point into this structure.  */
-struct regcache *current_regcache;
+static struct regcache *current_regcache;
 
 /* NOTE: this is a write-through cache.  There is no "dirty" bit for
    recording if the register values have been changed (eg. by the
    user).  Therefore all registers must be written back to the
    target when appropriate.  */
 
-/* The thread/process associated with the current set of registers. */
+struct regcache *get_thread_regcache (ptid_t ptid)
+{
+  /* NOTE: uweigand/2007-05-05:  We need to detect the thread's
+     current architecture at this point.  */
+  struct gdbarch *thread_gdbarch = current_gdbarch;
+
+  if (current_regcache && ptid_equal (current_regcache->ptid, ptid)
+      && get_regcache_arch (current_regcache) == thread_gdbarch)
+    return current_regcache;
+
+  if (current_regcache)
+    regcache_xfree (current_regcache);
+
+  current_regcache = regcache_xmalloc (thread_gdbarch);
+  current_regcache->readonly_p = 0;
+  current_regcache->ptid = ptid;
+
+  return current_regcache;
+}
+
+struct regcache *get_current_regcache (void)
+{
+  return get_thread_regcache (inferior_ptid);
+}
 
-static ptid_t registers_ptid;
 
 /* Observer for the target_changed event.  */
 
@@ -447,7 +471,8 @@ registers_changed (void)
 {
   int i;
 
-  registers_ptid = pid_to_ptid (-1);
+  regcache_xfree (current_regcache);
+  current_regcache = NULL;
 
   /* Force cleanup of any alloca areas if using C alloca instead of
      a builtin alloca.  This particular call is used to clean up
@@ -455,9 +480,6 @@ registers_changed (void)
      during lengthy interactions between gdb and the target before
      gdb gives control to the user (ie watchpoints).  */
   alloca (0);
-
-  for (i = 0; i < current_regcache->descr->nr_raw_registers; i++)
-    regcache_invalidate (current_regcache, i);
 }
 
 
@@ -472,14 +494,13 @@ regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf)
      On the bright side, at least there is a regcache object.  */
   if (!regcache->readonly_p)
     {
-      gdb_assert (regcache == current_regcache);
-      if (! ptid_equal (registers_ptid, inferior_ptid))
+      if (!regcache_valid_p (regcache, regnum))
        {
-         registers_changed ();
-         registers_ptid = inferior_ptid;
+         struct cleanup *old_chain = save_inferior_ptid ();
+         inferior_ptid = regcache->ptid;
+         target_fetch_registers (regcache, regnum);
+         do_cleanups (old_chain);
        }
-      if (!regcache_valid_p (regcache, regnum))
-       target_fetch_registers (regcache, regnum);
 #if 0
       /* FIXME: cagney/2004-08-07: At present a number of targets
         forget (or didn't know that they needed) to set this leading to
@@ -615,6 +636,8 @@ void
 regcache_raw_write (struct regcache *regcache, int regnum,
                    const gdb_byte *buf)
 {
+  struct cleanup *old_chain;
+
   gdb_assert (regcache != NULL && buf != NULL);
   gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
   gdb_assert (!regcache->readonly_p);
@@ -624,14 +647,6 @@ regcache_raw_write (struct regcache *regcache, int regnum,
   if (gdbarch_cannot_store_register (current_gdbarch, regnum))
     return;
 
-  /* Make certain that the correct cache is selected.  */
-  gdb_assert (regcache == current_regcache);
-  if (! ptid_equal (registers_ptid, inferior_ptid))
-    {
-      registers_changed ();
-      registers_ptid = inferior_ptid;
-    }
-
   /* If we have a valid copy of the register, and new value == old
      value, then don't bother doing the actual store. */
   if (regcache_valid_p (regcache, regnum)
@@ -639,11 +654,16 @@ regcache_raw_write (struct regcache *regcache, int regnum,
                  regcache->descr->sizeof_register[regnum]) == 0))
     return;
 
+  old_chain = save_inferior_ptid ();
+  inferior_ptid = regcache->ptid;
+
   target_prepare_to_store (regcache);
   memcpy (register_buffer (regcache, regnum), buf,
          regcache->descr->sizeof_register[regnum]);
   regcache->register_valid_p[regnum] = 1;
   target_store_registers (regcache, regnum);
+
+  do_cleanups (old_chain);
 }
 
 void
@@ -767,15 +787,6 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
   gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
   gdb_assert (!regcache->readonly_p);
 
-  /* FIXME: kettenis/20030828: It shouldn't be necessary to handle
-     CURRENT_REGCACHE specially here.  */
-  if (regcache == current_regcache
-      && !ptid_equal (registers_ptid, inferior_ptid))
-    {
-      registers_changed ();
-      registers_ptid = inferior_ptid;
-    }
-
   regbuf = register_buffer (regcache, regnum);
   size = regcache->descr->sizeof_register[regnum];
 
@@ -820,16 +831,11 @@ regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf)
 CORE_ADDR
 read_pc_pid (ptid_t ptid)
 {
-  struct regcache *regcache = current_regcache;
+  struct regcache *regcache = get_thread_regcache (ptid);
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
 
-  ptid_t saved_inferior_ptid;
   CORE_ADDR pc_val;
 
-  /* In case ptid != inferior_ptid. */
-  saved_inferior_ptid = inferior_ptid;
-  inferior_ptid = ptid;
-
   if (gdbarch_read_pc_p (gdbarch))
     pc_val = gdbarch_read_pc (gdbarch, regcache);
   /* Else use per-frame method on get_current_frame.  */
@@ -842,7 +848,6 @@ read_pc_pid (ptid_t ptid)
   else
     internal_error (__FILE__, __LINE__, _("read_pc_pid: Unable to find PC"));
 
-  inferior_ptid = saved_inferior_ptid;
   return pc_val;
 }
 
@@ -855,15 +860,9 @@ read_pc (void)
 void
 write_pc_pid (CORE_ADDR pc, ptid_t ptid)
 {
-  struct regcache *regcache = current_regcache;
+  struct regcache *regcache = get_thread_regcache (ptid);
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
 
-  ptid_t saved_inferior_ptid;
-
-  /* In case ptid != inferior_ptid. */
-  saved_inferior_ptid = inferior_ptid;
-  inferior_ptid = ptid;
-
   if (gdbarch_write_pc_p (gdbarch))
     gdbarch_write_pc (gdbarch, regcache, pc);
   else if (PC_REGNUM >= 0)
@@ -871,8 +870,6 @@ write_pc_pid (CORE_ADDR pc, ptid_t ptid)
   else
     internal_error (__FILE__, __LINE__,
                    _("write_pc_pid: Unable to update PC"));
-
-  inferior_ptid = saved_inferior_ptid;
 }
 
 void
@@ -891,13 +888,6 @@ reg_flush_command (char *command, int from_tty)
     printf_filtered (_("Register cache flushed.\n"));
 }
 
-static void
-build_regcache (void)
-{
-  current_regcache = regcache_xmalloc (current_gdbarch);
-  current_regcache->readonly_p = 0;
-}
-
 static void
 dump_endian_bytes (struct ui_file *file, enum bfd_endian endian,
                   const unsigned char *buf, long len)
@@ -1162,18 +1152,12 @@ void
 _initialize_regcache (void)
 {
   regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
-  DEPRECATED_REGISTER_GDBARCH_SWAP (current_regcache);
-  deprecated_register_gdbarch_swap (NULL, 0, build_regcache);
 
   observer_attach_target_changed (regcache_observer_target_changed);
 
   add_com ("flushregs", class_maintenance, reg_flush_command,
           _("Force gdb to flush its register cache (maintainer command)"));
 
-   /* Initialize the thread/process associated with the current set of
-      registers.  For now, -1 is special, and means `no current process'.  */
-  registers_ptid = pid_to_ptid (-1);
-
   add_cmd ("registers", class_maintenance, maintenance_print_registers, _("\
 Print the internal register configuration.\n\
 Takes an optional file parameter."), &maintenanceprintlist);
index d8e3a433d4358689339ab53ae25e108eae2292fe..a5f4fdb031640aebac1fb0ac8a04663f30ef4350 100644 (file)
@@ -26,7 +26,8 @@
 struct regcache;
 struct gdbarch;
 
-extern struct regcache *current_regcache;
+extern struct regcache *get_current_regcache (void);
+extern struct regcache *get_thread_regcache (ptid_t ptid);
 
 void regcache_xfree (struct regcache *regcache);
 struct cleanup *make_cleanup_regcache_xfree (struct regcache *regcache);
index a5f3cbf94a6431ff8309f0d30ed5ab7d0eb859e2..0acc606253bb19caebc4f07862390a0206d81eae 100644 (file)
@@ -1755,19 +1755,20 @@ mips_wait (ptid_t ptid, struct target_waitstatus *status)
                    &rpc, &rfp, &rsp, flags);
   if (nfields >= 3)
     {
+      struct regcache *regcache = get_current_regcache ();
       char buf[MAX_REGISTER_SIZE];
 
       store_unsigned_integer (buf, register_size (current_gdbarch, PC_REGNUM), rpc);
-      regcache_raw_supply (current_regcache, PC_REGNUM, buf);
+      regcache_raw_supply (regcache, PC_REGNUM, buf);
 
       store_unsigned_integer (buf, register_size (current_gdbarch, PC_REGNUM), rfp);
-      regcache_raw_supply (current_regcache, 30, buf); /* This register they are avoiding and so it is unnamed */
+      regcache_raw_supply (regcache, 30, buf); /* This register they are avoiding and so it is unnamed */
 
       store_unsigned_integer (buf, register_size (current_gdbarch, SP_REGNUM), rsp);
-      regcache_raw_supply (current_regcache, SP_REGNUM, buf);
+      regcache_raw_supply (regcache, SP_REGNUM, buf);
 
       store_unsigned_integer (buf, register_size (current_gdbarch, DEPRECATED_FP_REGNUM), 0);
-      regcache_raw_supply (current_regcache, DEPRECATED_FP_REGNUM, buf);
+      regcache_raw_supply (regcache, DEPRECATED_FP_REGNUM, buf);
 
       if (nfields == 9)
        {
index 9fa700e5857b3574f23b098fac9381b20474e869..f4f267b420d0be43f5e3fe0de8b97dd16e9baa46 100644 (file)
@@ -3232,7 +3232,7 @@ Packet: '%s'\n"),
                    if (fieldsize < register_size (current_gdbarch,
                                                   reg->regnum))
                      warning (_("Remote reply is too short: %s"), buf);
-                   regcache_raw_supply (current_regcache,
+                   regcache_raw_supply (get_current_regcache (),
                                         reg->regnum, regs);
                  }
 
@@ -3429,7 +3429,8 @@ Packet: '%s'\n"),
                    if (fieldsize < register_size (current_gdbarch,
                                                   reg->regnum))
                      warning (_("Remote reply is too short: %s"), buf);
-                   regcache_raw_supply (current_regcache, reg->regnum, regs);
+                   regcache_raw_supply (get_current_regcache (),
+                                        reg->regnum, regs);
                  }
 
                if (*p++ != ';')
index 4224d2832621a9eb52023fc6b6c33754ab7b0e26..2cd66dbd2d34ce6b593a92b591c0f5a7d76559a6 100644 (file)
@@ -1087,16 +1087,18 @@ ps_err_e
 ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
 {
   struct cleanup *old_chain;
+  struct regcache *regcache;
 
   old_chain = save_inferior_ptid ();
 
   inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+  regcache = get_thread_regcache (inferior_ptid);
 
   if (target_has_execution)
-    procfs_ops.to_fetch_registers (current_regcache, -1);
+    procfs_ops.to_fetch_registers (regcache, -1);
   else
-    orig_core_ops.to_fetch_registers (current_regcache, -1);
-  fill_gregset (current_regcache, (gdb_gregset_t *) gregset, -1);
+    orig_core_ops.to_fetch_registers (regcache, -1);
+  fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
 
   do_cleanups (old_chain);
 
@@ -1110,16 +1112,18 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
             const prgregset_t gregset)
 {
   struct cleanup *old_chain;
+  struct regcache *regcache;
 
   old_chain = save_inferior_ptid ();
 
   inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+  regcache = get_thread_regcache (inferior_ptid);
 
-  supply_gregset (current_regcache, (const gdb_gregset_t *) gregset);
+  supply_gregset (regcache, (const gdb_gregset_t *) gregset);
   if (target_has_execution)
-    procfs_ops.to_store_registers (current_regcache, -1);
+    procfs_ops.to_store_registers (regcache, -1);
   else
-    orig_core_ops.to_store_registers (current_regcache, -1);
+    orig_core_ops.to_store_registers (regcache, -1);
 
   do_cleanups (old_chain);
 
@@ -1219,16 +1223,18 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
               prfpregset_t *fpregset)
 {
   struct cleanup *old_chain;
+  struct regcache *regcache;
 
   old_chain = save_inferior_ptid ();
 
   inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+  regcache = get_thread_regcache (inferior_ptid);
 
   if (target_has_execution)
-    procfs_ops.to_fetch_registers (current_regcache, -1);
+    procfs_ops.to_fetch_registers (regcache, -1);
   else
-    orig_core_ops.to_fetch_registers (current_regcache, -1);
-  fill_fpregset (current_regcache, (gdb_fpregset_t *) fpregset, -1);
+    orig_core_ops.to_fetch_registers (regcache, -1);
+  fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
 
   do_cleanups (old_chain);
 
@@ -1242,16 +1248,18 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
               const prfpregset_t * fpregset)
 {
   struct cleanup *old_chain;
+  struct regcache *regcache;
 
   old_chain = save_inferior_ptid ();
 
   inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+  regcache = get_thread_regcache (inferior_ptid);
 
-  supply_fpregset (current_regcache, (const gdb_fpregset_t *) fpregset);
+  supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
   if (target_has_execution)
-    procfs_ops.to_store_registers (current_regcache, -1);
+    procfs_ops.to_store_registers (regcache, -1);
   else
-    orig_core_ops.to_store_registers (current_regcache, -1);
+    orig_core_ops.to_store_registers (regcache, -1);
 
   do_cleanups (old_chain);
 
index 2bc5036e0fb8d93798b8e2e039f7a915ebec6766..f10882d92f46a7c324b5699e8befccfdad273429 100644 (file)
@@ -1850,7 +1850,7 @@ If you continue, the return value that you specified will be ignored.\n";
                                        NULL, NULL, NULL)
                  == RETURN_VALUE_REGISTER_CONVENTION);
       gdbarch_return_value (current_gdbarch, return_type,
-                           current_regcache, NULL /*read*/,
+                           get_current_regcache (), NULL /*read*/,
                            value_contents (return_value) /*write*/);
     }
 
index 13f90ee675dbf6d3aac85bbeae76114118505bf1..c5627c79fb03a8190d8367b98877873303bcfa62 100644 (file)
@@ -1318,7 +1318,7 @@ win32_resume (ptid_t ptid, int step, enum target_signal sig)
       if (step)
        {
          /* Single step by setting t bit */
-         win32_fetch_inferior_registers (current_regcache, PS_REGNUM);
+         win32_fetch_inferior_registers (get_current_regcache (), PS_REGNUM);
          th->context.EFlags |= FLAG_TRACE_BIT;
        }
 
index 13f90ee675dbf6d3aac85bbeae76114118505bf1..c5627c79fb03a8190d8367b98877873303bcfa62 100644 (file)
@@ -1318,7 +1318,7 @@ win32_resume (ptid_t ptid, int step, enum target_signal sig)
       if (step)
        {
          /* Single step by setting t bit */
-         win32_fetch_inferior_registers (current_regcache, PS_REGNUM);
+         win32_fetch_inferior_registers (get_current_regcache (), PS_REGNUM);
          th->context.EFlags |= FLAG_TRACE_BIT;
        }