This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] Eliminate current_regcache global variable
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 7 Jun 2007 23:19:19 +0200 (CEST)
- Subject: [rfc] Eliminate current_regcache global variable
Hello,
as a follow-on to the patch set eliminating read_register, this patch
gets rid of the global current_regcache variable, and makes a first step
into the direction of real per-thread register caches.
The patch introduces a new routine
struct regcache *get_thread_regcache (ptid_t ptid);
that can be used to retrieve a register cache for the given thread.
The ptid is stored within the regcache object, and is automatically
used when calling target routines to fetch or store registers.
A second routine
struct regcache *get_current_regcache (void);
is simply a shortcut for get_thread_regcache (inferior_ptid).
All remaining users of the current_regcache global variable are modified
to use get_thread_regcache or get_current_regcache.
Note that internally to regcache.c, there is still a static variable
current_regcache. The reason for this is that we still only actually
cache a single thread's register set, because we do not yet have
infrastructure in place to selectively invalidate a specific thread's
register set. Thus, for now, the registers_changed routine will
continue to invalidate the (single) actually cached set of values.
Future development directions:
- Actually cache multiple threads, presumably by storing a regcache
object within the thread object, and fixing the invalidation issues.
- Currently we still need to reset inferior_ptid before calling
target_fetch_registers or target_store_registers. Now that the
regcache object that is passed down into this functions itself
holds the correct ptid, this shouldn't be necessary any more.
We should change the target_fetch/store_register implementations
to operated on the regcache's ptid instead of inferior_ptid.
Even so, the patch is already valuable as is removes current_regcache
as a gdbarch-swapped variable. Getting rid of these is the next
important step to allow having multiple active architectures at
the same time.
Tested in conjunction with the read_register patch set on powerpc64-linux,
powerpc-ibm-aix5.3.0.0, spu-elf, s390-ibm-linux, s390x-ibm-linux, i386-linux,
and ia64-linux.
Bye,
Ulrich
ChangeLog:
* 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.
diff -urNp gdb-orig/gdb/bsd-kvm.c gdb-head/gdb/bsd-kvm.c
--- gdb-orig/gdb/bsd-kvm.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/bsd-kvm.c 2007-06-06 19:49:08.425097670 +0200
@@ -91,7 +91,7 @@ bsd_kvm_open (char *filename, int from_t
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 -urNp gdb-orig/gdb/corelow.c gdb-head/gdb/corelow.c
--- gdb-orig/gdb/corelow.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/corelow.c 2007-06-06 19:49:08.430096950 +0200
@@ -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 -urNp gdb-orig/gdb/fbsd-nat.c gdb-head/gdb/fbsd-nat.c
--- gdb-orig/gdb/fbsd-nat.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/fbsd-nat.c 2007-06-06 19:49:08.434096375 +0200
@@ -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 -urNp gdb-orig/gdb/frame.c gdb-head/gdb/frame.c
--- gdb-orig/gdb/frame.c 2007-06-06 17:25:20.078646000 +0200
+++ gdb-head/gdb/frame.c 2007-06-06 19:49:08.441095368 +0200
@@ -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 *f
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_A
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 -urNp gdb-orig/gdb/frv-tdep.c gdb-head/gdb/frv-tdep.c
--- gdb-orig/gdb/frv-tdep.c 2007-06-06 19:48:10.715628145 +0200
+++ gdb-head/gdb/frv-tdep.c 2007-06-06 19:49:08.448094360 +0200
@@ -112,17 +112,19 @@ frv_fdpic_loadmap_addresses (struct gdba
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 -urNp gdb-orig/gdb/i386fbsd-nat.c gdb-head/gdb/i386fbsd-nat.c
--- gdb-orig/gdb/i386fbsd-nat.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/i386fbsd-nat.c 2007-06-06 19:49:08.452093785 +0200
@@ -49,6 +49,7 @@ i386fbsd_resume (ptid_t ptid, int step,
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,
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 -urNp gdb-orig/gdb/i386-linux-nat.c gdb-head/gdb/i386-linux-nat.c
--- gdb-orig/gdb/i386-linux-nat.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/i386-linux-nat.c 2007-06-06 19:49:08.457093065 +0200
@@ -736,14 +736,12 @@ i386_linux_resume (ptid_t ptid, int step
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
@@ -782,8 +780,6 @@ i386_linux_resume (ptid_t ptid, int step
write_memory (addr, (gdb_byte *) &eflags, 4);
}
}
-
- do_cleanups (old_chain);
}
if (ptrace (request, pid, 0, target_signal_to_host (signal)) == -1)
diff -urNp gdb-orig/gdb/ia64-linux-nat.c gdb-head/gdb/ia64-linux-nat.c
--- gdb-orig/gdb/ia64-linux-nat.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/ia64-linux-nat.c 2007-06-06 19:49:08.462092346 +0200
@@ -595,7 +595,7 @@ ia64_linux_insert_watchpoint (CORE_ADDR
}
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
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 -urNp gdb-orig/gdb/infcall.c gdb-head/gdb/infcall.c
--- gdb-orig/gdb/infcall.c 2007-06-06 19:47:16.366207339 +0200
+++ gdb-head/gdb/infcall.c 2007-06-06 19:49:08.479089900 +0200
@@ -469,7 +469,7 @@ call_function_by_hand (struct value *fun
{
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 *fun
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
/* 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 -urNp gdb-orig/gdb/infrun.c gdb-head/gdb/infrun.c
--- gdb-orig/gdb/infrun.c 2007-06-06 19:46:31.228791788 +0200
+++ gdb-head/gdb/infrun.c 2007-06-06 19:49:08.501086735 +0200
@@ -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\
@@ -3211,7 +3212,7 @@ Further execution is probably impossible
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)
{
@@ -3668,7 +3669,7 @@ save_inferior_status (int restore_stack_
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;
@@ -3723,7 +3724,7 @@ restore_inferior_status (struct inferior
(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 -urNp gdb-orig/gdb/linux-fork.c gdb-head/gdb/linux-fork.c
--- gdb-orig/gdb/linux-fork.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/linux-fork.c 2007-06-06 19:49:08.544080548 +0200
@@ -245,7 +245,7 @@ fork_load_infrun_state (struct fork_info
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
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 -urNp gdb-orig/gdb/linux-nat.c gdb-head/gdb/linux-nat.c
--- gdb-orig/gdb/linux-nat.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/linux-nat.c 2007-06-06 19:49:08.553079253 +0200
@@ -2580,19 +2580,26 @@ linux_nat_do_thread_registers (bfd *obfd
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;
+ ptid_t saved_ptid;
+
+ saved_ptid = inferior_ptid;
+ inferior_ptid = ptid;
+ target_fetch_registers (regcache, -1);
+ inferior_ptid = saved_ptid;
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,
@@ -2604,10 +2611,10 @@ linux_nat_do_thread_registers (bfd *obfd
&& (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,
@@ -2619,10 +2626,10 @@ linux_nat_do_thread_registers (bfd *obfd
&& (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,
@@ -2647,21 +2654,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;
}
@@ -2672,15 +2670,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 -urNp gdb-orig/gdb/m32c-tdep.c gdb-head/gdb/m32c-tdep.c
--- gdb-orig/gdb/m32c-tdep.c 2007-06-06 19:41:42.711574493 +0200
+++ gdb-head/gdb/m32c-tdep.c 2007-06-06 19:49:08.562077958 +0200
@@ -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 -urNp gdb-orig/gdb/mep-tdep.c gdb-head/gdb/mep-tdep.c
--- gdb-orig/gdb/mep-tdep.c 2007-06-06 19:48:10.826612174 +0200
+++ gdb-head/gdb/mep-tdep.c 2007-06-06 19:49:08.571076663 +0200
@@ -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, ®val);
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, ®val);
return regval;
}
diff -urNp gdb-orig/gdb/mi/mi-main.c gdb-head/gdb/mi/mi-main.c
--- gdb-orig/gdb/mi/mi-main.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/mi/mi-main.c 2007-06-06 19:49:08.577075800 +0200
@@ -630,7 +630,7 @@ mi_cmd_data_write_register_values (char
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 -urNp gdb-orig/gdb/mips-tdep.c gdb-head/gdb/mips-tdep.c
--- gdb-orig/gdb/mips-tdep.c 2007-06-06 19:48:10.840610160 +0200
+++ gdb-head/gdb/mips-tdep.c 2007-06-06 19:49:08.591073785 +0200
@@ -4276,7 +4276,7 @@ deprecated_mips_set_processor_regs_hack
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 -urNp gdb-orig/gdb/monitor.c gdb-head/gdb/monitor.c
--- gdb-orig/gdb/monitor.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/monitor.c 2007-06-06 19:49:08.634067598 +0200
@@ -1109,10 +1109,10 @@ monitor_wait (ptid_t ptid, struct target
}
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 -urNp gdb-orig/gdb/procfs.c gdb-head/gdb/procfs.c
--- gdb-orig/gdb/procfs.c 2007-06-06 17:19:37.942918000 +0200
+++ gdb-head/gdb/procfs.c 2007-06-06 19:49:08.657064289 +0200
@@ -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, p
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 +6105,7 @@ procfs_make_note_section (bfd *obfd, int
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 -urNp gdb-orig/gdb/proc-service.c gdb-head/gdb/proc-service.c
--- gdb-orig/gdb/proc-service.c 2007-06-01 18:51:01.000000000 +0200
+++ gdb-head/gdb/proc-service.c 2007-06-06 19:49:08.662063570 +0200
@@ -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, l
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, l
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 -urNp gdb-orig/gdb/regcache.c gdb-head/gdb/regcache.c
--- gdb-orig/gdb/regcache.c 2007-06-06 19:48:27.653715981 +0200
+++ gdb-head/gdb/regcache.c 2007-06-06 19:49:08.670062419 +0200
@@ -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 *gdbarc
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 regc
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 *re
/* 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 *regc
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;
+ ptid_t saved_ptid = inferior_ptid;
+ inferior_ptid = regcache->ptid;
+ target_fetch_registers (regcache, regnum);
+ inferior_ptid = saved_ptid;
}
- 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)
{
+ ptid_t saved_ptid;
+
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 *reg
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 *reg
regcache->descr->sizeof_register[regnum]) == 0))
return;
+ saved_ptid = 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);
+
+ inferior_ptid = saved_ptid;
}
void
@@ -767,15 +787,6 @@ regcache_raw_supply (struct regcache *re
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 regca
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 fr
}
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 -urNp gdb-orig/gdb/regcache.h gdb-head/gdb/regcache.h
--- gdb-orig/gdb/regcache.h 2007-06-06 19:48:27.658715261 +0200
+++ gdb-head/gdb/regcache.h 2007-06-06 19:49:08.674061843 +0200
@@ -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 -urNp gdb-orig/gdb/remote.c gdb-head/gdb/remote.c
--- gdb-orig/gdb/remote.c 2007-06-06 00:55:29.000000000 +0200
+++ gdb-head/gdb/remote.c 2007-06-06 19:49:08.688059829 +0200
@@ -3225,7 +3225,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);
}
@@ -3422,7 +3422,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 -urNp gdb-orig/gdb/remote-mips.c gdb-head/gdb/remote-mips.c
--- gdb-orig/gdb/remote-mips.c 2007-06-01 18:51:02.000000000 +0200
+++ gdb-head/gdb/remote-mips.c 2007-06-06 19:49:08.698058390 +0200
@@ -1755,19 +1755,20 @@ mips_wait (ptid_t ptid, struct target_wa
&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 -urNp gdb-orig/gdb/sol-thread.c gdb-head/gdb/sol-thread.c
--- gdb-orig/gdb/sol-thread.c 2007-06-01 18:51:02.000000000 +0200
+++ gdb-head/gdb/sol-thread.c 2007-06-06 19:49:08.705057383 +0200
@@ -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, lwp
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, l
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, l
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 -urNp gdb-orig/gdb/stack.c gdb-head/gdb/stack.c
--- gdb-orig/gdb/stack.c 2007-06-06 17:34:42.752987000 +0200
+++ gdb-head/gdb/stack.c 2007-06-06 19:49:08.712056376 +0200
@@ -1849,7 +1849,7 @@ If you continue, the return value that y
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 -urNp gdb-orig/gdb/win32-nat.c gdb-head/gdb/win32-nat.c
--- gdb-orig/gdb/win32-nat.c 2007-06-01 18:51:02.000000000 +0200
+++ gdb-head/gdb/win32-nat.c 2007-06-06 19:49:08.719055368 +0200
@@ -1318,7 +1318,7 @@ win32_resume (ptid_t ptid, int step, enu
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;
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com