summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2007-06-16 17:16:26 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2007-06-16 17:16:26 +0000
commit954e927b912047942c40cfb32168ac48267fb464 (patch)
tree1ffa7bf490aead5fcb0e1cd72dcb122cf0ac663f /gdb
parentf3cf9eafd94420b23bb26aee35d022a597fb745f (diff)
downloadgdb-954e927b912047942c40cfb32168ac48267fb464.tar.gz
* 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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog68
-rw-r--r--gdb/bsd-kvm.c6
-rw-r--r--gdb/corelow.c2
-rw-r--r--gdb/fbsd-nat.c2
-rw-r--r--gdb/frame.c10
-rw-r--r--gdb/frv-tdep.c6
-rw-r--r--gdb/i386-linux-nat.c6
-rw-r--r--gdb/i386fbsd-nat.c5
-rw-r--r--gdb/ia64-linux-nat.c4
-rw-r--r--gdb/infcall.c10
-rw-r--r--gdb/infrun.c9
-rw-r--r--gdb/linux-fork.c4
-rw-r--r--gdb/linux-nat.c34
-rw-r--r--gdb/m32c-tdep.c7
-rw-r--r--gdb/mep-tdep.c4
-rw-r--r--gdb/mi/mi-main.c2
-rw-r--r--gdb/mips-tdep.c2
-rw-r--r--gdb/monitor.c4
-rw-r--r--gdb/proc-service.c24
-rw-r--r--gdb/procfs.c7
-rw-r--r--gdb/regcache.c110
-rw-r--r--gdb/regcache.h3
-rw-r--r--gdb/remote-mips.c9
-rw-r--r--gdb/remote.c5
-rw-r--r--gdb/sol-thread.c32
-rw-r--r--gdb/stack.c2
-rw-r--r--gdb/win32-nat.c2
27 files changed, 223 insertions, 156 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ebb43c9ce8b..8b086d75106 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c
index 910b3d0a197..5e4c57d9c6d 100644
--- a/gdb/bsd-kvm.c
+++ b/gdb/bsd-kvm.c
@@ -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);
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 82e6d7d9833..d85b14b4e0a 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -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 ();
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 06e2151b471..cef15ccbf75 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -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;
diff --git a/gdb/frame.c b/gdb/frame.c
index 42a44d42219..4e26f5a7832 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -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. */
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 7cb7b328789..b339bb9a1bf 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -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;
}
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 1541cfc8904..7a2be097eb5 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -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)
diff --git a/gdb/i386fbsd-nat.c b/gdb/i386fbsd-nat.c
index 111170413c0..c3bdf53c3eb 100644
--- a/gdb/i386fbsd-nat.c
+++ b/gdb/i386fbsd-nat.c
@@ -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;
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index d50fc2968c7..f42ca0ffc30 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -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)
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 2805e4b4f89..525cf2fd8e8 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -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
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 2c1b32f844c..1557dc70f41 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -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
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 0da442a993a..9f0c0d11277 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -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 ();
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index c2f67de1698..e8cc7c55b57 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -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
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index d66e0d9554a..2ff2685a608 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -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;
}
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index fd039898547..b42b02c8a44 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -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;
}
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 1193b0c2042..9c5aeb9f221 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -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
{
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 0597191f52f..3ef2fc0ad5d 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -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;
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 30493f4270b..efcd047f23c 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -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;
diff --git a/gdb/proc-service.c b/gdb/proc-service.c
index d38ade538bb..630100dfbf2 100644
--- a/gdb/proc-service.c
+++ b/gdb/proc-service.c
@@ -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;
diff --git a/gdb/procfs.c b/gdb/procfs.c
index cbb59b87bcc..b3a3fc27174 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -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);
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 5a1073bbef5..6c0fca82aca 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -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
@@ -892,13 +889,6 @@ reg_flush_command (char *command, int from_tty)
}
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);
diff --git a/gdb/regcache.h b/gdb/regcache.h
index d8e3a433d43..a5f4fdb0316 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -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);
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index a5f3cbf94a6..0acc606253b 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -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)
{
diff --git a/gdb/remote.c b/gdb/remote.c
index 9fa700e5857..f4f267b420d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -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++ != ';')
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 4224d283262..2cd66dbd2d3 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -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);
diff --git a/gdb/stack.c b/gdb/stack.c
index 2bc5036e0fb..f10882d92f4 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -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*/);
}
diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c
index 13f90ee675d..c5627c79fb0 100644
--- a/gdb/win32-nat.c
+++ b/gdb/win32-nat.c
@@ -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;
}