(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-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.
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);
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);
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);
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 ();
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;
/* 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);
(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
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."));
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)
{
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. */
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;
}
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
write_memory (addr, (gdb_byte *) &eflags, 4);
}
}
-
- do_cleanups (old_chain);
}
if (ptrace (request, pid, 0, target_signal_to_host (signal)) == -1)
if (!step)
{
+ struct regcache *regcache = get_current_regcache ();
ULONGEST eflags;
/* Workaround for a bug in FreeBSD. Make sure that the trace
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;
}
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;
}
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)
{
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
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:
/* 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
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\
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)
{
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;
(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
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 ();
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 ();
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,
&& (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,
&& (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,
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;
}
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
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))
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;
}
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;
}
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;
}
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
{
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;
}
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;
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;
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;
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;
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;
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,
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,
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);
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 *
regcache->register_valid_p
= XCALLOC (descr->sizeof_raw_register_valid_p, gdb_byte);
regcache->readonly_p = 1;
+ regcache->ptid = minus_one_ptid;
return regcache;
}
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);
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;
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;
/* 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. */
{
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
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);
}
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
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);
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)
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
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];
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. */
else
internal_error (__FILE__, __LINE__, _("read_pc_pid: Unable to find PC"));
- inferior_ptid = saved_inferior_ptid;
return pc_val;
}
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)
else
internal_error (__FILE__, __LINE__,
_("write_pc_pid: Unable to update PC"));
-
- inferior_ptid = saved_inferior_ptid;
}
void
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)
_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);
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);
&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)
{
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);
}
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++ != ';')
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);
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);
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);
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);
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*/);
}
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;
}
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;
}