diff options
Diffstat (limited to 'gdb')
57 files changed, 855 insertions, 700 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2b1bbd8..a24b284 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,162 @@ 2007-05-06 Ulrich Weigand <uweigand@de.ibm.com> + * target.h (struct regcache): Add forward declaration. + (struct target_ops): Add REGCACHE parameter to to_fetch_registers + and to_store_registers target operations. + (target_fetch_registers, target_store_registers): Update. + + * regcache.c (regcache_raw_read): Replace register_cached by + regcache_valid_p. Pass regcache to target_fetch_registers. + (regcache_raw_write): Pass regcache to target_store_registers. + + * arm-linux-nat.c (store_fpregister, store_fpregs, store_register, + store_regs, store_wmmx_regs): Replace register_cached by + regcache_valid_p. + + * bsd-kvm.c (bsd_kvm_open, bsd_kvm_proc_cmd): Pass current_regcache + to target_fetch_registers calls. + * corelow.c (core_open): Likewise. + * linux-nat.c (linux_nat_corefile_thread_callback): Likewise. + * proc-service.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, + ps_lsetfpregs): Likewise. + * sol-thread.c (ps_lgetregs, ps_lsetregs, ps_lgetfpregs, + ps_lsetfpregs): Likewise. + * win32-nat.c (win32_resume): Likewise. + * ia64-tdep.c (ia64_store_return_value): Pass current_regcache + to target_store_registers call. + * rs6000-tdep.c (rs6000_push_dummy_call): Likewise. + + * inferior.h (store_inferior_registers): Update prototype. + (fetch_inferior_registers): Likewise. + * gnu-nat.c (gnu_store_registers, gnu_fetch_registers): Likewise. + * mips-linux-nat.c (super_fetch_registers, super_store_registers): + Update function pointer signatures. + + * aix-thread.c (aix_thread_fetch_registers): Add REGCACHE parameter, + use it instead of current_regcache, update calls. + (aix_thread_store_registers): Likewise. + * alphabsd-nat.c (alphabsd_fetch_inferior_registers): Likewise. + (alphabsd_store_inferior_registers): Likewise. + * amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise. + (amd64bsd_store_inferior_registers): Likewise. + * amd64-linux-nat.c (amd64_linux_fetch_inferior_registers): Likewise. + (amd64_linux_store_inferior_registers): Likewise. + * arm-linux-nat.c (fetch_fpregister, fetch_fpregs, store_fpregister, + store_fpregs, fetch_register, fetch_regs, store_register, store_regs, + fetch_wmmx_regs, store_wmmx_regs): Likewise. + (arm_linux_fetch_inferior_registers): Likewise. + (arm_linux_store_inferior_registers): Likewise. + * armnbsd-nat.c (fetch_register, fetch_regs, fetch_fp_register, + fetch_fp_regs, armnbsd_fetch_registers): Likewise. + (store_register, store_regs, store_fp_register, store_fp_regs, + armnbsd_store_registers): Likewise. + * bsd-kvm.c (bsd_kvm_fetch_pcb, bsd_kvm_fetch_registers): Likewise. + * bsd-uthread.c (bsd_uthread_fetch_registers): Likewise. + (bsd_uthread_store_registers): Likewise. + * corelow.c (get_core_registers): Likewise. + * go32-nat.c (fetch_register, go32_fetch_registers, store_register, + go32_store_registers): Likewise. + * hppabsd-nat.c (hppabsd_fetch_registers): Likewise. + (hppabsd_store_registers): Likewise. + * hppa-hpux-nat.c (hppa_hpux_fetch_register): Likewise. + (hppa_hpux_fetch_inferior_registers): Likewise. + (hppa_hpux_store_register): Likewise. + (hppa_hpux_store_inferior_registers): Likewise. + * hppa-linux-nat.c (fetch_register, store_register): Likewise. + (hppa_linux_fetch_inferior_registers): Likewise. + (hppa_linux_store_inferior_registers): Likewise. + * hpux-thread.c (hpux_thread_fetch_registers): Likewise. + (hpux_thread_store_registers): Likewise. + * i386bsd-nat.c (i386bsd_fetch_inferior_registers): Likewise. + (i386bsd_store_inferior_registers): Likewise. + * i386gnu-nat.c (fetch_fpregs, gnu_fetch_registers, store_fpregs, + gnu_store_registers): Likewise. + * i386-linux-nat.c (fetch_register, store_register, fetch_regs, + store_regs, fetch_fpregs, store_fpregs, fetch_fpxregs, store_fpxregs): + Likewise. + (i386_linux_fetch_inferior_registers): Likewise. + (i386_linux_store_inferior_registers): Likewise. + * ia64-linux-nat.c (ia64_linux_fetch_register): Likewise. + (ia64_linux_fetch_registers): Likewise. + (ia64_linux_store_register): Likewise. + (ia64_linux_store_registers): Likewise. + * inf-child.c (inf_child_fetch_inferior_registers): Likewise. + (inf_child_store_inferior_registers): Likewise. + * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. + (inf_ptrace_fetch_registers): Likewise. + (inf_ptrace_store_register): Likewise. + (inf_ptrace_store_registers): Likewise. + * infptrace.c (fetch_register, store_register): Likewise. + (fetch_inferior_registers, store_inferior_registers): Likewise. + * m32r-linux-nat.c (fetch_regs, store_regs): Likewise. + (m32r_linux_fetch_inferior_registers): Likewise. + (m32r_linux_store_inferior_registers): Likewise. + * m68kbsd-nat.c (m68kbsd_fetch_inferior_registers): Likewise. + (m68kbsd_store_inferior_registers): Likewise. + * m68klinux-nat.c (fetch_register, old_fetch_inferior_registers, + store_register, old_store_inferior_registers, fetch_regs, store_regs, + fetch_fpregs, store_fpregs): Likewise. + (m68k_linux_fetch_inferior_registers): Likewise. + (m68k_linux_store_inferior_registers): Likewise. + * m88kbsd-nat.c (m88kbsd_fetch_inferior_registers): Likewise. + (m88kbsd_store_inferior_registers): Likewise. + * mips64obsd-nat.c (mips64obsd_fetch_inferior_registers): Likewise. + (mips64obsd_store_inferior_registers): Likewise. + * mips-linux-nat.c (mips64_linux_regsets_fetch_registers): Likewise. + (mips64_linux_regsets_store_registers): Likewise. + (mips64_linux_fetch_registers): Likewise. + (mips64_linux_store_registers): Likewise. + * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise. + (mipsnbsd_store_inferior_registers): Likewise. + * monitor.c (monitor_fetch_register, monitor_store_register): Likewise. + (monitor_fetch_registers, monitor_store_registers): Likewise. + * nto-procfs.c (procfs_fetch_registers): Likewise. + (procfs_store_registers): Likewise. + * ppc-linux-nat.c (fetch_altivec_register, fetch_spe_register, + fetch_register, supply_vrregset, fetch_altivec_registers, + fetch_ppc_registers, ppc_linux_fetch_inferior_registers): Likewise. + (store_altivec_register, store_spe_register, store_register, + fill_vrregset, store_altivec_registers, store_ppc_registers, + ppc_linux_store_inferior_registers): Likewise. + * ppcnbsd-nat.c (ppcnbsd_fetch_inferior_registers): Likewise. + (ppcnbsd_store_inferior_registers): Likewise. + * ppcobsd-nat.c (ppcobsd_fetch_registers): Likewise. + (ppcobsd_store_registers): Likewise. + * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. + * remote.c (fetch_register_using_p, process_g_packet, + fetch_registers_using_g, remote_fetch_registers): Likewise. + (store_register_using_P, store_registers_using_G, + remote_store_registers): Likewise. + * remote-m32r-sdi.c (m32r_fetch_registers, m32r_fetch_register, + m32r_store_register, m32r_store_register): Likewise. + * remote-mips.c (mips_fetch_registers, mips_store_registers): Likewise. + * remote-sim.c (gdbsim_fetch_register): Likewise. + (gdbsim_store_register): Likewise. + * rs6000-nat.c (fetch_register, store_register): Likewise. + (rs6000_fetch_inferior_registers): Likewise. + (rs6000_store_inferior_registers): Likewise. + * s390-nat.c (fetch_regs, store_regs): Likewise. + (fetch_fpregs, store_fpregs): Likewise. + (s390_linux_fetch_inferior_registers): Likewise. + (s390_linux_store_inferior_registers): Likewise. + * shnbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise. + (shnbsd_store_inferior_registers): Likewise. + * sol-thread.c (sol_thread_fetch_registers): Likewise. + (sol_thread_store_registers): Likewise. + * sparc-nat.c (fetch_inferior_registers): Likewise. + (store_inferior_registers): Likewise. + * spu-linux-nat.c (spu_fetch_inferior_registers): Likewise. + (spu_store_inferior_registers): Likewise. + * target.c (debug_print_register): Likewise. + (debug_to_fetch_registers, debug_to_store_registers): Likewise. + * vaxbsd-nat.c (vaxbsd_fetch_inferior_registers): Likewise. + (vaxbsd_store_inferior_registers): Likewise. + * win32-nat.c (do_win32_fetch_inferior_registers): Likewise. + (win32_fetch_inferior_registers): Likewise. + (win32_store_inferior_registers): Likewise. + +2007-05-06 Ulrich Weigand <uweigand@de.ibm.com> + * gdbcore.h (struct regcache): Add forward declaration. (struct core_fns): Add REGCACHE argument to core_read_registers callback. diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 65c9e81..e6d7a29 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -1270,22 +1270,22 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno, thread/process specified by inferior_ptid. */ static void -aix_thread_fetch_registers (int regno) +aix_thread_fetch_registers (struct regcache *regcache, int regno) { struct thread_info *thread; pthdb_tid_t tid; if (!PD_TID (inferior_ptid)) - base_target.to_fetch_registers (regno); + base_target.to_fetch_registers (regcache, regno); else { thread = find_thread_pid (inferior_ptid); tid = thread->private->tid; if (tid == PTHDB_INVALID_TID) - fetch_regs_user_thread (current_regcache, thread->private->pdtid); + fetch_regs_user_thread (regcache, thread->private->pdtid); else - fetch_regs_kernel_thread (current_regcache, regno, tid); + fetch_regs_kernel_thread (regcache, regno, tid); } } @@ -1602,22 +1602,22 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno, thread/process specified by inferior_ptid. */ static void -aix_thread_store_registers (int regno) +aix_thread_store_registers (struct regcache *regcache, int regno) { struct thread_info *thread; pthdb_tid_t tid; if (!PD_TID (inferior_ptid)) - base_target.to_store_registers (regno); + base_target.to_store_registers (regcache, regno); else { thread = find_thread_pid (inferior_ptid); tid = thread->private->tid; if (tid == PTHDB_INVALID_TID) - store_regs_user_thread (current_regcache, thread->private->pdtid); + store_regs_user_thread (regcache, thread->private->pdtid); else - store_regs_kernel_thread (current_regcache, regno, tid); + store_regs_kernel_thread (regcache, regno, tid); } } diff --git a/gdb/alphabsd-nat.c b/gdb/alphabsd-nat.c index 9eb1937..fd21983 100644 --- a/gdb/alphabsd-nat.c +++ b/gdb/alphabsd-nat.c @@ -86,7 +86,7 @@ getregs_supplies (int regno) for all registers (including the floating point registers). */ static void -alphabsd_fetch_inferior_registers (int regno) +alphabsd_fetch_inferior_registers (struct regcache *regcache, int regno) { if (regno == -1 || getregs_supplies (regno)) { @@ -96,7 +96,7 @@ alphabsd_fetch_inferior_registers (int regno) (PTRACE_TYPE_ARG3) &gregs, 0) == -1) perror_with_name (_("Couldn't get registers")); - alphabsd_supply_reg (current_regcache, (char *) &gregs, regno); + alphabsd_supply_reg (regcache, (char *) &gregs, regno); if (regno != -1) return; } @@ -109,7 +109,7 @@ alphabsd_fetch_inferior_registers (int regno) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - alphabsd_supply_fpreg (current_regcache, (char *) &fpregs, regno); + alphabsd_supply_fpreg (regcache, (char *) &fpregs, regno); } } @@ -117,7 +117,7 @@ alphabsd_fetch_inferior_registers (int regno) this for all registers (including the floating point registers). */ static void -alphabsd_store_inferior_registers (int regno) +alphabsd_store_inferior_registers (struct regcache *regcache, int regno) { if (regno == -1 || getregs_supplies (regno)) { @@ -126,7 +126,7 @@ alphabsd_store_inferior_registers (int regno) (PTRACE_TYPE_ARG3) &gregs, 0) == -1) perror_with_name (_("Couldn't get registers")); - alphabsd_fill_reg (current_regcache, (char *) &gregs, regno); + alphabsd_fill_reg (regcache, (char *) &gregs, regno); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &gregs, 0) == -1) @@ -144,7 +144,7 @@ alphabsd_store_inferior_registers (int regno) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - alphabsd_fill_fpreg (current_regcache, (char *) &fpregs, regno); + alphabsd_fill_fpreg (regcache, (char *) &fpregs, regno); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index 7a253a3..09899a4 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -157,7 +157,7 @@ fill_fpregset (const struct regcache *regcache, registers). */ static void -amd64_linux_fetch_inferior_registers (int regnum) +amd64_linux_fetch_inferior_registers (struct regcache *regcache, int regnum) { int tid; @@ -173,7 +173,7 @@ amd64_linux_fetch_inferior_registers (int regnum) if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) perror_with_name (_("Couldn't get registers")); - amd64_supply_native_gregset (current_regcache, ®s, -1); + amd64_supply_native_gregset (regcache, ®s, -1); if (regnum != -1) return; } @@ -185,7 +185,7 @@ amd64_linux_fetch_inferior_registers (int regnum) if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) perror_with_name (_("Couldn't get floating point status")); - amd64_supply_fxsave (current_regcache, -1, &fpregs); + amd64_supply_fxsave (regcache, -1, &fpregs); } } @@ -194,7 +194,7 @@ amd64_linux_fetch_inferior_registers (int regnum) registers). */ static void -amd64_linux_store_inferior_registers (int regnum) +amd64_linux_store_inferior_registers (struct regcache *regcache, int regnum) { int tid; @@ -210,7 +210,7 @@ amd64_linux_store_inferior_registers (int regnum) if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) perror_with_name (_("Couldn't get registers")); - amd64_collect_native_gregset (current_regcache, ®s, regnum); + amd64_collect_native_gregset (regcache, ®s, regnum); if (ptrace (PTRACE_SETREGS, tid, 0, (long) ®s) < 0) perror_with_name (_("Couldn't write registers")); @@ -226,7 +226,7 @@ amd64_linux_store_inferior_registers (int regnum) if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) perror_with_name (_("Couldn't get floating point status")); - amd64_collect_fxsave (current_regcache, regnum, &fpregs); + amd64_collect_fxsave (regcache, regnum, &fpregs); if (ptrace (PTRACE_SETFPREGS, tid, 0, (long) &fpregs) < 0) perror_with_name (_("Couldn't write floating point status")); diff --git a/gdb/amd64bsd-nat.c b/gdb/amd64bsd-nat.c index a1f9e82..c75470c 100644 --- a/gdb/amd64bsd-nat.c +++ b/gdb/amd64bsd-nat.c @@ -41,7 +41,7 @@ for all registers (including the floating-point registers). */ static void -amd64bsd_fetch_inferior_registers (int regnum) +amd64bsd_fetch_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || amd64_native_gregset_supplies_p (regnum)) { @@ -51,7 +51,7 @@ amd64bsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - amd64_supply_native_gregset (current_regcache, ®s, -1); + amd64_supply_native_gregset (regcache, ®s, -1); if (regnum != -1) return; } @@ -64,7 +64,7 @@ amd64bsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - amd64_supply_fxsave (current_regcache, -1, &fpregs); + amd64_supply_fxsave (regcache, -1, &fpregs); } } @@ -72,7 +72,7 @@ amd64bsd_fetch_inferior_registers (int regnum) this for all registers (including the floating-point registers). */ static void -amd64bsd_store_inferior_registers (int regnum) +amd64bsd_store_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || amd64_native_gregset_supplies_p (regnum)) { @@ -82,7 +82,7 @@ amd64bsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - amd64_collect_native_gregset (current_regcache, ®s, regnum); + amd64_collect_native_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) @@ -100,7 +100,7 @@ amd64bsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - amd64_collect_fxsave (current_regcache, regnum, &fpregs); + amd64_collect_fxsave (regcache, regnum, &fpregs); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index 997120d..49114fa 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -93,7 +93,7 @@ get_thread_id (ptid_t ptid) state of the process and store it into regcache. */ static void -fetch_fpregister (int regno) +fetch_fpregister (struct regcache *regcache, int regno) { int ret, tid; gdb_byte fp[ARM_LINUX_SIZEOF_NWFPE]; @@ -111,19 +111,19 @@ fetch_fpregister (int regno) /* Fetch fpsr. */ if (ARM_FPS_REGNUM == regno) - regcache_raw_supply (current_regcache, ARM_FPS_REGNUM, + regcache_raw_supply (regcache, ARM_FPS_REGNUM, fp + NWFPE_FPSR_OFFSET); /* Fetch the floating point register. */ if (regno >= ARM_F0_REGNUM && regno <= ARM_F7_REGNUM) - supply_nwfpe_register (current_regcache, regno, fp); + supply_nwfpe_register (regcache, regno, fp); } /* Get the whole floating point state of the process and store it into regcache. */ static void -fetch_fpregs (void) +fetch_fpregs (struct regcache *regcache) { int ret, regno, tid; gdb_byte fp[ARM_LINUX_SIZEOF_NWFPE]; @@ -140,19 +140,19 @@ fetch_fpregs (void) } /* Fetch fpsr. */ - regcache_raw_supply (current_regcache, ARM_FPS_REGNUM, + regcache_raw_supply (regcache, ARM_FPS_REGNUM, fp + NWFPE_FPSR_OFFSET); /* Fetch the floating point registers. */ for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++) - supply_nwfpe_register (current_regcache, regno, fp); + supply_nwfpe_register (regcache, regno, fp); } /* Save a particular register into the floating point state of the process using the contents from regcache. */ static void -store_fpregister (int regno) +store_fpregister (const struct regcache *regcache, int regno) { int ret, tid; gdb_byte fp[ARM_LINUX_SIZEOF_NWFPE]; @@ -169,13 +169,12 @@ store_fpregister (int regno) } /* Store fpsr. */ - if (ARM_FPS_REGNUM == regno && register_cached (ARM_FPS_REGNUM)) - regcache_raw_collect (current_regcache, ARM_FPS_REGNUM, - fp + NWFPE_FPSR_OFFSET); + if (ARM_FPS_REGNUM == regno && regcache_valid_p (regcache, ARM_FPS_REGNUM)) + regcache_raw_collect (regcache, ARM_FPS_REGNUM, fp + NWFPE_FPSR_OFFSET); /* Store the floating point register. */ if (regno >= ARM_F0_REGNUM && regno <= ARM_F7_REGNUM) - collect_nwfpe_register (current_regcache, regno, fp); + collect_nwfpe_register (regcache, regno, fp); ret = ptrace (PTRACE_SETFPREGS, tid, 0, fp); if (ret < 0) @@ -189,7 +188,7 @@ store_fpregister (int regno) the contents from regcache. */ static void -store_fpregs (void) +store_fpregs (const struct regcache *regcache) { int ret, regno, tid; gdb_byte fp[ARM_LINUX_SIZEOF_NWFPE]; @@ -206,14 +205,13 @@ store_fpregs (void) } /* Store fpsr. */ - if (register_cached (ARM_FPS_REGNUM)) - regcache_raw_collect (current_regcache, ARM_FPS_REGNUM, - fp + NWFPE_FPSR_OFFSET); + if (regcache_valid_p (regcache, ARM_FPS_REGNUM)) + regcache_raw_collect (regcache, ARM_FPS_REGNUM, fp + NWFPE_FPSR_OFFSET); /* Store the floating point registers. */ for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++) - if (register_cached (regno)) - collect_nwfpe_register (current_regcache, regno, fp); + if (regcache_valid_p (regcache, regno)) + collect_nwfpe_register (regcache, regno, fp); ret = ptrace (PTRACE_SETFPREGS, tid, 0, fp); if (ret < 0) @@ -227,7 +225,7 @@ store_fpregs (void) regcache. */ static void -fetch_register (int regno) +fetch_register (struct regcache *regcache, int regno) { int ret, tid; elf_gregset_t regs; @@ -243,22 +241,22 @@ fetch_register (int regno) } if (regno >= ARM_A1_REGNUM && regno < ARM_PC_REGNUM) - regcache_raw_supply (current_regcache, regno, (char *) ®s[regno]); + regcache_raw_supply (regcache, regno, (char *) ®s[regno]); if (ARM_PS_REGNUM == regno) { if (arm_apcs_32) - regcache_raw_supply (current_regcache, ARM_PS_REGNUM, + regcache_raw_supply (regcache, ARM_PS_REGNUM, (char *) ®s[ARM_CPSR_REGNUM]); else - regcache_raw_supply (current_regcache, ARM_PS_REGNUM, + regcache_raw_supply (regcache, ARM_PS_REGNUM, (char *) ®s[ARM_PC_REGNUM]); } if (ARM_PC_REGNUM == regno) { regs[ARM_PC_REGNUM] = ADDR_BITS_REMOVE (regs[ARM_PC_REGNUM]); - regcache_raw_supply (current_regcache, ARM_PC_REGNUM, + regcache_raw_supply (regcache, ARM_PC_REGNUM, (char *) ®s[ARM_PC_REGNUM]); } } @@ -267,7 +265,7 @@ fetch_register (int regno) regcache. */ static void -fetch_regs (void) +fetch_regs (struct regcache *regcache) { int ret, regno, tid; elf_gregset_t regs; @@ -283,17 +281,17 @@ fetch_regs (void) } for (regno = ARM_A1_REGNUM; regno < ARM_PC_REGNUM; regno++) - regcache_raw_supply (current_regcache, regno, (char *) ®s[regno]); + regcache_raw_supply (regcache, regno, (char *) ®s[regno]); if (arm_apcs_32) - regcache_raw_supply (current_regcache, ARM_PS_REGNUM, + regcache_raw_supply (regcache, ARM_PS_REGNUM, (char *) ®s[ARM_CPSR_REGNUM]); else - regcache_raw_supply (current_regcache, ARM_PS_REGNUM, + regcache_raw_supply (regcache, ARM_PS_REGNUM, (char *) ®s[ARM_PC_REGNUM]); regs[ARM_PC_REGNUM] = ADDR_BITS_REMOVE (regs[ARM_PC_REGNUM]); - regcache_raw_supply (current_regcache, ARM_PC_REGNUM, + regcache_raw_supply (regcache, ARM_PC_REGNUM, (char *) ®s[ARM_PC_REGNUM]); } @@ -301,12 +299,12 @@ fetch_regs (void) regcache. */ static void -store_register (int regno) +store_register (const struct regcache *regcache, int regno) { int ret, tid; elf_gregset_t regs; - if (!register_cached (regno)) + if (!regcache_valid_p (regcache, regno)) return; /* Get the thread id for the ptrace call. */ @@ -321,12 +319,12 @@ store_register (int regno) } if (regno >= ARM_A1_REGNUM && regno <= ARM_PC_REGNUM) - regcache_raw_collect (current_regcache, regno, (char *) ®s[regno]); + regcache_raw_collect (regcache, regno, (char *) ®s[regno]); else if (arm_apcs_32 && regno == ARM_PS_REGNUM) - regcache_raw_collect (current_regcache, regno, + regcache_raw_collect (regcache, regno, (char *) ®s[ARM_CPSR_REGNUM]); else if (!arm_apcs_32 && regno == ARM_PS_REGNUM) - regcache_raw_collect (current_regcache, ARM_PC_REGNUM, + regcache_raw_collect (regcache, ARM_PC_REGNUM, (char *) ®s[ARM_PC_REGNUM]); ret = ptrace (PTRACE_SETREGS, tid, 0, ®s); @@ -338,7 +336,7 @@ store_register (int regno) } static void -store_regs (void) +store_regs (const struct regcache *regcache) { int ret, regno, tid; elf_gregset_t regs; @@ -356,12 +354,12 @@ store_regs (void) for (regno = ARM_A1_REGNUM; regno <= ARM_PC_REGNUM; regno++) { - if (register_cached (regno)) - regcache_raw_collect (current_regcache, regno, (char *) ®s[regno]); + if (regcache_valid_p (regcache, regno)) + regcache_raw_collect (regcache, regno, (char *) ®s[regno]); } - if (arm_apcs_32 && register_cached (ARM_PS_REGNUM)) - regcache_raw_collect (current_regcache, ARM_PS_REGNUM, + if (arm_apcs_32 && regcache_valid_p (regcache, ARM_PS_REGNUM)) + regcache_raw_collect (regcache, ARM_PS_REGNUM, (char *) ®s[ARM_CPSR_REGNUM]); ret = ptrace (PTRACE_SETREGS, tid, 0, ®s); @@ -379,7 +377,7 @@ store_regs (void) #define IWMMXT_REGS_SIZE (16 * 8 + 6 * 4) static void -fetch_wmmx_regs (void) +fetch_wmmx_regs (struct regcache *regcache) { char regbuf[IWMMXT_REGS_SIZE]; int ret, regno, tid; @@ -395,20 +393,20 @@ fetch_wmmx_regs (void) } for (regno = 0; regno < 16; regno++) - regcache_raw_supply (current_regcache, regno + ARM_WR0_REGNUM, + regcache_raw_supply (regcache, regno + ARM_WR0_REGNUM, ®buf[regno * 8]); for (regno = 0; regno < 2; regno++) - regcache_raw_supply (current_regcache, regno + ARM_WCSSF_REGNUM, + regcache_raw_supply (regcache, regno + ARM_WCSSF_REGNUM, ®buf[16 * 8 + regno * 4]); for (regno = 0; regno < 4; regno++) - regcache_raw_supply (current_regcache, regno + ARM_WCGR0_REGNUM, + regcache_raw_supply (regcache, regno + ARM_WCGR0_REGNUM, ®buf[16 * 8 + 2 * 4 + regno * 4]); } static void -store_wmmx_regs (void) +store_wmmx_regs (const struct regcache *regcache) { char regbuf[IWMMXT_REGS_SIZE]; int ret, regno, tid; @@ -424,18 +422,18 @@ store_wmmx_regs (void) } for (regno = 0; regno < 16; regno++) - if (register_cached (regno + ARM_WR0_REGNUM)) - regcache_raw_collect (current_regcache, regno + ARM_WR0_REGNUM, + if (regcache_valid_p (regcache, regno + ARM_WR0_REGNUM)) + regcache_raw_collect (regcache, regno + ARM_WR0_REGNUM, ®buf[regno * 8]); for (regno = 0; regno < 2; regno++) - if (register_cached (regno + ARM_WCSSF_REGNUM)) - regcache_raw_collect (current_regcache, regno + ARM_WCSSF_REGNUM, + if (regcache_valid_p (regcache, regno + ARM_WCSSF_REGNUM)) + regcache_raw_collect (regcache, regno + ARM_WCSSF_REGNUM, ®buf[16 * 8 + regno * 4]); for (regno = 0; regno < 4; regno++) - if (register_cached (regno + ARM_WCGR0_REGNUM)) - regcache_raw_collect (current_regcache, regno + ARM_WCGR0_REGNUM, + if (regcache_valid_p (regcache, regno + ARM_WCGR0_REGNUM)) + regcache_raw_collect (regcache, regno + ARM_WCGR0_REGNUM, ®buf[16 * 8 + 2 * 4 + regno * 4]); ret = ptrace (PTRACE_SETWMMXREGS, tid, 0, regbuf); @@ -452,24 +450,24 @@ store_wmmx_regs (void) point registers depending upon the value of regno. */ static void -arm_linux_fetch_inferior_registers (int regno) +arm_linux_fetch_inferior_registers (struct regcache *regcache, int regno) { if (-1 == regno) { - fetch_regs (); - fetch_fpregs (); + fetch_regs (regcache); + fetch_fpregs (regcache); if (arm_linux_has_wmmx_registers) - fetch_wmmx_regs (); + fetch_wmmx_regs (regcache); } else { if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) - fetch_register (regno); + fetch_register (regcache, regno); else if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM) - fetch_fpregister (regno); + fetch_fpregister (regcache, regno); else if (arm_linux_has_wmmx_registers && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM) - fetch_wmmx_regs (); + fetch_wmmx_regs (regcache); } } @@ -478,24 +476,24 @@ arm_linux_fetch_inferior_registers (int regno) point registers depending upon the value of regno. */ static void -arm_linux_store_inferior_registers (int regno) +arm_linux_store_inferior_registers (struct regcache *regcache, int regno) { if (-1 == regno) { - store_regs (); - store_fpregs (); + store_regs (regcache); + store_fpregs (regcache); if (arm_linux_has_wmmx_registers) - store_wmmx_regs (); + store_wmmx_regs (regcache); } else { if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM) - store_register (regno); + store_register (regcache, regno); else if ((regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM)) - store_fpregister (regno); + store_fpregister (regcache, regno); else if (arm_linux_has_wmmx_registers && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM) - store_wmmx_regs (); + store_wmmx_regs (regcache); } } diff --git a/gdb/armnbsd-nat.c b/gdb/armnbsd-nat.c index d2b5f6c..6f6bd77 100644 --- a/gdb/armnbsd-nat.c +++ b/gdb/armnbsd-nat.c @@ -77,7 +77,7 @@ arm_supply_fparegset (struct regcache *regcache, struct fpreg *fparegset) } static void -fetch_register (int regno) +fetch_register (struct regcache *regcache, int regno) { struct reg inferior_registers; int ret; @@ -94,40 +94,40 @@ fetch_register (int regno) switch (regno) { case ARM_SP_REGNUM: - regcache_raw_supply (current_regcache, ARM_SP_REGNUM, + regcache_raw_supply (regcache, ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); break; case ARM_LR_REGNUM: - regcache_raw_supply (current_regcache, ARM_LR_REGNUM, + regcache_raw_supply (regcache, ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); break; case ARM_PC_REGNUM: /* This is ok: we're running native... */ inferior_registers.r_pc = ADDR_BITS_REMOVE (inferior_registers.r_pc); - regcache_raw_supply (current_regcache, ARM_PC_REGNUM, + regcache_raw_supply (regcache, ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); break; case ARM_PS_REGNUM: if (arm_apcs_32) - regcache_raw_supply (current_regcache, ARM_PS_REGNUM, + regcache_raw_supply (regcache, ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); else - regcache_raw_supply (current_regcache, ARM_PS_REGNUM, + regcache_raw_supply (regcache, ARM_PS_REGNUM, (char *) &inferior_registers.r_pc); break; default: - regcache_raw_supply (current_regcache, regno, + regcache_raw_supply (regcache, regno, (char *) &inferior_registers.r[regno]); break; } } static void -fetch_regs (void) +fetch_regs (struct regcache *regcache) { struct reg inferior_registers; int ret; @@ -142,11 +142,11 @@ fetch_regs (void) return; } - arm_supply_gregset (current_regcache, &inferior_registers); + arm_supply_gregset (regcache, &inferior_registers); } static void -fetch_fp_register (int regno) +fetch_fp_register (struct regcache *regcache, int regno) { struct fpreg inferior_fp_registers; int ret; @@ -163,19 +163,19 @@ fetch_fp_register (int regno) switch (regno) { case ARM_FPS_REGNUM: - regcache_raw_supply (current_regcache, ARM_FPS_REGNUM, + regcache_raw_supply (regcache, ARM_FPS_REGNUM, (char *) &inferior_fp_registers.fpr_fpsr); break; default: - regcache_raw_supply (current_regcache, regno, + regcache_raw_supply (regcache, regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); break; } } static void -fetch_fp_regs (void) +fetch_fp_regs (struct regcache *regcache) { struct fpreg inferior_fp_registers; int ret; @@ -190,29 +190,29 @@ fetch_fp_regs (void) return; } - arm_supply_fparegset (current_regcache, &inferior_fp_registers); + arm_supply_fparegset (regcache, &inferior_fp_registers); } static void -armnbsd_fetch_registers (int regno) +armnbsd_fetch_registers (struct regcache *regcache, int regno) { if (regno >= 0) { if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM) - fetch_register (regno); + fetch_register (regcache, regno); else - fetch_fp_register (regno); + fetch_fp_register (regcache, regno); } else { - fetch_regs (); - fetch_fp_regs (); + fetch_regs (regcache); + fetch_fp_regs (regcache); } } static void -store_register (int regno) +store_register (const struct regcache *regcache, int regno) { struct reg inferior_registers; int ret; @@ -229,24 +229,24 @@ store_register (int regno) switch (regno) { case ARM_SP_REGNUM: - regcache_raw_collect (current_regcache, ARM_SP_REGNUM, + regcache_raw_collect (regcache, ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); break; case ARM_LR_REGNUM: - regcache_raw_collect (current_regcache, ARM_LR_REGNUM, + regcache_raw_collect (regcache, ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); break; case ARM_PC_REGNUM: if (arm_apcs_32) - regcache_raw_collect (current_regcache, ARM_PC_REGNUM, + regcache_raw_collect (regcache, ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); else { unsigned pc_val; - regcache_raw_collect (current_regcache, ARM_PC_REGNUM, + regcache_raw_collect (regcache, ARM_PC_REGNUM, (char *) &pc_val); pc_val = ADDR_BITS_REMOVE (pc_val); @@ -258,13 +258,13 @@ store_register (int regno) case ARM_PS_REGNUM: if (arm_apcs_32) - regcache_raw_collect (current_regcache, ARM_PS_REGNUM, + regcache_raw_collect (regcache, ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); else { unsigned psr_val; - regcache_raw_collect (current_regcache, ARM_PS_REGNUM, + regcache_raw_collect (regcache, ARM_PS_REGNUM, (char *) &psr_val); psr_val ^= ADDR_BITS_REMOVE (psr_val); @@ -274,7 +274,7 @@ store_register (int regno) break; default: - regcache_raw_collect (current_regcache, regno, + regcache_raw_collect (regcache, regno, (char *) &inferior_registers.r[regno]); break; } @@ -287,7 +287,7 @@ store_register (int regno) } static void -store_regs (void) +store_regs (const struct regcache *regcache) { struct reg inferior_registers; int ret; @@ -295,19 +295,19 @@ store_regs (void) for (regno = ARM_A1_REGNUM; regno < ARM_SP_REGNUM; regno++) - regcache_raw_collect (current_regcache, regno, + regcache_raw_collect (regcache, regno, (char *) &inferior_registers.r[regno]); - regcache_raw_collect (current_regcache, ARM_SP_REGNUM, + regcache_raw_collect (regcache, ARM_SP_REGNUM, (char *) &inferior_registers.r_sp); - regcache_raw_collect (current_regcache, ARM_LR_REGNUM, + regcache_raw_collect (regcache, ARM_LR_REGNUM, (char *) &inferior_registers.r_lr); if (arm_apcs_32) { - regcache_raw_collect (current_regcache, ARM_PC_REGNUM, + regcache_raw_collect (regcache, ARM_PC_REGNUM, (char *) &inferior_registers.r_pc); - regcache_raw_collect (current_regcache, ARM_PS_REGNUM, + regcache_raw_collect (regcache, ARM_PS_REGNUM, (char *) &inferior_registers.r_cpsr); } else @@ -315,9 +315,9 @@ store_regs (void) unsigned pc_val; unsigned psr_val; - regcache_raw_collect (current_regcache, ARM_PC_REGNUM, + regcache_raw_collect (regcache, ARM_PC_REGNUM, (char *) &pc_val); - regcache_raw_collect (current_regcache, ARM_PS_REGNUM, + regcache_raw_collect (regcache, ARM_PS_REGNUM, (char *) &psr_val); pc_val = ADDR_BITS_REMOVE (pc_val); @@ -334,7 +334,7 @@ store_regs (void) } static void -store_fp_register (int regno) +store_fp_register (const struct regcache *regcache, int regno) { struct fpreg inferior_fp_registers; int ret; @@ -351,12 +351,12 @@ store_fp_register (int regno) switch (regno) { case ARM_FPS_REGNUM: - regcache_raw_collect (current_regcache, ARM_FPS_REGNUM, + regcache_raw_collect (regcache, ARM_FPS_REGNUM, (char *) &inferior_fp_registers.fpr_fpsr); break; default: - regcache_raw_collect (current_regcache, regno, + regcache_raw_collect (regcache, regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); break; } @@ -369,7 +369,7 @@ store_fp_register (int regno) } static void -store_fp_regs (void) +store_fp_regs (const struct regcache *regcache) { struct fpreg inferior_fp_registers; int ret; @@ -377,10 +377,10 @@ store_fp_regs (void) for (regno = ARM_F0_REGNUM; regno <= ARM_F7_REGNUM; regno++) - regcache_raw_collect (current_regcache, regno, + regcache_raw_collect (regcache, regno, (char *) &inferior_fp_registers.fpr[regno - ARM_F0_REGNUM]); - regcache_raw_collect (current_regcache, ARM_FPS_REGNUM, + regcache_raw_collect (regcache, ARM_FPS_REGNUM, (char *) &inferior_fp_registers.fpr_fpsr); ret = ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), @@ -391,19 +391,19 @@ store_fp_regs (void) } static void -armnbsd_store_registers (int regno) +armnbsd_store_registers (struct regcache *regcache, int regno) { if (regno >= 0) { if (regno < ARM_F0_REGNUM || regno > ARM_FPS_REGNUM) - store_register (regno); + store_register (regcache, regno); else - store_fp_register (regno); + store_fp_register (regcache, regno); } else { - store_regs (); - store_fp_regs (); + store_regs (regcache); + store_fp_regs (regcache); } } diff --git a/gdb/bsd-kvm.c b/gdb/bsd-kvm.c index 864be4f..910b3d0 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 (-1); + target_fetch_registers (current_regcache, -1); reinit_frame_cache (); print_stack_frame (get_selected_frame (NULL), -1, 1); @@ -150,7 +150,7 @@ bsd_kvm_files_info (struct target_ops *ops) /* Fetch process control block at address PADDR. */ static int -bsd_kvm_fetch_pcb (struct pcb *paddr) +bsd_kvm_fetch_pcb (struct regcache *regcache, struct pcb *paddr) { struct pcb pcb; @@ -158,17 +158,17 @@ bsd_kvm_fetch_pcb (struct pcb *paddr) error (("%s"), kvm_geterr (core_kd)); gdb_assert (bsd_kvm_supply_pcb); - return bsd_kvm_supply_pcb (current_regcache, &pcb); + return bsd_kvm_supply_pcb (regcache, &pcb); } static void -bsd_kvm_fetch_registers (int regnum) +bsd_kvm_fetch_registers (struct regcache *regcache, int regnum) { struct nlist nl[2]; if (bsd_kvm_paddr) { - bsd_kvm_fetch_pcb (bsd_kvm_paddr); + bsd_kvm_fetch_pcb (regcache, bsd_kvm_paddr); return; } @@ -184,7 +184,7 @@ bsd_kvm_fetch_registers (int regnum) { /* Found dumppcb. If it contains a valid context, return immediately. */ - if (bsd_kvm_fetch_pcb ((struct pcb *) nl[0].n_value)) + if (bsd_kvm_fetch_pcb (regcache, (struct pcb *) nl[0].n_value)) return; } @@ -206,7 +206,7 @@ bsd_kvm_fetch_registers (int regnum) if (kvm_read (core_kd, nl[0].n_value, &paddr, sizeof paddr) == -1) error (("%s"), kvm_geterr (core_kd)); - bsd_kvm_fetch_pcb (paddr); + bsd_kvm_fetch_pcb (regcache, paddr); return; } @@ -231,7 +231,7 @@ bsd_kvm_fetch_registers (int regnum) if (kvm_read (core_kd, nl[0].n_value, &paddr, sizeof paddr) == -1) error (("%s"), kvm_geterr (core_kd)); - bsd_kvm_fetch_pcb (paddr); + bsd_kvm_fetch_pcb (regcache, paddr); return; } #endif @@ -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 (-1); + target_fetch_registers (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 (-1); + target_fetch_registers (current_regcache, -1); reinit_frame_cache (); print_stack_frame (get_selected_frame (NULL), -1, 1); diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index 24edeb8..172192e 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -266,7 +266,7 @@ bsd_uthread_mourn_inferior (void) } static void -bsd_uthread_fetch_registers (int regnum) +bsd_uthread_fetch_registers (struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = current_gdbarch; struct bsd_uthread_ops *ops = gdbarch_data (gdbarch, bsd_uthread_data); @@ -274,7 +274,7 @@ bsd_uthread_fetch_registers (int regnum) CORE_ADDR active_addr; /* Always fetch the appropriate registers from the layer beneath. */ - find_target_beneath (bsd_uthread_ops_hack)->to_fetch_registers (regnum); + find_target_beneath (bsd_uthread_ops_hack)->to_fetch_registers (regcache, regnum); /* FIXME: That might have gotten us more than we asked for. Make sure we overwrite all relevant registers with values from the @@ -286,13 +286,13 @@ bsd_uthread_fetch_registers (int regnum) if (addr != 0 && addr != active_addr) { bsd_uthread_check_magic (addr); - ops->supply_uthread (current_regcache, regnum, + ops->supply_uthread (regcache, regnum, addr + bsd_uthread_thread_ctx_offset); } } static void -bsd_uthread_store_registers (int regnum) +bsd_uthread_store_registers (struct regcache *regcache, int regnum) { struct gdbarch *gdbarch = current_gdbarch; struct bsd_uthread_ops *ops = gdbarch_data (gdbarch, bsd_uthread_data); @@ -304,14 +304,14 @@ bsd_uthread_store_registers (int regnum) if (addr != 0 && addr != active_addr) { bsd_uthread_check_magic (addr); - ops->collect_uthread (current_regcache, regnum, + ops->collect_uthread (regcache, regnum, addr + bsd_uthread_thread_ctx_offset); } else { /* Updating the thread that is currently running; pass the request to the layer beneath. */ - find_target_beneath (bsd_uthread_ops_hack)->to_store_registers (regnum); + find_target_beneath (bsd_uthread_ops_hack)->to_store_registers (regcache, regnum); } } diff --git a/gdb/corelow.c b/gdb/corelow.c index f38934e..ea2d386 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -82,7 +82,7 @@ static void core_close (int); static void core_close_cleanup (void *ignore); -static void get_core_registers (int); +static void get_core_registers (struct regcache *, int); static void add_to_thread_list (bfd *, asection *, void *); @@ -375,7 +375,7 @@ core_open (char *filename, int from_tty) if (ontop) { /* Fetch all registers from core file. */ - target_fetch_registers (-1); + target_fetch_registers (current_regcache, -1); /* Now, set up the frame cache, and print the top of stack. */ reinit_frame_cache (); @@ -483,7 +483,7 @@ get_core_register_section (struct regcache *regcache, /* We just get all the registers, so we don't use regno. */ static void -get_core_registers (int regno) +get_core_registers (struct regcache *regcache, int regno) { int status; @@ -495,11 +495,11 @@ get_core_registers (int regno) return; } - get_core_register_section (current_regcache, + get_core_register_section (regcache, ".reg", 0, "general-purpose", 1); - get_core_register_section (current_regcache, + get_core_register_section (regcache, ".reg2", 2, "floating-point", 0); - get_core_register_section (current_regcache, + get_core_register_section (regcache, ".reg-xfp", 3, "extended floating-point", 0); deprecated_registers_fetched (); diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 86712d5..4e8b82e 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2584,8 +2584,8 @@ gnu_pid_to_str (ptid_t ptid) } -extern void gnu_store_registers (int regno); -extern void gnu_fetch_registers (int regno); +extern void gnu_store_registers (struct regcache *regcache, int regno); +extern void gnu_fetch_registers (struct regcache *regcache, int regno); struct target_ops gnu_ops; diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 919b42a..b4b86728 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -174,9 +174,9 @@ static void go32_resume (ptid_t ptid, int step, enum target_signal siggnal); static ptid_t go32_wait (ptid_t ptid, struct target_waitstatus *status); -static void go32_fetch_registers (int regno); -static void store_register (int regno); -static void go32_store_registers (int regno); +static void go32_fetch_registers (struct regcache *, int regno); +static void store_register (const struct regcache *, int regno); +static void go32_store_registers (struct regcache *, int regno); static void go32_prepare_to_store (void); static int go32_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, @@ -465,56 +465,56 @@ go32_wait (ptid_t ptid, struct target_waitstatus *status) } static void -fetch_register (int regno) +fetch_register (struct regcache *regcache, int regno) { if (regno < FP0_REGNUM) - regcache_raw_supply (current_regcache, regno, + regcache_raw_supply (regcache, regno, (char *) &a_tss + regno_mapping[regno].tss_ofs); else if (i386_fp_regnum_p (regno) || i386_fpc_regnum_p (regno)) - i387_supply_fsave (current_regcache, regno, &npx); + i387_supply_fsave (regcache, regno, &npx); else internal_error (__FILE__, __LINE__, _("Invalid register no. %d in fetch_register."), regno); } static void -go32_fetch_registers (int regno) +go32_fetch_registers (struct regcache *regcache, int regno) { if (regno >= 0) - fetch_register (regno); + fetch_register (regcache, regno); else { for (regno = 0; regno < FP0_REGNUM; regno++) - fetch_register (regno); - i387_supply_fsave (current_regcache, -1, &npx); + fetch_register (regcache, regno); + i387_supply_fsave (regcache, -1, &npx); } } static void -store_register (int regno) +store_register (const struct regcache *regcache, int regno) { if (regno < FP0_REGNUM) - regcache_raw_collect (current_regcache, regno, + regcache_raw_collect (regcache, regno, (char *) &a_tss + regno_mapping[regno].tss_ofs); else if (i386_fp_regnum_p (regno) || i386_fpc_regnum_p (regno)) - i387_collect_fsave (current_regcache, regno, &npx); + i387_collect_fsave (regcache, regno, &npx); else internal_error (__FILE__, __LINE__, _("Invalid register no. %d in store_register."), regno); } static void -go32_store_registers (int regno) +go32_store_registers (struct regcache *regcache, int regno) { unsigned r; if (regno >= 0) - store_register (regno); + store_register (regcache, regno); else { for (r = 0; r < FP0_REGNUM; r++) - store_register (r); - i387_collect_fsave (current_regcache, -1, &npx); + store_register (regcache, r); + i387_collect_fsave (regcache, -1, &npx); } } diff --git a/gdb/hppa-hpux-nat.c b/gdb/hppa-hpux-nat.c index 49fd363..fcf681c 100644 --- a/gdb/hppa-hpux-nat.c +++ b/gdb/hppa-hpux-nat.c @@ -87,7 +87,7 @@ hppa_hpux_save_state_offset (struct regcache *regcache, int regnum) #endif static void -hppa_hpux_fetch_register (int regnum) +hppa_hpux_fetch_register (struct regcache *regcache, int regnum) { CORE_ADDR addr; size_t size; @@ -98,7 +98,7 @@ hppa_hpux_fetch_register (int regnum) pid = ptid_get_pid (inferior_ptid); /* This isn't really an address, but ptrace thinks of it as one. */ - addr = hppa_hpux_save_state_offset(current_regcache, regnum); + addr = hppa_hpux_save_state_offset (regcache, regnum); size = register_size (current_gdbarch, regnum); gdb_assert (size == 4 || size == 8); @@ -138,23 +138,23 @@ hppa_hpux_fetch_register (int regnum) store_unsigned_integer ((gdb_byte *)buf, 8, flags); } - regcache_raw_supply (current_regcache, regnum, buf); + regcache_raw_supply (regcache, regnum, buf); } static void -hppa_hpux_fetch_inferior_registers (int regnum) +hppa_hpux_fetch_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1) for (regnum = 0; regnum < NUM_REGS; regnum++) - hppa_hpux_fetch_register (regnum); + hppa_hpux_fetch_register (regcache, regnum); else - hppa_hpux_fetch_register (regnum); + hppa_hpux_fetch_register (regcache, regnum); } /* Store register REGNUM into the inferior. */ static void -hppa_hpux_store_register (int regnum) +hppa_hpux_store_register (struct regcache *regcache, int regnum) { CORE_ADDR addr; size_t size; @@ -164,13 +164,13 @@ hppa_hpux_store_register (int regnum) pid = ptid_get_pid (inferior_ptid); /* This isn't really an address, but ptrace thinks of it as one. */ - addr = hppa_hpux_save_state_offset(current_regcache, regnum); + addr = hppa_hpux_save_state_offset (regcache, regnum); size = register_size (current_gdbarch, regnum); gdb_assert (size == 4 || size == 8); buf = alloca (size); - regcache_raw_collect (current_regcache, regnum, buf); + regcache_raw_collect (regcache, regnum, buf); /* Take care with the "flags" register. It's stored as an `int' in `struct save_state', even for 64-bit code. */ @@ -212,13 +212,13 @@ hppa_hpux_store_register (int regnum) this for all registers (including the floating point registers). */ static void -hppa_hpux_store_inferior_registers (int regnum) +hppa_hpux_store_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1) for (regnum = 0; regnum < NUM_REGS; regnum++) - hppa_hpux_store_register (regnum); + hppa_hpux_store_register (regcache, regnum); else - hppa_hpux_store_register (regnum); + hppa_hpux_store_register (regcache, regnum); } static int diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c index 274f140..ee24856 100644 --- a/gdb/hppa-linux-nat.c +++ b/gdb/hppa-linux-nat.c @@ -216,14 +216,14 @@ static const int greg_map[] = /* Fetch one register. */ static void -fetch_register (int regno) +fetch_register (struct regcache *regcache, int regno) { int tid; int val; if (CANNOT_FETCH_REGISTER (regno)) { - regcache_raw_supply (current_regcache, regno, NULL); + regcache_raw_supply (regcache, regno, NULL); return; } @@ -238,13 +238,13 @@ fetch_register (int regno) error (_("Couldn't read register %s (#%d): %s."), REGISTER_NAME (regno), regno, safe_strerror (errno)); - regcache_raw_supply (current_regcache, regno, &val); + regcache_raw_supply (regcache, regno, &val); } /* Store one register. */ static void -store_register (int regno) +store_register (const struct regcache *regcache, int regno) { int tid; int val; @@ -258,7 +258,7 @@ store_register (int regno) tid = PIDGET (inferior_ptid); /* Not a threaded program. */ errno = 0; - regcache_raw_collect (current_regcache, regno, &val); + regcache_raw_collect (regcache, regno, &val); ptrace (PTRACE_POKEUSER, tid, hppa_linux_register_addr (regno, 0), val); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), REGISTER_NAME (regno), @@ -270,16 +270,16 @@ store_register (int regno) point registers depending upon the value of regno. */ static void -hppa_linux_fetch_inferior_registers (int regno) +hppa_linux_fetch_inferior_registers (struct regcache *regcache, int regno) { if (-1 == regno) { for (regno = 0; regno < NUM_REGS; regno++) - fetch_register (regno); + fetch_register (regcache, regno); } else { - fetch_register (regno); + fetch_register (regcache, regno); } } @@ -288,16 +288,16 @@ hppa_linux_fetch_inferior_registers (int regno) point registers depending upon the value of regno. */ static void -hppa_linux_store_inferior_registers (int regno) +hppa_linux_store_inferior_registers (struct regcache *regcache, int regno) { if (-1 == regno) { for (regno = 0; regno < NUM_REGS; regno++) - store_register (regno); + store_register (regcache, regno); } else { - store_register (regno); + store_register (regcache, regno); } } diff --git a/gdb/hppabsd-nat.c b/gdb/hppabsd-nat.c index 1ffcbfd..a3c8ab5 100644 --- a/gdb/hppabsd-nat.c +++ b/gdb/hppabsd-nat.c @@ -124,10 +124,8 @@ hppabsd_collect_fpregset (struct regcache *regcache, for all registers (including the floating-point registers). */ static void -hppabsd_fetch_registers (int regnum) +hppabsd_fetch_registers (struct regcache *regcache, int regnum) { - struct regcache *regcache = current_regcache; - if (regnum == -1 || hppabsd_gregset_supplies_p (regnum)) { struct reg regs; @@ -147,7 +145,7 @@ hppabsd_fetch_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - hppabsd_supply_fpregset (current_regcache, &fpregs); + hppabsd_supply_fpregset (regcache, &fpregs); } } @@ -155,7 +153,7 @@ hppabsd_fetch_registers (int regnum) this for all registers (including the floating-point registers). */ static void -hppabsd_store_registers (int regnum) +hppabsd_store_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || hppabsd_gregset_supplies_p (regnum)) { @@ -165,7 +163,7 @@ hppabsd_store_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - hppabsd_collect_gregset (current_regcache, ®s, regnum); + hppabsd_collect_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) @@ -180,7 +178,7 @@ hppabsd_store_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - hppabsd_collect_fpregset (current_regcache, &fpregs, regnum); + hppabsd_collect_fpregset (regcache, &fpregs, regnum); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) diff --git a/gdb/hpux-thread.c b/gdb/hpux-thread.c index a3640b8..f65208c 100644 --- a/gdb/hpux-thread.c +++ b/gdb/hpux-thread.c @@ -249,7 +249,7 @@ static char regmap[] = }; static void -hpux_thread_fetch_registers (int regno) +hpux_thread_fetch_registers (struct regcache *regcache, int regno) { cma__t_int_tcb tcb, *tcb_ptr; struct cleanup *old_chain; @@ -264,7 +264,7 @@ hpux_thread_fetch_registers (int regno) if (tcb_ptr->state == cma__c_state_running) { - deprecated_child_ops.to_fetch_registers (regno); + deprecated_child_ops.to_fetch_registers (regcache, regno); do_cleanups (old_chain); @@ -285,7 +285,7 @@ hpux_thread_fetch_registers (int regno) for (regno = first_regno; regno <= last_regno; regno++) { if (regmap[regno] == -1) - deprecated_child_ops.to_fetch_registers (regno); + deprecated_child_ops.to_fetch_registers (regcache, regno); else { unsigned char buf[MAX_REGISTER_SIZE]; @@ -303,7 +303,7 @@ hpux_thread_fetch_registers (int regno) else read_memory (sp + regmap[regno], buf, register_size (current_gdbarch, regno)); - regcache_raw_supply (current_regcache, regno, buf); + regcache_raw_supply (regcache, regno, buf); } } @@ -311,7 +311,7 @@ hpux_thread_fetch_registers (int regno) } static void -hpux_thread_store_registers (int regno) +hpux_thread_store_registers (struct regcache *regcache, int regno) { cma__t_int_tcb tcb, *tcb_ptr; struct cleanup *old_chain; @@ -326,7 +326,7 @@ hpux_thread_store_registers (int regno) if (tcb_ptr->state == cma__c_state_running) { - deprecated_child_ops.to_store_registers (regno); + deprecated_child_ops.to_store_registers (regcache, regno); do_cleanups (old_chain); @@ -347,7 +347,7 @@ hpux_thread_store_registers (int regno) for (regno = first_regno; regno <= last_regno; regno++) { if (regmap[regno] == -1) - deprecated_child_ops.to_store_registers (regno); + deprecated_child_ops.to_store_registers (regcache, regno); else { unsigned char buf[MAX_REGISTER_SIZE]; @@ -356,10 +356,10 @@ hpux_thread_store_registers (int regno) sp = (CORE_ADDR) tcb_ptr->static_ctx.sp - 160; if (regno == HPPA_FLAGS_REGNUM) - deprecated_child_ops.to_store_registers (regno); /* Let lower layer handle this... */ + deprecated_child_ops.to_store_registers (regcache, regno); /* Let lower layer handle this... */ else if (regno == HPPA_SP_REGNUM) { - regcache_raw_collect (current_regcache, regno, buf); + regcache_raw_collect (regcache, regno, buf); write_memory ((CORE_ADDR) &tcb_ptr->static_ctx.sp, buf, register_size (current_gdbarch, regno)); tcb_ptr->static_ctx.sp @@ -367,13 +367,13 @@ hpux_thread_store_registers (int regno) } else if (regno == HPPA_PCOQ_HEAD_REGNUM) { - regcache_raw_collect (current_regcache, regno, buf); + regcache_raw_collect (regcache, regno, buf); write_memory (sp - 20, buf, register_size (current_gdbarch, regno)); } else { - regcache_raw_collect (current_regcache, regno, buf); + regcache_raw_collect (regcache, regno, buf); write_memory (sp + regmap[regno], buf, register_size (current_gdbarch, regno)); } diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index bfa099d..7a71c60 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -142,7 +142,7 @@ int have_ptrace_getfpxregs = /* Fetch one register. */ static void -fetch_register (int regno) +fetch_register (struct regcache *regcache, int regno) { int tid; int val; @@ -150,7 +150,7 @@ fetch_register (int regno) gdb_assert (!have_ptrace_getregs); if (regmap[regno] == -1) { - regcache_raw_supply (current_regcache, regno, NULL); + regcache_raw_supply (regcache, regno, NULL); return; } @@ -165,13 +165,13 @@ fetch_register (int regno) error (_("Couldn't read register %s (#%d): %s."), REGISTER_NAME (regno), regno, safe_strerror (errno)); - regcache_raw_supply (current_regcache, regno, &val); + regcache_raw_supply (regcache, regno, &val); } /* Store one register. */ static void -store_register (int regno) +store_register (const struct regcache *regcache, int regno) { int tid; int val; @@ -186,7 +186,7 @@ store_register (int regno) tid = PIDGET (inferior_ptid); /* Not a threaded program. */ errno = 0; - regcache_raw_collect (current_regcache, regno, &val); + regcache_raw_collect (regcache, regno, &val); ptrace (PTRACE_POKEUSER, tid, 4 * regmap[regno], val); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), REGISTER_NAME (regno), @@ -241,7 +241,7 @@ fill_gregset (const struct regcache *regcache, store their values in GDB's register array. */ static void -fetch_regs (int tid) +fetch_regs (struct regcache *regcache, int tid) { elf_gregset_t regs; @@ -258,21 +258,21 @@ fetch_regs (int tid) perror_with_name (_("Couldn't get registers")); } - supply_gregset (current_regcache, (const elf_gregset_t *) ®s); + supply_gregset (regcache, (const elf_gregset_t *) ®s); } /* Store all valid general-purpose registers in GDB's register array into the process/thread specified by TID. */ static void -store_regs (int tid, int regno) +store_regs (const struct regcache *regcache, int tid, int regno) { elf_gregset_t regs; if (ptrace (PTRACE_GETREGS, tid, 0, (int) ®s) < 0) perror_with_name (_("Couldn't get registers")); - fill_gregset (current_regcache, ®s, regno); + fill_gregset (regcache, ®s, regno); if (ptrace (PTRACE_SETREGS, tid, 0, (int) ®s) < 0) perror_with_name (_("Couldn't write registers")); @@ -280,8 +280,8 @@ store_regs (int tid, int regno) #else -static void fetch_regs (int tid) {} -static void store_regs (int tid, int regno) {} +static void fetch_regs (struct regcache *regcache, int tid) {} +static void store_regs (const struct regcache *regcache, int tid, int regno) {} #endif @@ -314,28 +314,28 @@ fill_fpregset (const struct regcache *regcache, thier values in GDB's register array. */ static void -fetch_fpregs (int tid) +fetch_fpregs (struct regcache *regcache, int tid) { elf_fpregset_t fpregs; if (ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs) < 0) perror_with_name (_("Couldn't get floating point status")); - supply_fpregset (current_regcache, (const elf_fpregset_t *) &fpregs); + supply_fpregset (regcache, (const elf_fpregset_t *) &fpregs); } /* Store all valid floating-point registers in GDB's register array into the process/thread specified by TID. */ static void -store_fpregs (int tid, int regno) +store_fpregs (const struct regcache *regcache, int tid, int regno) { elf_fpregset_t fpregs; if (ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs) < 0) perror_with_name (_("Couldn't get floating point status")); - fill_fpregset (current_regcache, &fpregs, regno); + fill_fpregset (regcache, &fpregs, regno); if (ptrace (PTRACE_SETFPREGS, tid, 0, (int) &fpregs) < 0) perror_with_name (_("Couldn't write floating point status")); @@ -343,8 +343,8 @@ store_fpregs (int tid, int regno) #else -static void fetch_fpregs (int tid) {} -static void store_fpregs (int tid, int regno) {} +static void fetch_fpregs (struct regcache *regcache, int tid) {} +static void store_fpregs (const struct regcache *regcache, int tid, int regno) {} #endif @@ -379,7 +379,7 @@ fill_fpxregset (const struct regcache *regcache, Return non-zero if successful, zero otherwise. */ static int -fetch_fpxregs (int tid) +fetch_fpxregs (struct regcache *regcache, int tid) { elf_fpxregset_t fpxregs; @@ -397,7 +397,7 @@ fetch_fpxregs (int tid) perror_with_name (_("Couldn't read floating-point and SSE registers")); } - supply_fpxregset (current_regcache, (const elf_fpxregset_t *) &fpxregs); + supply_fpxregset (regcache, (const elf_fpxregset_t *) &fpxregs); return 1; } @@ -406,7 +406,7 @@ fetch_fpxregs (int tid) Return non-zero if successful, zero otherwise. */ static int -store_fpxregs (int tid, int regno) +store_fpxregs (const struct regcache *regcache, int tid, int regno) { elf_fpxregset_t fpxregs; @@ -424,7 +424,7 @@ store_fpxregs (int tid, int regno) perror_with_name (_("Couldn't read floating-point and SSE registers")); } - fill_fpxregset (current_regcache, &fpxregs, regno); + fill_fpxregset (regcache, &fpxregs, regno); if (ptrace (PTRACE_SETFPXREGS, tid, 0, &fpxregs) == -1) perror_with_name (_("Couldn't write floating-point and SSE registers")); @@ -434,8 +434,8 @@ store_fpxregs (int tid, int regno) #else -static int fetch_fpxregs (int tid) { return 0; } -static int store_fpxregs (int tid, int regno) { return 0; } +static int fetch_fpxregs (struct regcache *regcache, int tid) { return 0; } +static int store_fpxregs (const struct regcache *regcache, int tid, int regno) { return 0; } #endif /* HAVE_PTRACE_GETFPXREGS */ @@ -447,7 +447,7 @@ static int store_fpxregs (int tid, int regno) { return 0; } registers). */ static void -i386_linux_fetch_inferior_registers (int regno) +i386_linux_fetch_inferior_registers (struct regcache *regcache, int regno) { int tid; @@ -459,7 +459,7 @@ i386_linux_fetch_inferior_registers (int regno) for (i = 0; i < NUM_REGS; i++) if (regno == -1 || regno == i) - fetch_register (i); + fetch_register (regcache, i); return; } @@ -475,30 +475,30 @@ i386_linux_fetch_inferior_registers (int regno) zero. */ if (regno == -1) { - fetch_regs (tid); + fetch_regs (regcache, tid); /* The call above might reset `have_ptrace_getregs'. */ if (!have_ptrace_getregs) { - i386_linux_fetch_inferior_registers (regno); + i386_linux_fetch_inferior_registers (regcache, regno); return; } - if (fetch_fpxregs (tid)) + if (fetch_fpxregs (regcache, tid)) return; - fetch_fpregs (tid); + fetch_fpregs (regcache, tid); return; } if (GETREGS_SUPPLIES (regno)) { - fetch_regs (tid); + fetch_regs (regcache, tid); return; } if (GETFPXREGS_SUPPLIES (regno)) { - if (fetch_fpxregs (tid)) + if (fetch_fpxregs (regcache, tid)) return; /* Either our processor or our kernel doesn't support the SSE @@ -507,7 +507,7 @@ i386_linux_fetch_inferior_registers (int regno) more graceful to handle differences in the register set using gdbarch. Until then, this will at least make things work plausibly. */ - fetch_fpregs (tid); + fetch_fpregs (regcache, tid); return; } @@ -519,7 +519,7 @@ i386_linux_fetch_inferior_registers (int regno) do this for all registers (including the floating point and SSE registers). */ static void -i386_linux_store_inferior_registers (int regno) +i386_linux_store_inferior_registers (struct regcache *regcache, int regno) { int tid; @@ -531,7 +531,7 @@ i386_linux_store_inferior_registers (int regno) for (i = 0; i < NUM_REGS; i++) if (regno == -1 || regno == i) - store_register (i); + store_register (regcache, i); return; } @@ -546,28 +546,28 @@ i386_linux_store_inferior_registers (int regno) store_fpxregs can fail, and return zero. */ if (regno == -1) { - store_regs (tid, regno); - if (store_fpxregs (tid, regno)) + store_regs (regcache, tid, regno); + if (store_fpxregs (regcache, tid, regno)) return; - store_fpregs (tid, regno); + store_fpregs (regcache, tid, regno); return; } if (GETREGS_SUPPLIES (regno)) { - store_regs (tid, regno); + store_regs (regcache, tid, regno); return; } if (GETFPXREGS_SUPPLIES (regno)) { - if (store_fpxregs (tid, regno)) + if (store_fpxregs (regcache, tid, regno)) return; /* Either our processor or our kernel doesn't support the SSE registers, so just write the FP registers in the traditional way. */ - store_fpregs (tid, regno); + store_fpregs (regcache, tid, regno); return; } diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c index b64ae69..8dc2713 100644 --- a/gdb/i386bsd-nat.c +++ b/gdb/i386bsd-nat.c @@ -132,7 +132,7 @@ i386bsd_collect_gregset (const struct regcache *regcache, for all registers (including the floating point registers). */ static void -i386bsd_fetch_inferior_registers (int regnum) +i386bsd_fetch_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { @@ -142,7 +142,7 @@ i386bsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - i386bsd_supply_gregset (current_regcache, ®s); + i386bsd_supply_gregset (regcache, ®s); if (regnum != -1) return; } @@ -158,7 +158,7 @@ i386bsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) xmmregs, 0) == 0) { have_ptrace_xmmregs = 1; - i387_supply_fxsave (current_regcache, -1, xmmregs); + i387_supply_fxsave (regcache, -1, xmmregs); } else { @@ -166,14 +166,14 @@ i386bsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - i387_supply_fsave (current_regcache, -1, &fpregs); + i387_supply_fsave (regcache, -1, &fpregs); } #else if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - i387_supply_fsave (current_regcache, -1, &fpregs); + i387_supply_fsave (regcache, -1, &fpregs); #endif } } @@ -182,7 +182,7 @@ i386bsd_fetch_inferior_registers (int regnum) this for all registers (including the floating point registers). */ static void -i386bsd_store_inferior_registers (int regnum) +i386bsd_store_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || GETREGS_SUPPLIES (regnum)) { @@ -192,7 +192,7 @@ i386bsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - i386bsd_collect_gregset (current_regcache, ®s, regnum); + i386bsd_collect_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) @@ -214,7 +214,7 @@ i386bsd_store_inferior_registers (int regnum) { have_ptrace_xmmregs = 1; - i387_collect_fxsave (current_regcache, regnum, xmmregs); + i387_collect_fxsave (regcache, regnum, xmmregs); if (ptrace (PT_SETXMMREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) xmmregs, 0) == -1) @@ -228,7 +228,7 @@ i386bsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - i387_collect_fsave (current_regcache, regnum, &fpregs); + i387_collect_fsave (regcache, regnum, &fpregs); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) diff --git a/gdb/i386gnu-nat.c b/gdb/i386gnu-nat.c index 3b61997..3547cd5 100644 --- a/gdb/i386gnu-nat.c +++ b/gdb/i386gnu-nat.c @@ -66,7 +66,7 @@ static int reg_offset[] = of the corresponding (pseudo) registers. */ static void -fetch_fpregs (struct proc *thread) +fetch_fpregs (struct regcache *regcache, struct proc *thread) { mach_msg_type_number_t count = i386_FLOAT_STATE_COUNT; struct i386_float_state state; @@ -84,12 +84,12 @@ fetch_fpregs (struct proc *thread) if (!state.initialized) { /* The floating-point state isn't initialized. */ - i387_supply_fsave (current_regcache, -1, NULL); + i387_supply_fsave (regcache, -1, NULL); } else { /* Supply the floating-point registers. */ - i387_supply_fsave (current_regcache, -1, state.hw_state); + i387_supply_fsave (regcache, -1, state.hw_state); } } @@ -113,7 +113,7 @@ supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregs) /* Fetch register REGNO, or all regs if REGNO is -1. */ void -gnu_fetch_registers (int regno) +gnu_fetch_registers (struct regcache *regcache, int regno) { struct proc *thread; @@ -145,14 +145,14 @@ gnu_fetch_registers (int regno) proc_debug (thread, "fetching all register"); for (i = 0; i < I386_NUM_GREGS; i++) - regcache_raw_supply (current_regcache, i, REG_ADDR (state, i)); + regcache_raw_supply (regcache, i, REG_ADDR (state, i)); thread->fetched_regs = ~0; } else { proc_debug (thread, "fetching register %s", REGISTER_NAME (regno)); - regcache_raw_supply (current_regcache, regno, + regcache_raw_supply (regcache, regno, REG_ADDR (state, regno)); thread->fetched_regs |= (1 << regno); } @@ -162,7 +162,7 @@ gnu_fetch_registers (int regno) { proc_debug (thread, "fetching floating-point registers"); - fetch_fpregs (thread); + fetch_fpregs (regcache, thread); } } @@ -170,7 +170,7 @@ gnu_fetch_registers (int regno) /* Store the whole floating-point state into THREAD using information from the corresponding (pseudo) registers. */ static void -store_fpregs (struct proc *thread, int regno) +store_fpregs (const struct regcache *regcache, struct proc *thread, int regno) { mach_msg_type_number_t count = i386_FLOAT_STATE_COUNT; struct i386_float_state state; @@ -187,7 +187,7 @@ store_fpregs (struct proc *thread, int regno) /* FIXME: kettenis/2001-07-15: Is this right? Should we somehow take into account DEPRECATED_REGISTER_VALID like the old code did? */ - i387_collect_fsave (current_regcache, regno, state.hw_state); + i387_collect_fsave (regcache, regno, state.hw_state); err = thread_set_state (thread->port, i386_FLOAT_STATE, (thread_state_t) &state, i386_FLOAT_STATE_COUNT); @@ -201,9 +201,8 @@ store_fpregs (struct proc *thread, int regno) /* Store at least register REGNO, or all regs if REGNO == -1. */ void -gnu_store_registers (int regno) +gnu_store_registers (struct regcache *regcache, int regno) { - struct regcache *regcache = current_regcache; struct proc *thread; /* Make sure we know about new threads. */ @@ -286,6 +285,6 @@ gnu_store_registers (int regno) { proc_debug (thread, "storing floating-point registers"); - store_fpregs (thread, regno); + store_fpregs (regcache, thread, regno); } } diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c index 8207be4..dbe6e53 100644 --- a/gdb/ia64-linux-nat.c +++ b/gdb/ia64-linux-nat.c @@ -666,7 +666,7 @@ ia64_linux_can_use_hw_breakpoint (int type, int cnt, int othertype) /* Fetch register REGNUM from the inferior. */ static void -ia64_linux_fetch_register (int regnum) +ia64_linux_fetch_register (struct regcache *regcache, int regnum) { CORE_ADDR addr; size_t size; @@ -675,7 +675,7 @@ ia64_linux_fetch_register (int regnum) if (ia64_cannot_fetch_register (regnum)) { - regcache_raw_supply (current_regcache, regnum, NULL); + regcache_raw_supply (regcache, regnum, NULL); return; } @@ -703,26 +703,26 @@ ia64_linux_fetch_register (int regnum) addr += sizeof (PTRACE_TYPE_RET); } - regcache_raw_supply (current_regcache, regnum, buf); + regcache_raw_supply (regcache, regnum, buf); } /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this for all registers. */ static void -ia64_linux_fetch_registers (int regnum) +ia64_linux_fetch_registers (struct regcache *regcache, int regnum) { if (regnum == -1) for (regnum = 0; regnum < NUM_REGS; regnum++) - ia64_linux_fetch_register (regnum); + ia64_linux_fetch_register (regcache, regnum); else - ia64_linux_fetch_register (regnum); + ia64_linux_fetch_register (regcache, regnum); } /* Store register REGNUM into the inferior. */ static void -ia64_linux_store_register (int regnum) +ia64_linux_store_register (const struct regcache *regcache, int regnum) { CORE_ADDR addr; size_t size; @@ -746,7 +746,7 @@ ia64_linux_store_register (int regnum) buf = alloca (size); /* Write the register contents into the inferior a chunk at a time. */ - regcache_raw_collect (current_regcache, regnum, buf); + regcache_raw_collect (regcache, regnum, buf); for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++) { errno = 0; @@ -763,13 +763,13 @@ ia64_linux_store_register (int regnum) this for all registers. */ static void -ia64_linux_store_registers (int regnum) +ia64_linux_store_registers (struct regcache *regcache, int regnum) { if (regnum == -1) for (regnum = 0; regnum < NUM_REGS; regnum++) - ia64_linux_store_register (regnum); + ia64_linux_store_register (regcache, regnum); else - ia64_linux_store_register (regnum); + ia64_linux_store_register (regcache, regnum); } diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 09c3706..a4ddfff 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -3540,7 +3540,7 @@ ia64_store_return_value (struct type *type, struct regcache *regcache, char to[MAX_REGISTER_SIZE]; convert_typed_floating (valbuf, type, to, builtin_type_ia64_ext); regcache_cooked_write (regcache, IA64_FR8_REGNUM, (void *)to); - target_store_registers (IA64_FR8_REGNUM); + target_store_registers (regcache, IA64_FR8_REGNUM); } else regcache_cooked_write (regcache, IA64_GR8_REGNUM, valbuf); diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 5b51fe3..00bb7fd 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -33,22 +33,22 @@ for all registers. */ static void -inf_child_fetch_inferior_registers (int regnum) +inf_child_fetch_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1) { for (regnum = 0; regnum < NUM_REGS; regnum++) - regcache_raw_supply (current_regcache, regnum, NULL); + regcache_raw_supply (regcache, regnum, NULL); } else - regcache_raw_supply (current_regcache, regnum, NULL); + regcache_raw_supply (regcache, regnum, NULL); } /* Store register REGNUM back into the inferior. If REGNUM is -1, do this for all registers (including the floating point registers). */ static void -inf_child_store_inferior_registers (int regnum) +inf_child_store_inferior_registers (struct regcache *regcache, int regnum) { } diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index bef45b5..bc3219e 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -617,7 +617,7 @@ static CORE_ADDR (*inf_ptrace_register_u_offset)(int); /* Fetch register REGNUM from the inferior. */ static void -inf_ptrace_fetch_register (int regnum) +inf_ptrace_fetch_register (struct regcache *regcache, int regnum) { CORE_ADDR addr; size_t size; @@ -626,7 +626,7 @@ inf_ptrace_fetch_register (int regnum) if (CANNOT_FETCH_REGISTER (regnum)) { - regcache_raw_supply (current_regcache, regnum, NULL); + regcache_raw_supply (regcache, regnum, NULL); return; } @@ -654,26 +654,26 @@ inf_ptrace_fetch_register (int regnum) addr += sizeof (PTRACE_TYPE_RET); } - regcache_raw_supply (current_regcache, regnum, buf); + regcache_raw_supply (regcache, regnum, buf); } /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this for all registers. */ static void -inf_ptrace_fetch_registers (int regnum) +inf_ptrace_fetch_registers (struct regcache *regcache, int regnum) { if (regnum == -1) for (regnum = 0; regnum < NUM_REGS; regnum++) - inf_ptrace_fetch_register (regnum); + inf_ptrace_fetch_register (regcache, regnum); else - inf_ptrace_fetch_register (regnum); + inf_ptrace_fetch_register (regcache, regnum); } /* Store register REGNUM into the inferior. */ static void -inf_ptrace_store_register (int regnum) +inf_ptrace_store_register (const struct regcache *regcache, int regnum) { CORE_ADDR addr; size_t size; @@ -697,7 +697,7 @@ inf_ptrace_store_register (int regnum) buf = alloca (size); /* Write the register contents into the inferior a chunk at a time. */ - regcache_raw_collect (current_regcache, regnum, buf); + regcache_raw_collect (regcache, regnum, buf); for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++) { errno = 0; @@ -714,13 +714,13 @@ inf_ptrace_store_register (int regnum) this for all registers. */ void -inf_ptrace_store_registers (int regnum) +inf_ptrace_store_registers (struct regcache *regcache, int regnum) { if (regnum == -1) for (regnum = 0; regnum < NUM_REGS; regnum++) - inf_ptrace_store_register (regnum); + inf_ptrace_store_register (regcache, regnum); else - inf_ptrace_store_register (regnum); + inf_ptrace_store_register (regcache, regnum); } /* Create a "traditional" ptrace target. REGISTER_U_OFFSET should be diff --git a/gdb/inferior.h b/gdb/inferior.h index cbfc459..e93e413 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -209,9 +209,9 @@ extern void default_print_registers_info (struct gdbarch *gdbarch, struct frame_info *frame, int regnum, int all); -extern void store_inferior_registers (int); +extern void store_inferior_registers (struct regcache *, int); -extern void fetch_inferior_registers (int); +extern void fetch_inferior_registers (struct regcache *, int); extern void child_terminal_info (char *, int); diff --git a/gdb/infptrace.c b/gdb/infptrace.c index f10a26a..d3bd1d5 100644 --- a/gdb/infptrace.c +++ b/gdb/infptrace.c @@ -203,7 +203,7 @@ detach (int signal) /* Fetch register REGNUM from the inferior. */ static void -fetch_register (int regnum) +fetch_register (struct regcache *regcache, int regnum) { CORE_ADDR addr; size_t size; @@ -212,7 +212,7 @@ fetch_register (int regnum) if (CANNOT_FETCH_REGISTER (regnum)) { - regcache_raw_supply (current_regcache, regnum, NULL); + regcache_raw_supply (regcache, regnum, NULL); return; } @@ -239,26 +239,26 @@ fetch_register (int regnum) addr += sizeof (PTRACE_TYPE_RET); } - regcache_raw_supply (current_regcache, regnum, buf); + regcache_raw_supply (regcache, regnum, buf); } /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this for all registers. */ void -fetch_inferior_registers (int regnum) +fetch_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1) for (regnum = 0; regnum < NUM_REGS; regnum++) - fetch_register (regnum); + fetch_register (regcache, regnum); else - fetch_register (regnum); + fetch_register (regcache, regnum); } /* Store register REGNUM into the inferior. */ static void -store_register (int regnum) +store_register (const struct regcache *regcache, int regnum) { CORE_ADDR addr; size_t size; @@ -281,7 +281,7 @@ store_register (int regnum) buf = alloca (size); /* Write the register contents into the inferior a chunk at the time. */ - regcache_raw_collect (current_regcache, regnum, buf); + regcache_raw_collect (regcache, regnum, buf); for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++) { errno = 0; @@ -298,13 +298,13 @@ store_register (int regnum) this for all registers (including the floating point registers). */ void -store_inferior_registers (int regnum) +store_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1) for (regnum = 0; regnum < NUM_REGS; regnum++) - store_register (regnum); + store_register (regcache, regnum); else - store_register (regnum); + store_register (regcache, regnum); } #endif /* not FETCH_INFERIOR_REGISTERS. */ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 4665581..3345cb7 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -2650,8 +2650,8 @@ linux_nat_corefile_thread_callback (struct lwp_info *ti, void *data) inferior_ptid = ti->ptid; registers_changed (); - target_fetch_registers (-1); /* FIXME should not be necessary; - fill_gregset should do it automatically. */ + /* 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, @@ -2659,8 +2659,9 @@ linux_nat_corefile_thread_callback (struct lwp_info *ti, void *data) args->num_notes++; inferior_ptid = saved_ptid; registers_changed (); - target_fetch_registers (-1); /* FIXME should not be necessary; - fill_gregset should do it automatically. */ + /* FIXME should not be necessary; fill_gregset should do it automatically. */ + target_fetch_registers (current_regcache, -1); + return 0; } @@ -2671,8 +2672,8 @@ linux_nat_do_registers (bfd *obfd, ptid_t ptid, char *note_data, int *note_size) { registers_changed (); - target_fetch_registers (-1); /* FIXME should not be necessary; - fill_gregset should do it automatically. */ + /* 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), diff --git a/gdb/m32r-linux-nat.c b/gdb/m32r-linux-nat.c index 32d3de9..2042024 100644 --- a/gdb/m32r-linux-nat.c +++ b/gdb/m32r-linux-nat.c @@ -108,14 +108,14 @@ supply_gregset (struct regcache *regcache, const elf_gregset_t * gregsetp) store their values in GDB's register array. */ static void -fetch_regs (int tid) +fetch_regs (struct regcache *regcache, int tid) { elf_gregset_t regs; if (ptrace (PTRACE_GETREGS, tid, 0, (int) ®s) < 0) perror_with_name (_("Couldn't get registers")); - supply_gregset (current_regcache, (const elf_gregset_t *) ®s); + supply_gregset (regcache, (const elf_gregset_t *) ®s); } /* Fill register REGNO (if it is a general-purpose register) in @@ -157,14 +157,14 @@ fill_gregset (const struct regcache *regcache, into the process/thread specified by TID. */ static void -store_regs (int tid, int regno) +store_regs (const struct regcache *regcache, int tid, int regno) { elf_gregset_t regs; if (ptrace (PTRACE_GETREGS, tid, 0, (int) ®s) < 0) perror_with_name (_("Couldn't get registers")); - fill_gregset (current_regcache, ®s, regno); + fill_gregset (regcache, ®s, regno); if (ptrace (PTRACE_SETREGS, tid, 0, (int) ®s) < 0) perror_with_name (_("Couldn't write registers")); @@ -195,7 +195,7 @@ fill_fpregset (const struct regcache *regcache, registers). */ static void -m32r_linux_fetch_inferior_registers (int regno) +m32r_linux_fetch_inferior_registers (struct regcache *regcache, int regno) { int tid; @@ -209,7 +209,7 @@ m32r_linux_fetch_inferior_registers (int regno) results. */ if (regno == -1 || GETREGS_SUPPLIES (regno)) { - fetch_regs (tid); + fetch_regs (regcache, tid); return; } @@ -221,7 +221,7 @@ m32r_linux_fetch_inferior_registers (int regno) do this for all registers (including the floating point and SSE registers). */ static void -m32r_linux_store_inferior_registers (int regno) +m32r_linux_store_inferior_registers (struct regcache *regcache, int regno) { int tid; @@ -233,7 +233,7 @@ m32r_linux_store_inferior_registers (int regno) transfers more registers in one system call. */ if (regno == -1 || GETREGS_SUPPLIES (regno)) { - store_regs (tid, regno); + store_regs (regcache, tid, regno); return; } diff --git a/gdb/m68kbsd-nat.c b/gdb/m68kbsd-nat.c index b1a68a6..fccc042 100644 --- a/gdb/m68kbsd-nat.c +++ b/gdb/m68kbsd-nat.c @@ -108,7 +108,7 @@ m68kbsd_collect_fpregset (struct regcache *regcache, for all registers (including the floating-point registers). */ static void -m68kbsd_fetch_inferior_registers (int regnum) +m68kbsd_fetch_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum)) { @@ -118,7 +118,7 @@ m68kbsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - m68kbsd_supply_gregset (current_regcache, ®s); + m68kbsd_supply_gregset (regcache, ®s); } if (regnum == -1 || m68kbsd_fpregset_supplies_p (regnum)) @@ -129,7 +129,7 @@ m68kbsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - m68kbsd_supply_fpregset (current_regcache, &fpregs); + m68kbsd_supply_fpregset (regcache, &fpregs); } } @@ -137,7 +137,7 @@ m68kbsd_fetch_inferior_registers (int regnum) this for all registers (including the floating-point registers). */ static void -m68kbsd_store_inferior_registers (int regnum) +m68kbsd_store_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || m68kbsd_gregset_supplies_p (regnum)) { @@ -147,7 +147,7 @@ m68kbsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - m68kbsd_collect_gregset (current_regcache, ®s, regnum); + m68kbsd_collect_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) @@ -162,7 +162,7 @@ m68kbsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - m68kbsd_collect_fpregset (current_regcache, &fpregs, regnum); + m68kbsd_collect_fpregset (regcache, &fpregs, regnum); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c index 2a25b34..96bf524 100644 --- a/gdb/m68klinux-nat.c +++ b/gdb/m68klinux-nat.c @@ -114,7 +114,7 @@ int have_ptrace_getregs = /* Fetch one register. */ static void -fetch_register (int regno) +fetch_register (struct regcache *regcache, int regno) { /* This isn't really an address. But ptrace thinks of it as one. */ CORE_ADDR regaddr; @@ -126,7 +126,7 @@ fetch_register (int regno) if (CANNOT_FETCH_REGISTER (regno)) { memset (buf, '\0', register_size (current_gdbarch, regno)); /* Supply zeroes */ - regcache_raw_supply (current_regcache, regno, buf); + regcache_raw_supply (regcache, regno, buf); return; } @@ -150,7 +150,7 @@ fetch_register (int regno) perror_with_name (mess); } } - regcache_raw_supply (current_regcache, regno, buf); + regcache_raw_supply (regcache, regno, buf); } /* Fetch register values from the inferior. @@ -158,17 +158,17 @@ fetch_register (int regno) Otherwise, REGNO specifies which register (so we can save time). */ static void -old_fetch_inferior_registers (int regno) +old_fetch_inferior_registers (struct regcache *regcache, int regno) { if (regno >= 0) { - fetch_register (regno); + fetch_register (regcache, regno); } else { for (regno = 0; regno < NUM_REGS; regno++) { - fetch_register (regno); + fetch_register (regcache, regno); } } } @@ -176,7 +176,7 @@ old_fetch_inferior_registers (int regno) /* Store one register. */ static void -store_register (int regno) +store_register (const struct regcache *regcache, int regno) { /* This isn't really an address. But ptrace thinks of it as one. */ CORE_ADDR regaddr; @@ -198,7 +198,7 @@ store_register (int regno) regaddr = 4 * regmap[regno]; /* Put the contents of regno into a local buffer */ - regcache_raw_collect (current_regcache, regno, buf); + regcache_raw_collect (regcache, regno, buf); /* Store the local buffer into the inferior a chunk at the time. */ for (i = 0; i < register_size (current_gdbarch, regno); @@ -222,17 +222,17 @@ store_register (int regno) Otherwise, REGNO specifies which register (so we can save time). */ static void -old_store_inferior_registers (int regno) +old_store_inferior_registers (const struct regcache *regcache, int regno) { if (regno >= 0) { - store_register (regno); + store_register (regcache, regno); } else { for (regno = 0; regno < NUM_REGS; regno++) { - store_register (regno); + store_register (regcache, regno); } } } @@ -274,7 +274,7 @@ fill_gregset (const struct regcache *regcache, store their values in GDB's register array. */ static void -fetch_regs (int tid) +fetch_regs (struct regcache *regcache, int tid) { elf_gregset_t regs; @@ -291,21 +291,21 @@ fetch_regs (int tid) perror_with_name (_("Couldn't get registers")); } - supply_gregset (current_regcache, (const elf_gregset_t *) ®s); + supply_gregset (regcache, (const elf_gregset_t *) ®s); } /* Store all valid general-purpose registers in GDB's register array into the process/thread specified by TID. */ static void -store_regs (int tid, int regno) +store_regs (const struct regcache *regcache, int tid, int regno) { elf_gregset_t regs; if (ptrace (PTRACE_GETREGS, tid, 0, (int) ®s) < 0) perror_with_name (_("Couldn't get registers")); - fill_gregset (current_regcache, ®s, regno); + fill_gregset (regcache, ®s, regno); if (ptrace (PTRACE_SETREGS, tid, 0, (int) ®s) < 0) perror_with_name (_("Couldn't write registers")); @@ -313,8 +313,8 @@ store_regs (int tid, int regno) #else -static void fetch_regs (int tid) {} -static void store_regs (int tid, int regno) {} +static void fetch_regs (struct regcache *regcache, int tid) {} +static void store_regs (const struct regcache *regcache, int tid, int regno) {} #endif @@ -369,28 +369,28 @@ fill_fpregset (const struct regcache *regcache, thier values in GDB's register array. */ static void -fetch_fpregs (int tid) +fetch_fpregs (struct regcache *regcache, int tid) { elf_fpregset_t fpregs; if (ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs) < 0) perror_with_name (_("Couldn't get floating point status")); - supply_fpregset (current_regcache, (const elf_fpregset_t *) &fpregs); + supply_fpregset (regcache, (const elf_fpregset_t *) &fpregs); } /* Store all valid floating-point registers in GDB's register array into the process/thread specified by TID. */ static void -store_fpregs (int tid, int regno) +store_fpregs (const struct regcache *regcache, int tid, int regno) { elf_fpregset_t fpregs; if (ptrace (PTRACE_GETFPREGS, tid, 0, (int) &fpregs) < 0) perror_with_name (_("Couldn't get floating point status")); - fill_fpregset (current_regcache, &fpregs, regno); + fill_fpregset (regcache, &fpregs, regno); if (ptrace (PTRACE_SETFPREGS, tid, 0, (int) &fpregs) < 0) perror_with_name (_("Couldn't write floating point status")); @@ -398,8 +398,8 @@ store_fpregs (int tid, int regno) #else -static void fetch_fpregs (int tid) {} -static void store_fpregs (int tid, int regno) {} +static void fetch_fpregs (struct regcache *regcache, int tid) {} +static void store_fpregs (const struct regcache *regcache, int tid, int regno) {} #endif @@ -410,7 +410,7 @@ static void store_fpregs (int tid, int regno) {} registers). */ static void -m68k_linux_fetch_inferior_registers (int regno) +m68k_linux_fetch_inferior_registers (struct regcache *regcache, int regno) { int tid; @@ -418,7 +418,7 @@ m68k_linux_fetch_inferior_registers (int regno) GETREGS request isn't available. */ if (! have_ptrace_getregs) { - old_fetch_inferior_registers (regno); + old_fetch_inferior_registers (regcache, regno); return; } @@ -433,28 +433,28 @@ m68k_linux_fetch_inferior_registers (int regno) zero. */ if (regno == -1) { - fetch_regs (tid); + fetch_regs (regcache, tid); /* The call above might reset `have_ptrace_getregs'. */ if (! have_ptrace_getregs) { - old_fetch_inferior_registers (-1); + old_fetch_inferior_registers (regcache, -1); return; } - fetch_fpregs (tid); + fetch_fpregs (regcache, tid); return; } if (getregs_supplies (regno)) { - fetch_regs (tid); + fetch_regs (regcache, tid); return; } if (getfpregs_supplies (regno)) { - fetch_fpregs (tid); + fetch_fpregs (regcache, tid); return; } @@ -466,7 +466,7 @@ m68k_linux_fetch_inferior_registers (int regno) do this for all registers (including the floating point and SSE registers). */ static void -m68k_linux_store_inferior_registers (int regno) +m68k_linux_store_inferior_registers (struct regcache *regcache, int regno) { int tid; @@ -474,7 +474,7 @@ m68k_linux_store_inferior_registers (int regno) SETREGS request isn't available. */ if (! have_ptrace_getregs) { - old_store_inferior_registers (regno); + old_store_inferior_registers (regcache, regno); return; } @@ -488,20 +488,20 @@ m68k_linux_store_inferior_registers (int regno) store_fpregs can fail, and return zero. */ if (regno == -1) { - store_regs (tid, regno); - store_fpregs (tid, regno); + store_regs (regcache, tid, regno); + store_fpregs (regcache, tid, regno); return; } if (getregs_supplies (regno)) { - store_regs (tid, regno); + store_regs (regcache, tid, regno); return; } if (getfpregs_supplies (regno)) { - store_fpregs (tid, regno); + store_fpregs (regcache, tid, regno); return; } diff --git a/gdb/m88kbsd-nat.c b/gdb/m88kbsd-nat.c index 1a7caa3..dc00a35 100644 --- a/gdb/m88kbsd-nat.c +++ b/gdb/m88kbsd-nat.c @@ -65,7 +65,7 @@ m88kbsd_collect_gregset (const struct regcache *regcache, for all registers. */ static void -m88kbsd_fetch_inferior_registers (int regnum) +m88kbsd_fetch_inferior_registers (struct regcache *regcache, int regnum) { struct reg regs; @@ -73,14 +73,14 @@ m88kbsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - m88kbsd_supply_gregset (current_regcache, ®s); + m88kbsd_supply_gregset (regcache, ®s); } /* Store register REGNUM back into the inferior. If REGNUM is -1, do this for all registers. */ static void -m88kbsd_store_inferior_registers (int regnum) +m88kbsd_store_inferior_registers (struct regcache *regcache, int regnum) { struct reg regs; @@ -88,7 +88,7 @@ m88kbsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - m88kbsd_collect_gregset (current_regcache, ®s, regnum); + m88kbsd_collect_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c index f6eaa0b..a511689 100644 --- a/gdb/mips-linux-nat.c +++ b/gdb/mips-linux-nat.c @@ -44,8 +44,8 @@ static int have_ptrace_regsets = 1; /* Saved function pointers to fetch and store a single register using PTRACE_PEEKUSER and PTRACE_POKEUSER. */ -void (*super_fetch_registers) (int); -void (*super_store_registers) (int); +void (*super_fetch_registers) (struct regcache *, int); +void (*super_store_registers) (struct regcache *, int); /* Pseudo registers can not be read. ptrace does not provide a way to read (or set) MIPS_PS_REGNUM, and there's no point in reading or @@ -219,7 +219,7 @@ fill_fpregset (const struct regcache *regcache, using PTRACE_GETREGS et al. */ static void -mips64_linux_regsets_fetch_registers (int regno) +mips64_linux_regsets_fetch_registers (struct regcache *regcache, int regno) { int is_fp; int tid; @@ -252,7 +252,7 @@ mips64_linux_regsets_fetch_registers (int regno) perror_with_name (_("Couldn't get registers")); } - mips64_supply_gregset (current_regcache, + mips64_supply_gregset (regcache, (const mips64_elf_gregset_t *) ®s); } @@ -271,7 +271,7 @@ mips64_linux_regsets_fetch_registers (int regno) perror_with_name (_("Couldn't get FP registers")); } - mips64_supply_fpregset (current_regcache, + mips64_supply_fpregset (regcache, (const mips64_elf_fpregset_t *) &fp_regs); } } @@ -280,7 +280,7 @@ mips64_linux_regsets_fetch_registers (int regno) using PTRACE_SETREGS et al. */ static void -mips64_linux_regsets_store_registers (int regno) +mips64_linux_regsets_store_registers (const struct regcache *regcache, int regno) { int is_fp; int tid; @@ -306,7 +306,7 @@ mips64_linux_regsets_store_registers (int regno) if (ptrace (PTRACE_GETREGS, tid, 0L, (PTRACE_TYPE_ARG3) ®s) == -1) perror_with_name (_("Couldn't get registers")); - mips64_fill_gregset (current_regcache, ®s, regno); + mips64_fill_gregset (regcache, ®s, regno); if (ptrace (PTRACE_SETREGS, tid, 0L, (PTRACE_TYPE_ARG3) ®s) == -1) perror_with_name (_("Couldn't set registers")); @@ -320,7 +320,7 @@ mips64_linux_regsets_store_registers (int regno) (PTRACE_TYPE_ARG3) &fp_regs) == -1) perror_with_name (_("Couldn't get FP registers")); - mips64_fill_fpregset (current_regcache, &fp_regs, regno); + mips64_fill_fpregset (regcache, &fp_regs, regno); if (ptrace (PTRACE_SETFPREGS, tid, 0L, (PTRACE_TYPE_ARG3) &fp_regs) == -1) @@ -332,32 +332,32 @@ mips64_linux_regsets_store_registers (int regno) using any working method. */ static void -mips64_linux_fetch_registers (int regnum) +mips64_linux_fetch_registers (struct regcache *regcache, int regnum) { /* Unless we already know that PTRACE_GETREGS does not work, try it. */ if (have_ptrace_regsets) - mips64_linux_regsets_fetch_registers (regnum); + mips64_linux_regsets_fetch_registers (regcache, regnum); /* If we know, or just found out, that PTRACE_GETREGS does not work, fall back to PTRACE_PEEKUSER. */ if (!have_ptrace_regsets) - super_fetch_registers (regnum); + super_fetch_registers (regcache, regnum); } /* Store REGNO (or all registers if REGNO == -1) to the target using any working method. */ static void -mips64_linux_store_registers (int regnum) +mips64_linux_store_registers (struct regcache *regcache, int regnum) { /* Unless we already know that PTRACE_GETREGS does not work, try it. */ if (have_ptrace_regsets) - mips64_linux_regsets_store_registers (regnum); + mips64_linux_regsets_store_registers (regcache, regnum); /* If we know, or just found out, that PTRACE_GETREGS does not work, fall back to PTRACE_PEEKUSER. */ if (!have_ptrace_regsets) - super_store_registers (regnum); + super_store_registers (regcache, regnum); } /* Return the address in the core dump or inferior of register diff --git a/gdb/mips64obsd-nat.c b/gdb/mips64obsd-nat.c index e0fe028..4f02a21 100644 --- a/gdb/mips64obsd-nat.c +++ b/gdb/mips64obsd-nat.c @@ -79,7 +79,7 @@ mips64obsd_collect_gregset (const struct regcache *regcache, for all registers. */ static void -mips64obsd_fetch_inferior_registers (int regnum) +mips64obsd_fetch_inferior_registers (struct regcache *regcache, int regnum) { struct reg regs; @@ -87,14 +87,14 @@ mips64obsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - mips64obsd_supply_gregset (current_regcache, ®s); + mips64obsd_supply_gregset (regcache, ®s); } /* Store register REGNUM back into the inferior. If REGNUM is -1, do this for all registers. */ static void -mips64obsd_store_inferior_registers (int regnum) +mips64obsd_store_inferior_registers (struct regcache *regcache, int regnum) { struct reg regs; @@ -102,7 +102,7 @@ mips64obsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - mips64obsd_collect_gregset (current_regcache, ®s, regnum); + mips64obsd_collect_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) diff --git a/gdb/mipsnbsd-nat.c b/gdb/mipsnbsd-nat.c index 2bea684..721b4a0 100644 --- a/gdb/mipsnbsd-nat.c +++ b/gdb/mipsnbsd-nat.c @@ -40,7 +40,7 @@ getregs_supplies (int regno) } static void -mipsnbsd_fetch_inferior_registers (int regno) +mipsnbsd_fetch_inferior_registers (struct regcache *regcache, int regno) { if (regno == -1 || getregs_supplies (regno)) { @@ -50,7 +50,7 @@ mipsnbsd_fetch_inferior_registers (int regno) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - mipsnbsd_supply_reg (current_regcache, (char *) ®s, regno); + mipsnbsd_supply_reg (regcache, (char *) ®s, regno); if (regno != -1) return; } @@ -63,12 +63,12 @@ mipsnbsd_fetch_inferior_registers (int regno) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - mipsnbsd_supply_fpreg (current_regcache, (char *) &fpregs, regno); + mipsnbsd_supply_fpreg (regcache, (char *) &fpregs, regno); } } static void -mipsnbsd_store_inferior_registers (int regno) +mipsnbsd_store_inferior_registers (struct regcache *regcache, int regno) { if (regno == -1 || getregs_supplies (regno)) { @@ -78,7 +78,7 @@ mipsnbsd_store_inferior_registers (int regno) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - mipsnbsd_fill_reg (current_regcache, (char *) ®s, regno); + mipsnbsd_fill_reg (regcache, (char *) ®s, regno); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) @@ -96,7 +96,7 @@ mipsnbsd_store_inferior_registers (int regno) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - mipsnbsd_fill_fpreg (current_regcache, (char *) &fpregs, regno); + mipsnbsd_fill_fpreg (regcache, (char *) &fpregs, regno); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) diff --git a/gdb/monitor.c b/gdb/monitor.c index 6266ab0..00695b8 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -1129,7 +1129,7 @@ monitor_wait (ptid_t ptid, struct target_waitstatus *status) errno value. */ static void -monitor_fetch_register (int regno) +monitor_fetch_register (struct regcache *regcache, int regno) { const char *name; char *zerobuf; @@ -1149,7 +1149,7 @@ monitor_fetch_register (int regno) if (!name || (*name == '\0')) { monitor_debug ("No register known for %d\n", regno); - regcache_raw_supply (current_regcache, regno, zerobuf); + regcache_raw_supply (regcache, regno, zerobuf); return; } @@ -1228,7 +1228,7 @@ monitor_fetch_register (int regno) current_monitor->getreg.term_cmd) /* ack expected */ monitor_expect_prompt (NULL, 0); /* get response */ - monitor_supply_register (current_regcache, regno, regbuf); + monitor_supply_register (regcache, regno, regbuf); } /* Sometimes, it takes several commands to dump the registers */ @@ -1268,30 +1268,30 @@ monitor_dump_regs (struct regcache *regcache) } static void -monitor_fetch_registers (int regno) +monitor_fetch_registers (struct regcache *regcache, int regno) { monitor_debug ("MON fetchregs\n"); if (current_monitor->getreg.cmd) { if (regno >= 0) { - monitor_fetch_register (regno); + monitor_fetch_register (regcache, regno); return; } for (regno = 0; regno < NUM_REGS; regno++) - monitor_fetch_register (regno); + monitor_fetch_register (regcache, regno); } else { - monitor_dump_regs (current_regcache); + monitor_dump_regs (regcache); } } /* Store register REGNO, or all if REGNO == 0. Return errno value. */ static void -monitor_store_register (int regno) +monitor_store_register (struct regcache *regcache, int regno) { const char *name; ULONGEST val; @@ -1307,7 +1307,7 @@ monitor_store_register (int regno) return; } - val = read_register (regno); + regcache_cooked_read_unsigned (regcache, regno, &val); monitor_debug ("MON storeg %d %s\n", regno, phex (val, register_size (current_gdbarch, regno))); @@ -1348,16 +1348,16 @@ monitor_store_register (int regno) /* Store the remote registers. */ static void -monitor_store_registers (int regno) +monitor_store_registers (struct regcache *regcache, int regno) { if (regno >= 0) { - monitor_store_register (regno); + monitor_store_register (regcache, regno); return; } for (regno = 0; regno < NUM_REGS; regno++) - monitor_store_register (regno); + monitor_store_register (regcache, regno); } /* Get ready to modify the registers array. On machines which store diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 8140840..34ae3cd 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -67,7 +67,7 @@ static int procfs_xfer_memory (CORE_ADDR, char *, int, int, struct mem_attrib *attrib, struct target_ops *); -static void procfs_fetch_registers (int); +static void procfs_fetch_registers (struct regcache *, int); static void notice_signals (void); @@ -714,7 +714,7 @@ procfs_wait (ptid_t ptid, struct target_waitstatus *ourstatus) general register set and floating point registers (if supported) and update gdb's idea of their current values. */ static void -procfs_fetch_registers (int regno) +procfs_fetch_registers (struct regcache *regcache, int regno) { union { @@ -727,13 +727,13 @@ procfs_fetch_registers (int regno) procfs_set_thread (inferior_ptid); if (devctl (ctl_fd, DCMD_PROC_GETGREG, ®, sizeof (reg), ®size) == EOK) - nto_supply_gregset (current_regcache, (char *) ®.greg); + nto_supply_gregset (regcache, (char *) ®.greg); if (devctl (ctl_fd, DCMD_PROC_GETFPREG, ®, sizeof (reg), ®size) == EOK) - nto_supply_fpregset (current_regcache, (char *) ®.fpreg); + nto_supply_fpregset (regcache, (char *) ®.fpreg); if (devctl (ctl_fd, DCMD_PROC_GETALTREG, ®, sizeof (reg), ®size) == EOK) - nto_supply_altregset (current_regcache, (char *) ®.altreg); + nto_supply_altregset (regcache, (char *) ®.altreg); } /* Copy LEN bytes to/from inferior's memory starting at MEMADDR @@ -1147,7 +1147,7 @@ get_regset (int regset, char *buf, int bufsize, int *regsize) } void -procfs_store_registers (int regno) +procfs_store_registers (struct regcache *regcache, int regno) { union { @@ -1173,7 +1173,7 @@ procfs_store_registers (int regno) if (dev_set == -1) continue; - if (nto_regset_fill (current_regcache, regset, (char *) ®) == -1) + if (nto_regset_fill (regcache, regset, (char *) ®) == -1) continue; err = devctl (ctl_fd, dev_set, ®, regsize, 0); @@ -1198,7 +1198,7 @@ procfs_store_registers (int regno) if (len < 1) return; - regcache_raw_collect (current_regcache, regno, (char *) ® + off); + regcache_raw_collect (regcache, regno, (char *) ® + off); err = devctl (ctl_fd, dev_set, ®, regsize, 0); if (err != EOK) diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 02e50f1..b5c5afb 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -226,7 +226,7 @@ ppc_register_u_addr (int regno) registers set mechanism, as opposed to the interface for all the other registers, that stores/fetches each register individually. */ static void -fetch_altivec_register (int tid, int regno) +fetch_altivec_register (struct regcache *regcache, int tid, int regno) { int ret; int offset = 0; @@ -252,7 +252,7 @@ fetch_altivec_register (int tid, int regno) if (regno == (tdep->ppc_vrsave_regnum - 1)) offset = vrregsize - register_size (current_gdbarch, tdep->ppc_vrsave_regnum); - regcache_raw_supply (current_regcache, regno, + regcache_raw_supply (regcache, regno, regs + (regno - tdep->ppc_vr0_regnum) * vrregsize + offset); } @@ -291,7 +291,7 @@ get_spe_registers (int tid, struct gdb_evrregset_t *evrregset) be the number of an upper half register, acc, spefscr, or -1 to supply the values of all registers. */ static void -fetch_spe_register (int tid, int regno) +fetch_spe_register (struct regcache *regcache, int tid, int regno) { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); struct gdb_evrregset_t evrregs; @@ -310,26 +310,26 @@ fetch_spe_register (int tid, int regno) int i; for (i = 0; i < ppc_num_gprs; i++) - regcache_raw_supply (current_regcache, tdep->ppc_ev0_upper_regnum + i, + regcache_raw_supply (regcache, tdep->ppc_ev0_upper_regnum + i, &evrregs.evr[i]); } else if (tdep->ppc_ev0_upper_regnum <= regno && regno < tdep->ppc_ev0_upper_regnum + ppc_num_gprs) - regcache_raw_supply (current_regcache, regno, + regcache_raw_supply (regcache, regno, &evrregs.evr[regno - tdep->ppc_ev0_upper_regnum]); if (regno == -1 || regno == tdep->ppc_acc_regnum) - regcache_raw_supply (current_regcache, tdep->ppc_acc_regnum, &evrregs.acc); + regcache_raw_supply (regcache, tdep->ppc_acc_regnum, &evrregs.acc); if (regno == -1 || regno == tdep->ppc_spefscr_regnum) - regcache_raw_supply (current_regcache, tdep->ppc_spefscr_regnum, + regcache_raw_supply (regcache, tdep->ppc_spefscr_regnum, &evrregs.spefscr); } static void -fetch_register (int tid, int regno) +fetch_register (struct regcache *regcache, int tid, int regno) { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); /* This isn't really an address. But ptrace thinks of it as one. */ @@ -346,7 +346,7 @@ fetch_register (int tid, int regno) register. */ if (have_ptrace_getvrregs) { - fetch_altivec_register (tid, regno); + fetch_altivec_register (regcache, tid, regno); return; } /* If we have discovered that there is no ptrace support for @@ -355,14 +355,14 @@ fetch_register (int tid, int regno) } else if (spe_register_p (regno)) { - fetch_spe_register (tid, regno); + fetch_spe_register (regcache, tid, regno); return; } if (regaddr == -1) { memset (buf, '\0', register_size (current_gdbarch, regno)); /* Supply zeroes */ - regcache_raw_supply (current_regcache, regno, buf); + regcache_raw_supply (regcache, regno, buf); return; } @@ -393,7 +393,7 @@ fetch_register (int tid, int regno) { /* Little-endian values are always found at the left end of the bytes transferred. */ - regcache_raw_supply (current_regcache, regno, buf); + regcache_raw_supply (regcache, regno, buf); } else if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) { @@ -401,7 +401,7 @@ fetch_register (int tid, int regno) transferred. */ size_t padding = (bytes_transferred - register_size (current_gdbarch, regno)); - regcache_raw_supply (current_regcache, regno, buf + padding); + regcache_raw_supply (regcache, regno, buf + padding); } else internal_error (__FILE__, __LINE__, @@ -410,7 +410,7 @@ fetch_register (int tid, int regno) } static void -supply_vrregset (gdb_vrregset_t *vrregsetp) +supply_vrregset (struct regcache *regcache, gdb_vrregset_t *vrregsetp) { int i; struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); @@ -425,16 +425,16 @@ supply_vrregset (gdb_vrregset_t *vrregsetp) occupies a whole vector, while VRSAVE occupies a full 4 bytes slot. */ if (i == (num_of_vrregs - 2)) - regcache_raw_supply (current_regcache, tdep->ppc_vr0_regnum + i, + regcache_raw_supply (regcache, tdep->ppc_vr0_regnum + i, *vrregsetp + i * vrregsize + offset); else - regcache_raw_supply (current_regcache, tdep->ppc_vr0_regnum + i, + regcache_raw_supply (regcache, tdep->ppc_vr0_regnum + i, *vrregsetp + i * vrregsize); } } static void -fetch_altivec_registers (int tid) +fetch_altivec_registers (struct regcache *regcache, int tid) { int ret; gdb_vrregset_t regs; @@ -449,47 +449,47 @@ fetch_altivec_registers (int tid) } perror_with_name (_("Unable to fetch AltiVec registers")); } - supply_vrregset (®s); + supply_vrregset (regcache, ®s); } static void -fetch_ppc_registers (int tid) +fetch_ppc_registers (struct regcache *regcache, int tid) { int i; struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); for (i = 0; i < ppc_num_gprs; i++) - fetch_register (tid, tdep->ppc_gp0_regnum + i); + fetch_register (regcache, tid, tdep->ppc_gp0_regnum + i); if (tdep->ppc_fp0_regnum >= 0) for (i = 0; i < ppc_num_fprs; i++) - fetch_register (tid, tdep->ppc_fp0_regnum + i); - fetch_register (tid, PC_REGNUM); + fetch_register (regcache, tid, tdep->ppc_fp0_regnum + i); + fetch_register (regcache, tid, PC_REGNUM); if (tdep->ppc_ps_regnum != -1) - fetch_register (tid, tdep->ppc_ps_regnum); + fetch_register (regcache, tid, tdep->ppc_ps_regnum); if (tdep->ppc_cr_regnum != -1) - fetch_register (tid, tdep->ppc_cr_regnum); + fetch_register (regcache, tid, tdep->ppc_cr_regnum); if (tdep->ppc_lr_regnum != -1) - fetch_register (tid, tdep->ppc_lr_regnum); + fetch_register (regcache, tid, tdep->ppc_lr_regnum); if (tdep->ppc_ctr_regnum != -1) - fetch_register (tid, tdep->ppc_ctr_regnum); + fetch_register (regcache, tid, tdep->ppc_ctr_regnum); if (tdep->ppc_xer_regnum != -1) - fetch_register (tid, tdep->ppc_xer_regnum); + fetch_register (regcache, tid, tdep->ppc_xer_regnum); if (tdep->ppc_mq_regnum != -1) - fetch_register (tid, tdep->ppc_mq_regnum); + fetch_register (regcache, tid, tdep->ppc_mq_regnum); if (tdep->ppc_fpscr_regnum != -1) - fetch_register (tid, tdep->ppc_fpscr_regnum); + fetch_register (regcache, tid, tdep->ppc_fpscr_regnum); if (have_ptrace_getvrregs) if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1) - fetch_altivec_registers (tid); + fetch_altivec_registers (regcache, tid); if (tdep->ppc_ev0_upper_regnum >= 0) - fetch_spe_register (tid, -1); + fetch_spe_register (regcache, tid, -1); } /* Fetch registers from the child process. Fetch all registers if regno == -1, otherwise fetch all general registers or all floating point registers depending upon the value of regno. */ static void -ppc_linux_fetch_inferior_registers (int regno) +ppc_linux_fetch_inferior_registers (struct regcache *regcache, int regno) { /* Overload thread id onto process id */ int tid = TIDGET (inferior_ptid); @@ -499,14 +499,14 @@ ppc_linux_fetch_inferior_registers (int regno) tid = PIDGET (inferior_ptid); if (regno == -1) - fetch_ppc_registers (tid); + fetch_ppc_registers (regcache, tid); else - fetch_register (tid, regno); + fetch_register (regcache, tid, regno); } /* Store one register. */ static void -store_altivec_register (int tid, int regno) +store_altivec_register (const struct regcache *regcache, int tid, int regno) { int ret; int offset = 0; @@ -530,7 +530,7 @@ store_altivec_register (int tid, int regno) if (regno == (tdep->ppc_vrsave_regnum - 1)) offset = vrregsize - register_size (current_gdbarch, tdep->ppc_vrsave_regnum); - regcache_raw_collect (current_regcache, regno, + regcache_raw_collect (regcache, regno, regs + (regno - tdep->ppc_vr0_regnum) * vrregsize + offset); ret = ptrace (PTRACE_SETVRREGS, tid, 0, ®s); @@ -571,7 +571,7 @@ set_spe_registers (int tid, struct gdb_evrregset_t *evrregset) If REGNO is -1, write the values of all the SPE-specific registers. */ static void -store_spe_register (int tid, int regno) +store_spe_register (const struct regcache *regcache, int tid, int regno) { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); struct gdb_evrregset_t evrregs; @@ -599,24 +599,24 @@ store_spe_register (int tid, int regno) int i; for (i = 0; i < ppc_num_gprs; i++) - regcache_raw_collect (current_regcache, + regcache_raw_collect (regcache, tdep->ppc_ev0_upper_regnum + i, &evrregs.evr[i]); } else if (tdep->ppc_ev0_upper_regnum <= regno && regno < tdep->ppc_ev0_upper_regnum + ppc_num_gprs) - regcache_raw_collect (current_regcache, regno, + regcache_raw_collect (regcache, regno, &evrregs.evr[regno - tdep->ppc_ev0_upper_regnum]); if (regno == -1 || regno == tdep->ppc_acc_regnum) - regcache_raw_collect (current_regcache, + regcache_raw_collect (regcache, tdep->ppc_acc_regnum, &evrregs.acc); if (regno == -1 || regno == tdep->ppc_spefscr_regnum) - regcache_raw_collect (current_regcache, + regcache_raw_collect (regcache, tdep->ppc_spefscr_regnum, &evrregs.spefscr); @@ -625,7 +625,7 @@ store_spe_register (int tid, int regno) } static void -store_register (int tid, int regno) +store_register (const struct regcache *regcache, int tid, int regno) { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); /* This isn't really an address. But ptrace thinks of it as one. */ @@ -636,12 +636,12 @@ store_register (int tid, int regno) if (altivec_register_p (regno)) { - store_altivec_register (tid, regno); + store_altivec_register (regcache, tid, regno); return; } else if (spe_register_p (regno)) { - store_spe_register (tid, regno); + store_spe_register (regcache, tid, regno); return; } @@ -657,14 +657,14 @@ store_register (int tid, int regno) if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE) { /* Little-endian values always sit at the left end of the buffer. */ - regcache_raw_collect (current_regcache, regno, buf); + regcache_raw_collect (regcache, regno, buf); } else if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) { /* Big-endian values sit at the right end of the buffer. */ size_t padding = (bytes_to_transfer - register_size (current_gdbarch, regno)); - regcache_raw_collect (current_regcache, regno, buf + padding); + regcache_raw_collect (regcache, regno, buf + padding); } for (i = 0; i < bytes_to_transfer; i += sizeof (long)) @@ -692,7 +692,7 @@ store_register (int tid, int regno) } static void -fill_vrregset (gdb_vrregset_t *vrregsetp) +fill_vrregset (const struct regcache *regcache, gdb_vrregset_t *vrregsetp) { int i; struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); @@ -705,16 +705,16 @@ fill_vrregset (gdb_vrregset_t *vrregsetp) /* The last 2 registers of this set are only 32 bit long, not 128, but only VSCR is fetched as a 16 bytes quantity. */ if (i == (num_of_vrregs - 2)) - regcache_raw_collect (current_regcache, tdep->ppc_vr0_regnum + i, + regcache_raw_collect (regcache, tdep->ppc_vr0_regnum + i, *vrregsetp + i * vrregsize + offset); else - regcache_raw_collect (current_regcache, tdep->ppc_vr0_regnum + i, + regcache_raw_collect (regcache, tdep->ppc_vr0_regnum + i, *vrregsetp + i * vrregsize); } } static void -store_altivec_registers (int tid) +store_altivec_registers (const struct regcache *regcache, int tid) { int ret; gdb_vrregset_t regs; @@ -730,43 +730,43 @@ store_altivec_registers (int tid) perror_with_name (_("Couldn't get AltiVec registers")); } - fill_vrregset (®s); + fill_vrregset (regcache, ®s); if (ptrace (PTRACE_SETVRREGS, tid, 0, ®s) < 0) perror_with_name (_("Couldn't write AltiVec registers")); } static void -store_ppc_registers (int tid) +store_ppc_registers (const struct regcache *regcache, int tid) { int i; struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); for (i = 0; i < ppc_num_gprs; i++) - store_register (tid, tdep->ppc_gp0_regnum + i); + store_register (regcache, tid, tdep->ppc_gp0_regnum + i); if (tdep->ppc_fp0_regnum >= 0) for (i = 0; i < ppc_num_fprs; i++) - store_register (tid, tdep->ppc_fp0_regnum + i); - store_register (tid, PC_REGNUM); + store_register (regcache, tid, tdep->ppc_fp0_regnum + i); + store_register (regcache, tid, PC_REGNUM); if (tdep->ppc_ps_regnum != -1) - store_register (tid, tdep->ppc_ps_regnum); + store_register (regcache, tid, tdep->ppc_ps_regnum); if (tdep->ppc_cr_regnum != -1) - store_register (tid, tdep->ppc_cr_regnum); + store_register (regcache, tid, tdep->ppc_cr_regnum); if (tdep->ppc_lr_regnum != -1) - store_register (tid, tdep->ppc_lr_regnum); + store_register (regcache, tid, tdep->ppc_lr_regnum); if (tdep->ppc_ctr_regnum != -1) - store_register (tid, tdep->ppc_ctr_regnum); + store_register (regcache, tid, tdep->ppc_ctr_regnum); if (tdep->ppc_xer_regnum != -1) - store_register (tid, tdep->ppc_xer_regnum); + store_register (regcache, tid, tdep->ppc_xer_regnum); if (tdep->ppc_mq_regnum != -1) - store_register (tid, tdep->ppc_mq_regnum); + store_register (regcache, tid, tdep->ppc_mq_regnum); if (tdep->ppc_fpscr_regnum != -1) - store_register (tid, tdep->ppc_fpscr_regnum); + store_register (regcache, tid, tdep->ppc_fpscr_regnum); if (have_ptrace_getvrregs) if (tdep->ppc_vr0_regnum != -1 && tdep->ppc_vrsave_regnum != -1) - store_altivec_registers (tid); + store_altivec_registers (regcache, tid); if (tdep->ppc_ev0_upper_regnum >= 0) - store_spe_register (tid, -1); + store_spe_register (regcache, tid, -1); } static int @@ -888,7 +888,7 @@ ppc_linux_stopped_by_watchpoint (void) } static void -ppc_linux_store_inferior_registers (int regno) +ppc_linux_store_inferior_registers (struct regcache *regcache, int regno) { /* Overload thread id onto process id */ int tid = TIDGET (inferior_ptid); @@ -898,9 +898,9 @@ ppc_linux_store_inferior_registers (int regno) tid = PIDGET (inferior_ptid); if (regno >= 0) - store_register (tid, regno); + store_register (regcache, tid, regno); else - store_ppc_registers (tid); + store_ppc_registers (regcache, tid); } void @@ -957,7 +957,7 @@ fill_gregset (const struct regcache *regcache, regcache_raw_collect (regcache, tdep->ppc_xer_regnum, regp + PT_XER); if ((regno == -1) || regno == tdep->ppc_ctr_regnum) - right_fill_reg (tdep->ppc_ctr_regnum, regp + PT_CTR); + right_fill_reg (regcache, tdep->ppc_ctr_regnum, regp + PT_CTR); #ifdef PT_MQ if (((regno == -1) || regno == tdep->ppc_mq_regnum) && (tdep->ppc_mq_regnum != -1)) @@ -995,7 +995,7 @@ fill_fpregset (const struct regcache *regcache, fpp + 8 * regi); } if (regno == -1 || regno == tdep->ppc_fpscr_regnum) - right_fill_reg (tdep->ppc_fpscr_regnum, (fpp + 8 * 32)); + right_fill_reg (regcache, tdep->ppc_fpscr_regnum, (fpp + 8 * 32)); } } diff --git a/gdb/ppcnbsd-nat.c b/gdb/ppcnbsd-nat.c index 0249797..2c73573 100644 --- a/gdb/ppcnbsd-nat.c +++ b/gdb/ppcnbsd-nat.c @@ -80,7 +80,7 @@ getfpregs_supplies (int regnum) } static void -ppcnbsd_fetch_inferior_registers (int regnum) +ppcnbsd_fetch_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || getregs_supplies (regnum)) { @@ -90,7 +90,7 @@ ppcnbsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - ppc_supply_gregset (&ppcnbsd_gregset, current_regcache, + ppc_supply_gregset (&ppcnbsd_gregset, regcache, regnum, ®s, sizeof regs); } @@ -102,13 +102,13 @@ ppcnbsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get FP registers")); - ppc_supply_fpregset (&ppcnbsd_fpregset, current_regcache, + ppc_supply_fpregset (&ppcnbsd_fpregset, regcache, regnum, &fpregs, sizeof fpregs); } } static void -ppcnbsd_store_inferior_registers (int regnum) +ppcnbsd_store_inferior_registers (struct regcache *regcache, int regnum) { if (regnum == -1 || getregs_supplies (regnum)) { @@ -118,7 +118,7 @@ ppcnbsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - ppc_collect_gregset (&ppcnbsd_gregset, current_regcache, + ppc_collect_gregset (&ppcnbsd_gregset, regcache, regnum, ®s, sizeof regs); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), @@ -134,7 +134,7 @@ ppcnbsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get FP registers")); - ppc_collect_fpregset (&ppcnbsd_fpregset, current_regcache, + ppc_collect_fpregset (&ppcnbsd_fpregset, regcache, regnum, &fpregs, sizeof fpregs); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), diff --git a/gdb/ppcobsd-nat.c b/gdb/ppcobsd-nat.c index f520450..9186907 100644 --- a/gdb/ppcobsd-nat.c +++ b/gdb/ppcobsd-nat.c @@ -74,7 +74,7 @@ getfpregs_supplies (int regnum) for all registers. */ static void -ppcobsd_fetch_registers (int regnum) +ppcobsd_fetch_registers (struct regcache *regcache, int regnum) { struct reg regs; @@ -82,10 +82,10 @@ ppcobsd_fetch_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - ppc_supply_gregset (&ppcobsd_gregset, current_regcache, -1, + ppc_supply_gregset (&ppcobsd_gregset, regcache, -1, ®s, sizeof regs); #ifndef PT_GETFPREGS - ppc_supply_fpregset (&ppcobsd_gregset, current_regcache, -1, + ppc_supply_fpregset (&ppcobsd_gregset, regcache, -1, ®s, sizeof regs); #endif @@ -98,7 +98,7 @@ ppcobsd_fetch_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - ppc_supply_fpregset (&ppcobsd_fpregset, current_regcache, -1, + ppc_supply_fpregset (&ppcobsd_fpregset, regcache, -1, &fpregs, sizeof fpregs); } #endif @@ -108,7 +108,7 @@ ppcobsd_fetch_registers (int regnum) this for all registers. */ static void -ppcobsd_store_registers (int regnum) +ppcobsd_store_registers (struct regcache *regcache, int regnum) { struct reg regs; @@ -116,10 +116,10 @@ ppcobsd_store_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - ppc_collect_gregset (&ppcobsd_gregset, current_regcache, + ppc_collect_gregset (&ppcobsd_gregset, regcache, regnum, ®s, sizeof regs); #ifndef PT_GETFPREGS - ppc_collect_fpregset (&ppcobsd_gregset, current_regcache, + ppc_collect_fpregset (&ppcobsd_gregset, regcache, regnum, ®s, sizeof regs); #endif @@ -136,7 +136,7 @@ ppcobsd_store_registers (int regnum) (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) perror_with_name (_("Couldn't get floating point status")); - ppc_collect_fpregset (&ppcobsd_fpregset, current_regcache, + ppc_collect_fpregset (&ppcobsd_fpregset, regcache, regnum, &fpregs, sizeof fpregs); if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), diff --git a/gdb/proc-service.c b/gdb/proc-service.c index a8411f4..6d3eb88 100644 --- a/gdb/proc-service.c +++ b/gdb/proc-service.c @@ -234,7 +234,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) inferior_ptid = BUILD_LWP (lwpid, ph->pid); - target_fetch_registers (-1); + target_fetch_registers (current_regcache, -1); fill_gregset (current_regcache, (gdb_gregset_t *) gregset, -1); do_cleanups (old_chain); @@ -252,7 +252,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset) inferior_ptid = BUILD_LWP (lwpid, ph->pid); supply_gregset (current_regcache, (const gdb_gregset_t *) gregset); - target_store_registers (-1); + target_store_registers (current_regcache, -1); do_cleanups (old_chain); return PS_OK; @@ -269,7 +269,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, inferior_ptid = BUILD_LWP (lwpid, ph->pid); - target_fetch_registers (-1); + target_fetch_registers (current_regcache, -1); fill_fpregset (current_regcache, (gdb_fpregset_t *) fpregset, -1); do_cleanups (old_chain); @@ -288,7 +288,7 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, inferior_ptid = BUILD_LWP (lwpid, ph->pid); supply_fpregset (current_regcache, (const gdb_fpregset_t *) fpregset); - target_store_registers (-1); + target_store_registers (current_regcache, -1); do_cleanups (old_chain); return PS_OK; diff --git a/gdb/procfs.c b/gdb/procfs.c index a6b43a2..788a661 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -120,8 +120,8 @@ static void procfs_resume (ptid_t, int, enum target_signal); static int procfs_can_run (void); static void procfs_stop (void); static void procfs_files_info (struct target_ops *); -static void procfs_fetch_registers (int); -static void procfs_store_registers (int); +static void procfs_fetch_registers (struct regcache *, int); +static void procfs_store_registers (struct regcache *, int); static void procfs_notice_signals (ptid_t); static void procfs_prepare_to_store (void); static void procfs_kill_inferior (void); @@ -3682,7 +3682,7 @@ do_detach (int signo) when the process is resumed. */ static void -procfs_fetch_registers (int regnum) +procfs_fetch_registers (struct regcache *regcache, int regnum) { gdb_gregset_t *gregs; procinfo *pi; @@ -3706,7 +3706,7 @@ procfs_fetch_registers (int regnum) if (gregs == NULL) proc_error (pi, "fetch_registers, get_gregs", __LINE__); - supply_gregset (current_regcache, (const gdb_gregset_t *) gregs); + supply_gregset (regcache, (const gdb_gregset_t *) gregs); if (FP0_REGNUM >= 0) /* Do we have an FPU? */ { @@ -3721,7 +3721,7 @@ procfs_fetch_registers (int regnum) if (fpregs == NULL) proc_error (pi, "fetch_registers, get_fpregs", __LINE__); - supply_fpregset (current_regcache, (const gdb_fpregset_t *) fpregs); + supply_fpregset (regcache, (const gdb_fpregset_t *) fpregs); } } @@ -3750,7 +3750,7 @@ procfs_prepare_to_store (void) writing one register might affect the value of others, etc. */ static void -procfs_store_registers (int regnum) +procfs_store_registers (struct regcache *regcache, int regnum) { gdb_gregset_t *gregs; procinfo *pi; @@ -3774,7 +3774,7 @@ procfs_store_registers (int regnum) if (gregs == NULL) proc_error (pi, "store_registers, get_gregs", __LINE__); - fill_gregset (current_regcache, gregs, regnum); + fill_gregset (regcache, gregs, regnum); if (!proc_set_gregs (pi)) proc_error (pi, "store_registers, set_gregs", __LINE__); @@ -3791,7 +3791,7 @@ procfs_store_registers (int regnum) if (fpregs == NULL) proc_error (pi, "store_registers, get_fpregs", __LINE__); - fill_fpregset (current_regcache, fpregs, regnum); + fill_fpregset (regcache, fpregs, regnum); if (!proc_set_fpregs (pi)) proc_error (pi, "store_registers, set_fpregs", __LINE__); } diff --git a/gdb/regcache.c b/gdb/regcache.c index 37e4bdc..15e4dba 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -508,8 +508,8 @@ regcache_raw_read (struct regcache *regcache, int regnum, gdb_byte *buf) registers_changed (); registers_ptid = inferior_ptid; } - if (!register_cached (regnum)) - target_fetch_registers (regnum); + 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 @@ -673,7 +673,7 @@ regcache_raw_write (struct regcache *regcache, int regnum, memcpy (register_buffer (regcache, regnum), buf, regcache->descr->sizeof_register[regnum]); regcache->register_valid_p[regnum] = 1; - target_store_registers (regnum); + target_store_registers (regcache, regnum); } void diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c index 664767a..110855a 100644 --- a/gdb/remote-m32r-sdi.c +++ b/gdb/remote-m32r-sdi.c @@ -903,26 +903,26 @@ get_reg_id (int regno) /* Read the remote registers into the block REGS. */ -static void m32r_fetch_register (int); +static void m32r_fetch_register (struct regcache *, int); static void -m32r_fetch_registers (void) +m32r_fetch_registers (struct regcache *regcache) { int regno; for (regno = 0; regno < NUM_REGS; regno++) - m32r_fetch_register (regno); + m32r_fetch_register (regcache, regno); } /* Fetch register REGNO, or all registers if REGNO is -1. Returns errno value. */ static void -m32r_fetch_register (int regno) +m32r_fetch_register (struct regcache *regcache, int regno) { unsigned long val, val2, regid; if (regno == -1) - m32r_fetch_registers (); + m32r_fetch_registers (regcache); else { char buffer[MAX_REGISTER_SIZE]; @@ -945,22 +945,22 @@ m32r_fetch_register (int regno) /* We got the number the register holds, but gdb expects to see a value in the target byte ordering. */ store_unsigned_integer (buffer, 4, val); - regcache_raw_supply (current_regcache, regno, buffer); + regcache_raw_supply (regcache, regno, buffer); } return; } /* Store the remote registers from the contents of the block REGS. */ -static void m32r_store_register (int); +static void m32r_store_register (struct regcache *, int); static void -m32r_store_registers (void) +m32r_store_registers (struct regcache *regcache) { int regno; for (regno = 0; regno < NUM_REGS; regno++) - m32r_store_register (regno); + m32r_store_register (regcache, regno); registers_changed (); } @@ -968,16 +968,16 @@ m32r_store_registers (void) /* Store register REGNO, or all if REGNO == 0. Return errno value. */ static void -m32r_store_register (int regno) +m32r_store_register (struct regcache *regcache, int regno) { int regid; ULONGEST regval, tmp; if (regno == -1) - m32r_store_registers (); + m32r_store_registers (regcache); else { - regcache_cooked_read_unsigned (current_regcache, regno, ®val); + regcache_cooked_read_unsigned (regcache, regno, ®val); regid = get_reg_id (regno); if (regid == SDI_REG_PSW) diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index 8089c01..dcbc15c 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -96,11 +96,11 @@ static ptid_t mips_wait (ptid_t ptid, static int mips_map_regno (int regno); -static void mips_fetch_registers (int regno); +static void mips_fetch_registers (struct regcache *regcache, int regno); static void mips_prepare_to_store (void); -static void mips_store_registers (int regno); +static void mips_store_registers (struct regcache *regcache, int regno); static unsigned int mips_fetch_word (CORE_ADDR addr); @@ -1892,7 +1892,7 @@ mips_map_regno (int regno) /* Fetch the remote registers. */ static void -mips_fetch_registers (int regno) +mips_fetch_registers (struct regcache *regcache, int regno) { unsigned LONGEST val; int err; @@ -1900,7 +1900,7 @@ mips_fetch_registers (int regno) if (regno == -1) { for (regno = 0; regno < NUM_REGS; regno++) - mips_fetch_registers (regno); + mips_fetch_registers (regcache, regno); return; } @@ -1938,7 +1938,7 @@ mips_fetch_registers (int regno) /* We got the number the register holds, but gdb expects to see a value in the target byte ordering. */ store_unsigned_integer (buf, register_size (current_gdbarch, regno), val); - regcache_raw_supply (current_regcache, regno, buf); + regcache_raw_supply (regcache, regno, buf); } } @@ -1953,19 +1953,20 @@ mips_prepare_to_store (void) /* Store remote register(s). */ static void -mips_store_registers (int regno) +mips_store_registers (struct regcache *regcache, int regno) { + ULONGEST val; int err; if (regno == -1) { for (regno = 0; regno < NUM_REGS; regno++) - mips_store_registers (regno); + mips_store_registers (regcache, regno); return; } - mips_request ('R', mips_map_regno (regno), - read_register (regno), + regcache_cooked_read_unsigned (regcache, regno, &val); + mips_request ('R', mips_map_regno (regno), val, &err, mips_receive_wait, NULL); if (err) mips_error ("Can't write register %d: %s", regno, safe_strerror (errno)); diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 2d8f3a7..425d1a6 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -73,9 +73,9 @@ static void gdb_os_evprintf_filtered (host_callback *, const char *, va_list); static void gdb_os_error (host_callback *, const char *, ...); -static void gdbsim_fetch_register (int regno); +static void gdbsim_fetch_register (struct regcache *regcache, int regno); -static void gdbsim_store_register (int regno); +static void gdbsim_store_register (struct regcache *regcache, int regno); static void gdbsim_kill (void); @@ -279,12 +279,12 @@ one2one_register_sim_regno (int regnum) } static void -gdbsim_fetch_register (int regno) +gdbsim_fetch_register (struct regcache *regcache, int regno) { if (regno == -1) { for (regno = 0; regno < NUM_REGS; regno++) - gdbsim_fetch_register (regno); + gdbsim_fetch_register (regcache, regno); return; } @@ -299,10 +299,11 @@ gdbsim_fetch_register (int regno) char buf[MAX_REGISTER_SIZE]; int nr_bytes; memset (buf, 0, MAX_REGISTER_SIZE); - regcache_raw_supply (current_regcache, regno, buf); + regcache_raw_supply (regcache, regno, buf); set_register_cached (regno, -1); break; } + default: { static int warn_user = 1; @@ -327,7 +328,7 @@ gdbsim_fetch_register (int regno) which registers are fetchable. */ /* Else if (nr_bytes < 0): an old simulator, that doesn't think to return the register size. Just assume all is ok. */ - regcache_raw_supply (current_regcache, regno, buf); + regcache_raw_supply (regcache, regno, buf); if (remote_debug) { printf_filtered ("gdbsim_fetch_register: %d", regno); @@ -341,19 +342,19 @@ gdbsim_fetch_register (int regno) static void -gdbsim_store_register (int regno) +gdbsim_store_register (struct regcache *regcache, int regno) { if (regno == -1) { for (regno = 0; regno < NUM_REGS; regno++) - gdbsim_store_register (regno); + gdbsim_store_register (regcache, regno); return; } else if (REGISTER_SIM_REGNO (regno) >= 0) { char tmp[MAX_REGISTER_SIZE]; int nr_bytes; - regcache_cooked_read (current_regcache, regno, tmp); + regcache_cooked_read (regcache, regno, tmp); nr_bytes = sim_store_register (gdbsim_desc, REGISTER_SIM_REGNO (regno), tmp, register_size (current_gdbarch, regno)); diff --git a/gdb/remote.c b/gdb/remote.c index 866c477..2c31c82 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -91,7 +91,7 @@ static void remote_files_info (struct target_ops *ignore); static void remote_prepare_to_store (void); -static void remote_fetch_registers (int regno); +static void remote_fetch_registers (struct regcache *regcache, int regno); static void remote_resume (ptid_t ptid, int step, enum target_signal siggnal); @@ -108,7 +108,7 @@ static void remote_open_1 (char *, int, struct target_ops *, int extended_p, static void remote_close (int quitting); -static void remote_store_registers (int regno); +static void remote_store_registers (struct regcache *regcache, int regno); static void remote_mourn (void); static void remote_async_mourn (void); @@ -3486,7 +3486,7 @@ got_status: /* Fetch a single register using a 'p' packet. */ static int -fetch_register_using_p (struct packet_reg *reg) +fetch_register_using_p (struct regcache *regcache, struct packet_reg *reg) { struct remote_state *rs = get_remote_state (); char *buf, *p; @@ -3521,7 +3521,7 @@ fetch_register_using_p (struct packet_reg *reg) /* If this register is unfetchable, tell the regcache. */ if (buf[0] == 'x') { - regcache_raw_supply (current_regcache, reg->regnum, NULL); + regcache_raw_supply (regcache, reg->regnum, NULL); set_register_cached (reg->regnum, -1); return 1; } @@ -3537,7 +3537,7 @@ fetch_register_using_p (struct packet_reg *reg) regp[i++] = fromhex (p[0]) * 16 + fromhex (p[1]); p += 2; } - regcache_raw_supply (current_regcache, reg->regnum, regp); + regcache_raw_supply (regcache, reg->regnum, regp); return 1; } @@ -3578,7 +3578,7 @@ send_g_packet (void) } static void -process_g_packet (void) +process_g_packet (struct regcache *regcache) { struct remote_state *rs = get_remote_state (); struct remote_arch_state *rsa = get_remote_arch_state (); @@ -3660,11 +3660,11 @@ process_g_packet (void) gdb_assert (r->offset * 2 < strlen (rs->buf)); /* The register isn't available, mark it as such (at the same time setting the value to zero). */ - regcache_raw_supply (current_regcache, r->regnum, NULL); + regcache_raw_supply (regcache, r->regnum, NULL); set_register_cached (i, -1); } else - regcache_raw_supply (current_regcache, r->regnum, + regcache_raw_supply (regcache, r->regnum, regs + r->offset); } } @@ -3672,14 +3672,14 @@ process_g_packet (void) } static void -fetch_registers_using_g (void) +fetch_registers_using_g (struct regcache *regcache) { send_g_packet (); - process_g_packet (); + process_g_packet (regcache); } static void -remote_fetch_registers (int regnum) +remote_fetch_registers (struct regcache *regcache, int regnum) { struct remote_state *rs = get_remote_state (); struct remote_arch_state *rsa = get_remote_arch_state (); @@ -3698,29 +3698,29 @@ remote_fetch_registers (int regnum) contents, so fall back to 'p'. */ if (reg->in_g_packet) { - fetch_registers_using_g (); + fetch_registers_using_g (regcache); if (reg->in_g_packet) return; } - if (fetch_register_using_p (reg)) + if (fetch_register_using_p (regcache, reg)) return; /* This register is not available. */ - regcache_raw_supply (current_regcache, reg->regnum, NULL); + regcache_raw_supply (regcache, reg->regnum, NULL); set_register_cached (reg->regnum, -1); return; } - fetch_registers_using_g (); + fetch_registers_using_g (regcache); for (i = 0; i < NUM_REGS; i++) if (!rsa->regs[i].in_g_packet) - if (!fetch_register_using_p (&rsa->regs[i])) + if (!fetch_register_using_p (regcache, &rsa->regs[i])) { /* This register is not available. */ - regcache_raw_supply (current_regcache, i, NULL); + regcache_raw_supply (regcache, i, NULL); set_register_cached (i, -1); } } @@ -3755,7 +3755,7 @@ remote_prepare_to_store (void) packet was not recognized. */ static int -store_register_using_P (struct packet_reg *reg) +store_register_using_P (const struct regcache *regcache, struct packet_reg *reg) { struct remote_state *rs = get_remote_state (); struct remote_arch_state *rsa = get_remote_arch_state (); @@ -3772,7 +3772,7 @@ store_register_using_P (struct packet_reg *reg) xsnprintf (buf, get_remote_packet_size (), "P%s=", phex_nz (reg->pnum, 0)); p = buf + strlen (buf); - regcache_raw_collect (current_regcache, reg->regnum, regp); + regcache_raw_collect (regcache, reg->regnum, regp); bin2hex (regp, p, register_size (current_gdbarch, reg->regnum)); remote_send (&rs->buf, &rs->buf_size); @@ -3794,7 +3794,7 @@ store_register_using_P (struct packet_reg *reg) contents of the register cache buffer. FIXME: ignores errors. */ static void -store_registers_using_G (void) +store_registers_using_G (const struct regcache *regcache) { struct remote_state *rs = get_remote_state (); struct remote_arch_state *rsa = get_remote_arch_state (); @@ -3811,7 +3811,7 @@ store_registers_using_G (void) { struct packet_reg *r = &rsa->regs[i]; if (r->in_g_packet) - regcache_raw_collect (current_regcache, r->regnum, regs + r->offset); + regcache_raw_collect (regcache, r->regnum, regs + r->offset); } } @@ -3829,7 +3829,7 @@ store_registers_using_G (void) of the register cache buffer. FIXME: ignores errors. */ static void -remote_store_registers (int regnum) +remote_store_registers (struct regcache *regcache, int regnum) { struct remote_state *rs = get_remote_state (); struct remote_arch_state *rsa = get_remote_arch_state (); @@ -3846,7 +3846,7 @@ remote_store_registers (int regnum) possible; we often change only a small number of registers. Sometimes we change a larger number; we'd need help from a higher layer to know to use 'G'. */ - if (store_register_using_P (reg)) + if (store_register_using_P (regcache, reg)) return; /* For now, don't complain if we have no way to write the @@ -3856,15 +3856,15 @@ remote_store_registers (int regnum) if (!reg->in_g_packet) return; - store_registers_using_G (); + store_registers_using_G (regcache); return; } - store_registers_using_G (); + store_registers_using_G (regcache); for (i = 0; i < NUM_REGS; i++) if (!rsa->regs[i].in_g_packet) - if (!store_register_using_P (&rsa->regs[i])) + if (!store_register_using_P (regcache, &rsa->regs[i])) /* See above for why we do not issue an error here. */ continue; } diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index dca0830..9adc1fd 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -210,7 +210,7 @@ rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf) /* Fetch register REGNO from the inferior. */ static void -fetch_register (int regno) +fetch_register (struct regcache *regcache, int regno) { int addr[MAX_REGISTER_SIZE]; int nr, isfloat; @@ -253,7 +253,7 @@ fetch_register (int regno) } if (!errno) - regcache_raw_supply (current_regcache, regno, (char *) addr); + regcache_raw_supply (regcache, regno, (char *) addr); else { #if 0 @@ -267,13 +267,13 @@ fetch_register (int regno) /* Store register REGNO back into the inferior. */ static void -store_register (int regno) +store_register (const struct regcache *regcache, int regno) { int addr[MAX_REGISTER_SIZE]; int nr, isfloat; /* Fetch the register's value from the register cache. */ - regcache_raw_collect (current_regcache, regno, addr); + regcache_raw_collect (regcache, regno, addr); /* -1 can be a successful return value, so infer errors from errno. */ errno = 0; @@ -333,10 +333,10 @@ store_register (int regno) REGNO otherwise. */ static void -rs6000_fetch_inferior_registers (int regno) +rs6000_fetch_inferior_registers (struct regcache *regcache, int regno) { if (regno != -1) - fetch_register (regno); + fetch_register (regcache, regno); else { @@ -347,25 +347,25 @@ rs6000_fetch_inferior_registers (int regno) regno < tdep->ppc_gp0_regnum + ppc_num_gprs; regno++) { - fetch_register (regno); + fetch_register (regcache, regno); } /* Read general purpose floating point registers. */ if (tdep->ppc_fp0_regnum >= 0) for (regno = 0; regno < ppc_num_fprs; regno++) - fetch_register (tdep->ppc_fp0_regnum + regno); + fetch_register (regcache, tdep->ppc_fp0_regnum + regno); /* Read special registers. */ - fetch_register (PC_REGNUM); - fetch_register (tdep->ppc_ps_regnum); - fetch_register (tdep->ppc_cr_regnum); - fetch_register (tdep->ppc_lr_regnum); - fetch_register (tdep->ppc_ctr_regnum); - fetch_register (tdep->ppc_xer_regnum); + fetch_register (regcache, PC_REGNUM); + fetch_register (regcache, tdep->ppc_ps_regnum); + fetch_register (regcache, tdep->ppc_cr_regnum); + fetch_register (regcache, tdep->ppc_lr_regnum); + fetch_register (regcache, tdep->ppc_ctr_regnum); + fetch_register (regcache, tdep->ppc_xer_regnum); if (tdep->ppc_fpscr_regnum >= 0) - fetch_register (tdep->ppc_fpscr_regnum); + fetch_register (regcache, tdep->ppc_fpscr_regnum); if (tdep->ppc_mq_regnum >= 0) - fetch_register (tdep->ppc_mq_regnum); + fetch_register (regcache, tdep->ppc_mq_regnum); } } @@ -374,10 +374,10 @@ rs6000_fetch_inferior_registers (int regno) Otherwise, REGNO specifies which register (so we can save time). */ static void -rs6000_store_inferior_registers (int regno) +rs6000_store_inferior_registers (struct regcache *regcache, int regno) { if (regno != -1) - store_register (regno); + store_register (regcache, regno); else { @@ -388,25 +388,25 @@ rs6000_store_inferior_registers (int regno) regno < tdep->ppc_gp0_regnum + ppc_num_gprs; regno++) { - store_register (regno); + store_register (regcache, regno); } /* Write floating point registers. */ if (tdep->ppc_fp0_regnum >= 0) for (regno = 0; regno < ppc_num_fprs; regno++) - store_register (tdep->ppc_fp0_regnum + regno); + store_register (regcache, tdep->ppc_fp0_regnum + regno); /* Write special registers. */ - store_register (PC_REGNUM); - store_register (tdep->ppc_ps_regnum); - store_register (tdep->ppc_cr_regnum); - store_register (tdep->ppc_lr_regnum); - store_register (tdep->ppc_ctr_regnum); - store_register (tdep->ppc_xer_regnum); + store_register (regcache, PC_REGNUM); + store_register (regcache, tdep->ppc_ps_regnum); + store_register (regcache, tdep->ppc_cr_regnum); + store_register (regcache, tdep->ppc_lr_regnum); + store_register (regcache, tdep->ppc_ctr_regnum); + store_register (regcache, tdep->ppc_xer_regnum); if (tdep->ppc_fpscr_regnum >= 0) - store_register (tdep->ppc_fpscr_regnum); + store_register (regcache, tdep->ppc_fpscr_regnum); if (tdep->ppc_mq_regnum >= 0) - store_register (tdep->ppc_mq_regnum); + store_register (regcache, tdep->ppc_mq_regnum); } } diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 9622aa2..e5099f5 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -1715,7 +1715,7 @@ ran_out_of_registers_for_arguments: regcache_raw_write_signed (regcache, tdep->ppc_toc_regnum, tocvalue); } - target_store_registers (-1); + target_store_registers (regcache, -1); return sp; } diff --git a/gdb/s390-nat.c b/gdb/s390-nat.c index a167bb7..845b8dd 100644 --- a/gdb/s390-nat.c +++ b/gdb/s390-nat.c @@ -128,7 +128,7 @@ s390_inferior_tid (void) /* Fetch all general-purpose registers from process/thread TID and store their values in GDB's register cache. */ static void -fetch_regs (int tid) +fetch_regs (struct regcache *regcache, int tid) { gregset_t regs; ptrace_area parea; @@ -139,13 +139,13 @@ fetch_regs (int tid) if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) perror_with_name (_("Couldn't get registers")); - supply_gregset (current_regcache, (const gregset_t *) ®s); + supply_gregset (regcache, (const gregset_t *) ®s); } /* Store all valid general-purpose registers in GDB's register cache into the process/thread specified by TID. */ static void -store_regs (int tid, int regnum) +store_regs (const struct regcache *regcache, int tid, int regnum) { gregset_t regs; ptrace_area parea; @@ -156,7 +156,7 @@ store_regs (int tid, int regnum) if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) perror_with_name (_("Couldn't get registers")); - fill_gregset (current_regcache, ®s, regnum); + fill_gregset (regcache, ®s, regnum); if (ptrace (PTRACE_POKEUSR_AREA, tid, (long) &parea) < 0) perror_with_name (_("Couldn't write registers")); @@ -165,7 +165,7 @@ store_regs (int tid, int regnum) /* Fetch all floating-point registers from process/thread TID and store their values in GDB's register cache. */ static void -fetch_fpregs (int tid) +fetch_fpregs (struct regcache *regcache, int tid) { fpregset_t fpregs; ptrace_area parea; @@ -176,13 +176,13 @@ fetch_fpregs (int tid) if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) perror_with_name (_("Couldn't get floating point status")); - supply_fpregset (current_regcache, (const fpregset_t *) &fpregs); + supply_fpregset (regcache, (const fpregset_t *) &fpregs); } /* Store all valid floating-point registers in GDB's register cache into the process/thread specified by TID. */ static void -store_fpregs (int tid, int regnum) +store_fpregs (const struct regcache *regcache, int tid, int regnum) { fpregset_t fpregs; ptrace_area parea; @@ -193,7 +193,7 @@ store_fpregs (int tid, int regnum) if (ptrace (PTRACE_PEEKUSR_AREA, tid, (long) &parea) < 0) perror_with_name (_("Couldn't get floating point status")); - fill_fpregset (current_regcache, &fpregs, regnum); + fill_fpregset (regcache, &fpregs, regnum); if (ptrace (PTRACE_POKEUSR_AREA, tid, (long) &parea) < 0) perror_with_name (_("Couldn't write floating point status")); @@ -202,33 +202,33 @@ store_fpregs (int tid, int regnum) /* Fetch register REGNUM from the child process. If REGNUM is -1, do this for all registers. */ static void -s390_linux_fetch_inferior_registers (int regnum) +s390_linux_fetch_inferior_registers (struct regcache *regcache, int regnum) { int tid = s390_inferior_tid (); if (regnum == -1 || (regnum < S390_NUM_REGS && regmap_gregset[regnum] != -1)) - fetch_regs (tid); + fetch_regs (regcache, tid); if (regnum == -1 || (regnum < S390_NUM_REGS && regmap_fpregset[regnum] != -1)) - fetch_fpregs (tid); + fetch_fpregs (regcache, tid); } /* Store register REGNUM back into the child process. If REGNUM is -1, do this for all registers. */ static void -s390_linux_store_inferior_registers (int regnum) +s390_linux_store_inferior_registers (struct regcache *regcache, int regnum) { int tid = s390_inferior_tid (); if (regnum == -1 || (regnum < S390_NUM_REGS && regmap_gregset[regnum] != -1)) - store_regs (tid, regnum); + store_regs (regcache, tid, regnum); if (regnum == -1 || (regnum < S390_NUM_REGS && regmap_fpregset[regnum] != -1)) - store_fpregs (tid, regnum); + store_fpregs (regcache, tid, regnum); } diff --git a/gdb/shnbsd-nat.c b/gdb/shnbsd-nat.c index 128dc0f..6afa573 100644 --- a/gdb/shnbsd-nat.c +++ b/gdb/shnbsd-nat.c @@ -42,7 +42,7 @@ || (regno) == SR_REGNUM) static void -shnbsd_fetch_inferior_registers (int regno) +shnbsd_fetch_inferior_registers (struct regcache *regcache, int regno) { if (regno == -1 || GETREGS_SUPPLIES (regno)) { @@ -52,7 +52,7 @@ shnbsd_fetch_inferior_registers (int regno) (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) perror_with_name (_("Couldn't get registers")); - shnbsd_supply_reg (current_regcache, (char *) &inferior_registers, regno); + shnbsd_supply_reg (regcache, (char *) &inferior_registers, regno); if (regno != -1) return; @@ -60,7 +60,7 @@ shnbsd_fetch_inferior_registers (int regno) } static void -shnbsd_store_inferior_registers (int regno) +shnbsd_store_inferior_registers (struct regcache *regcache, int regno) { if (regno == -1 || GETREGS_SUPPLIES (regno)) { @@ -70,7 +70,7 @@ shnbsd_store_inferior_registers (int regno) (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) perror_with_name (_("Couldn't get registers")); - shnbsd_fill_reg (current_regcache, (char *) &inferior_registers, regno); + shnbsd_fill_reg (regcache, (char *) &inferior_registers, regno); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1) diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index bb8d20b..722e253 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -478,7 +478,7 @@ sol_thread_wait (ptid_t ptid, struct target_waitstatus *ourstatus) } static void -sol_thread_fetch_registers (int regnum) +sol_thread_fetch_registers (struct regcache *regcache, int regnum) { thread_t thread; td_thrhandle_t thandle; @@ -494,9 +494,9 @@ sol_thread_fetch_registers (int regnum) { /* It's an LWP; pass the request on to procfs. */ if (target_has_execution) - procfs_ops.to_fetch_registers (regnum); + procfs_ops.to_fetch_registers (regcache, regnum); else - orig_core_ops.to_fetch_registers (regnum); + orig_core_ops.to_fetch_registers (regcache, regnum); return; } @@ -531,8 +531,8 @@ sol_thread_fetch_registers (int regnum) calling the td routines because the td routines call ps_lget* which affect the values stored in the registers array. */ - supply_gregset (current_regcache, (const gdb_gregset_t *) &gregset); - supply_fpregset (current_regcache, (const gdb_fpregset_t *) &fpregset); + supply_gregset (regcache, (const gdb_gregset_t *) &gregset); + supply_fpregset (regcache, (const gdb_fpregset_t *) &fpregset); #if 0 /* FIXME: libthread_db doesn't seem to handle this right. */ @@ -553,7 +553,7 @@ sol_thread_fetch_registers (int regnum) } static void -sol_thread_store_registers (int regnum) +sol_thread_store_registers (struct regcache *regcache, int regnum) { thread_t thread; td_thrhandle_t thandle; @@ -568,7 +568,7 @@ sol_thread_store_registers (int regnum) if (!is_thread (inferior_ptid)) { /* It's an LWP; pass the request on to procfs.c. */ - procfs_ops.to_store_registers (regnum); + procfs_ops.to_store_registers (regcache, regnum); return; } @@ -586,7 +586,7 @@ sol_thread_store_registers (int regnum) char old_value[MAX_REGISTER_SIZE]; /* Save new register value. */ - regcache_raw_collect (current_regcache, regnum, old_value); + regcache_raw_collect (regcache, regnum, old_value); val = p_td_thr_getgregs (&thandle, gregset); if (val != TD_OK) @@ -598,7 +598,7 @@ sol_thread_store_registers (int regnum) td_err_string (val)); /* Restore new register value. */ - regcache_raw_supply (current_regcache, regnum, old_value); + regcache_raw_supply (regcache, regnum, old_value); #if 0 /* FIXME: libthread_db doesn't seem to handle this right. */ @@ -618,8 +618,8 @@ sol_thread_store_registers (int regnum) #endif } - fill_gregset (current_regcache, (gdb_gregset_t *) &gregset, regnum); - fill_fpregset (current_regcache, (gdb_fpregset_t *) &fpregset, regnum); + fill_gregset (regcache, (gdb_gregset_t *) &gregset, regnum); + fill_fpregset (regcache, (gdb_fpregset_t *) &fpregset, regnum); val = p_td_thr_setgregs (&thandle, gregset); if (val != TD_OK) @@ -1104,9 +1104,9 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); if (target_has_execution) - procfs_ops.to_fetch_registers (-1); + procfs_ops.to_fetch_registers (current_regcache, -1); else - orig_core_ops.to_fetch_registers (-1); + orig_core_ops.to_fetch_registers (current_regcache, -1); fill_gregset (current_regcache, (gdb_gregset_t *) gregset, -1); do_cleanups (old_chain); @@ -1128,9 +1128,9 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, supply_gregset (current_regcache, (const gdb_gregset_t *) gregset); if (target_has_execution) - procfs_ops.to_store_registers (-1); + procfs_ops.to_store_registers (current_regcache, -1); else - orig_core_ops.to_store_registers (-1); + orig_core_ops.to_store_registers (current_regcache, -1); do_cleanups (old_chain); @@ -1236,9 +1236,9 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); if (target_has_execution) - procfs_ops.to_fetch_registers (-1); + procfs_ops.to_fetch_registers (current_regcache, -1); else - orig_core_ops.to_fetch_registers (-1); + orig_core_ops.to_fetch_registers (current_regcache, -1); fill_fpregset (current_regcache, (gdb_fpregset_t *) fpregset, -1); do_cleanups (old_chain); @@ -1260,9 +1260,9 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, supply_fpregset (current_regcache, (const gdb_fpregset_t *) fpregset); if (target_has_execution) - procfs_ops.to_store_registers (-1); + procfs_ops.to_store_registers (current_regcache, -1); else - orig_core_ops.to_store_registers (-1); + orig_core_ops.to_store_registers (current_regcache, -1); do_cleanups (old_chain); diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c index 7125fc4..268f868 100644 --- a/gdb/sparc-nat.c +++ b/gdb/sparc-nat.c @@ -135,9 +135,8 @@ sparc32_fpregset_supplies_p (int regnum) for all registers (including the floating-point registers). */ void -fetch_inferior_registers (int regnum) +fetch_inferior_registers (struct regcache *regcache, int regnum) { - struct regcache *regcache = current_regcache; int pid; /* NOTE: cagney/2002-12-03: This code assumes that the currently @@ -187,9 +186,8 @@ fetch_inferior_registers (int regnum) } void -store_inferior_registers (int regnum) +store_inferior_registers (struct regcache *regcache, int regnum) { - struct regcache *regcache = current_regcache; int pid; /* NOTE: cagney/2002-12-02: See comment in fetch_inferior_registers diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c index 7f71b58..514fd7f 100644 --- a/gdb/spu-linux-nat.c +++ b/gdb/spu-linux-nat.c @@ -441,7 +441,7 @@ spu_child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) /* Override the fetch_inferior_register routine. */ static void -spu_fetch_inferior_registers (int regno) +spu_fetch_inferior_registers (struct regcache *regcache, int regno) { int fd; CORE_ADDR addr; @@ -455,7 +455,7 @@ spu_fetch_inferior_registers (int regno) { char buf[4]; store_unsigned_integer (buf, 4, fd); - regcache_raw_supply (current_regcache, SPU_ID_REGNUM, buf); + regcache_raw_supply (regcache, SPU_ID_REGNUM, buf); } /* The NPC register is found at ADDR. */ @@ -463,7 +463,7 @@ spu_fetch_inferior_registers (int regno) { gdb_byte buf[4]; if (fetch_ppc_memory (addr, buf, 4) == 0) - regcache_raw_supply (current_regcache, SPU_PC_REGNUM, buf); + regcache_raw_supply (regcache, SPU_PC_REGNUM, buf); } /* The GPRs are found in the "regs" spufs file. */ @@ -476,13 +476,13 @@ spu_fetch_inferior_registers (int regno) xsnprintf (annex, sizeof annex, "%d/regs", fd); if (spu_proc_xfer_spu (annex, buf, NULL, 0, sizeof buf) == sizeof buf) for (i = 0; i < SPU_NUM_GPRS; i++) - regcache_raw_supply (current_regcache, i, buf + i*16); + regcache_raw_supply (regcache, i, buf + i*16); } } /* Override the store_inferior_register routine. */ static void -spu_store_inferior_registers (int regno) +spu_store_inferior_registers (struct regcache *regcache, int regno) { int fd; CORE_ADDR addr; @@ -495,7 +495,7 @@ spu_store_inferior_registers (int regno) if (regno == -1 || regno == SPU_PC_REGNUM) { gdb_byte buf[4]; - regcache_raw_collect (current_regcache, SPU_PC_REGNUM, buf); + regcache_raw_collect (regcache, SPU_PC_REGNUM, buf); store_ppc_memory (addr, buf, 4); } @@ -507,7 +507,7 @@ spu_store_inferior_registers (int regno) int i; for (i = 0; i < SPU_NUM_GPRS; i++) - regcache_raw_collect (current_regcache, i, buf + i*16); + regcache_raw_collect (regcache, i, buf + i*16); xsnprintf (annex, sizeof annex, "%d/regs", fd); spu_proc_xfer_spu (annex, NULL, buf, 0, sizeof buf); diff --git a/gdb/target.c b/gdb/target.c index 0299f9a..fd833de 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -106,9 +106,9 @@ static void debug_to_resume (ptid_t, int, enum target_signal); static ptid_t debug_to_wait (ptid_t, struct target_waitstatus *); -static void debug_to_fetch_registers (int); +static void debug_to_fetch_registers (struct regcache *, int); -static void debug_to_store_registers (int); +static void debug_to_store_registers (struct regcache *, int); static void debug_to_prepare_to_store (void); @@ -503,10 +503,10 @@ update_current_target (void) (ptid_t (*) (ptid_t, struct target_waitstatus *)) noprocess); de_fault (to_fetch_registers, - (void (*) (int)) + (void (*) (struct regcache *, int)) target_ignore); de_fault (to_store_registers, - (void (*) (int)) + (void (*) (struct regcache *, int)) noprocess); de_fault (to_prepare_to_store, (void (*) (void)) @@ -2150,7 +2150,8 @@ debug_to_wait (ptid_t ptid, struct target_waitstatus *status) } static void -debug_print_register (const char * func, int regno) +debug_print_register (const char * func, + struct regcache *regcache, int regno) { fprintf_unfiltered (gdb_stdlog, "%s ", func); if (regno >= 0 && regno < NUM_REGS + NUM_PSEUDO_REGS @@ -2162,7 +2163,7 @@ debug_print_register (const char * func, int regno) { int i, size = register_size (current_gdbarch, regno); unsigned char buf[MAX_REGISTER_SIZE]; - regcache_cooked_read (current_regcache, regno, buf); + regcache_cooked_read (regcache, regno, buf); fprintf_unfiltered (gdb_stdlog, " = "); for (i = 0; i < size; i++) { @@ -2179,17 +2180,17 @@ debug_print_register (const char * func, int regno) } static void -debug_to_fetch_registers (int regno) +debug_to_fetch_registers (struct regcache *regcache, int regno) { - debug_target.to_fetch_registers (regno); - debug_print_register ("target_fetch_registers", regno); + debug_target.to_fetch_registers (regcache, regno); + debug_print_register ("target_fetch_registers", regcache, regno); } static void -debug_to_store_registers (int regno) +debug_to_store_registers (struct regcache *regcache, int regno) { - debug_target.to_store_registers (regno); - debug_print_register ("target_store_registers", regno); + debug_target.to_store_registers (regcache, regno); + debug_print_register ("target_store_registers", regcache, regno); fprintf_unfiltered (gdb_stdlog, "\n"); } diff --git a/gdb/target.h b/gdb/target.h index 2420b2e..ad4e437 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -31,6 +31,7 @@ struct ui_file; struct mem_attrib; struct target_ops; struct bp_target_info; +struct regcache; /* This include file defines the interface between the main part of the debugger, and the part which is target-specific, or @@ -323,8 +324,8 @@ struct target_ops void (*to_disconnect) (struct target_ops *, char *, int); void (*to_resume) (ptid_t, int, enum target_signal); ptid_t (*to_wait) (ptid_t, struct target_waitstatus *); - void (*to_fetch_registers) (int); - void (*to_store_registers) (int); + void (*to_fetch_registers) (struct regcache *, int); + void (*to_store_registers) (struct regcache *, int); void (*to_prepare_to_store) (void); /* Transfer LEN bytes of memory between GDB address MYADDR and @@ -589,15 +590,15 @@ extern void target_disconnect (char *, int); /* Fetch at least register REGNO, or all regs if regno == -1. No result. */ -#define target_fetch_registers(regno) \ - (*current_target.to_fetch_registers) (regno) +#define target_fetch_registers(regcache, regno) \ + (*current_target.to_fetch_registers) (regcache, regno) /* Store at least register REGNO, or all regs if REGNO == -1. It can store as many registers as it wants to, so target_prepare_to_store must have been previously called. Calls error() if there are problems. */ -#define target_store_registers(regs) \ - (*current_target.to_store_registers) (regs) +#define target_store_registers(regcache, regs) \ + (*current_target.to_store_registers) (regcache, regs) /* Get ready to modify the registers array. On machines which store individual registers, this doesn't need to do anything. On machines diff --git a/gdb/vaxbsd-nat.c b/gdb/vaxbsd-nat.c index 388d527..229e8a6 100644 --- a/gdb/vaxbsd-nat.c +++ b/gdb/vaxbsd-nat.c @@ -65,7 +65,7 @@ vaxbsd_collect_gregset (const struct regcache *regcache, for all registers. */ static void -vaxbsd_fetch_inferior_registers (int regnum) +vaxbsd_fetch_inferior_registers (struct regcache *regcache, int regnum) { struct reg regs; @@ -73,14 +73,14 @@ vaxbsd_fetch_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - vaxbsd_supply_gregset (current_regcache, ®s); + vaxbsd_supply_gregset (regcache, ®s); } /* Store register REGNUM back into the inferior. If REGNUM is -1, do this for all registers. */ static void -vaxbsd_store_inferior_registers (int regnum) +vaxbsd_store_inferior_registers (struct regcache *regcache, int regnum) { struct reg regs; @@ -88,7 +88,7 @@ vaxbsd_store_inferior_registers (int regnum) (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); - vaxbsd_collect_gregset (current_regcache, ®s, regnum); + vaxbsd_collect_gregset (regcache, ®s, regnum); if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_TYPE_ARG3) ®s, 0) == -1) diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c index 7d6aab0..922cc28 100644 --- a/gdb/win32-nat.c +++ b/gdb/win32-nat.c @@ -343,7 +343,7 @@ win32_delete_thread (DWORD id) } static void -do_win32_fetch_inferior_registers (int r) +do_win32_fetch_inferior_registers (struct regcache *regcache, int r) { char *context_offset = ((char *) ¤t_thread->context) + mappings[r]; long l; @@ -385,58 +385,58 @@ do_win32_fetch_inferior_registers (int r) if (r == I387_FISEG_REGNUM) { l = *((long *) context_offset) & 0xffff; - regcache_raw_supply (current_regcache, r, (char *) &l); + regcache_raw_supply (regcache, r, (char *) &l); } else if (r == I387_FOP_REGNUM) { l = (*((long *) context_offset) >> 16) & ((1 << 11) - 1); - regcache_raw_supply (current_regcache, r, (char *) &l); + regcache_raw_supply (regcache, r, (char *) &l); } else if (r >= 0) - regcache_raw_supply (current_regcache, r, context_offset); + regcache_raw_supply (regcache, r, context_offset); else { for (r = 0; r < NUM_REGS; r++) - do_win32_fetch_inferior_registers (r); + do_win32_fetch_inferior_registers (regcache, r); } #undef I387_ST0_REGNUM } static void -win32_fetch_inferior_registers (int r) +win32_fetch_inferior_registers (struct regcache *regcache, int r) { current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); /* Check if current_thread exists. Windows sometimes uses a non-existent thread id in its events */ if (current_thread) - do_win32_fetch_inferior_registers (r); + do_win32_fetch_inferior_registers (regcache, r); } static void -do_win32_store_inferior_registers (int r) +do_win32_store_inferior_registers (const struct regcache *regcache, int r) { if (!current_thread) /* Windows sometimes uses a non-existent thread id in its events */; else if (r >= 0) - regcache_raw_collect (current_regcache, r, + regcache_raw_collect (regcache, r, ((char *) ¤t_thread->context) + mappings[r]); else { for (r = 0; r < NUM_REGS; r++) - do_win32_store_inferior_registers (r); + do_win32_store_inferior_registers (regcache, r); } } /* Store a new register value into the current thread context */ static void -win32_store_inferior_registers (int r) +win32_store_inferior_registers (struct regcache *regcache, int r) { current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); /* Check if current_thread exists. Windows sometimes uses a non-existent thread id in its events */ if (current_thread) - do_win32_store_inferior_registers (r); + do_win32_store_inferior_registers (regcache, r); } static int psapi_loaded = 0; @@ -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 (PS_REGNUM); + win32_fetch_inferior_registers (current_regcache, PS_REGNUM); th->context.EFlags |= FLAG_TRACE_BIT; } diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 7d6aab0..922cc28 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -343,7 +343,7 @@ win32_delete_thread (DWORD id) } static void -do_win32_fetch_inferior_registers (int r) +do_win32_fetch_inferior_registers (struct regcache *regcache, int r) { char *context_offset = ((char *) ¤t_thread->context) + mappings[r]; long l; @@ -385,58 +385,58 @@ do_win32_fetch_inferior_registers (int r) if (r == I387_FISEG_REGNUM) { l = *((long *) context_offset) & 0xffff; - regcache_raw_supply (current_regcache, r, (char *) &l); + regcache_raw_supply (regcache, r, (char *) &l); } else if (r == I387_FOP_REGNUM) { l = (*((long *) context_offset) >> 16) & ((1 << 11) - 1); - regcache_raw_supply (current_regcache, r, (char *) &l); + regcache_raw_supply (regcache, r, (char *) &l); } else if (r >= 0) - regcache_raw_supply (current_regcache, r, context_offset); + regcache_raw_supply (regcache, r, context_offset); else { for (r = 0; r < NUM_REGS; r++) - do_win32_fetch_inferior_registers (r); + do_win32_fetch_inferior_registers (regcache, r); } #undef I387_ST0_REGNUM } static void -win32_fetch_inferior_registers (int r) +win32_fetch_inferior_registers (struct regcache *regcache, int r) { current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); /* Check if current_thread exists. Windows sometimes uses a non-existent thread id in its events */ if (current_thread) - do_win32_fetch_inferior_registers (r); + do_win32_fetch_inferior_registers (regcache, r); } static void -do_win32_store_inferior_registers (int r) +do_win32_store_inferior_registers (const struct regcache *regcache, int r) { if (!current_thread) /* Windows sometimes uses a non-existent thread id in its events */; else if (r >= 0) - regcache_raw_collect (current_regcache, r, + regcache_raw_collect (regcache, r, ((char *) ¤t_thread->context) + mappings[r]); else { for (r = 0; r < NUM_REGS; r++) - do_win32_store_inferior_registers (r); + do_win32_store_inferior_registers (regcache, r); } } /* Store a new register value into the current thread context */ static void -win32_store_inferior_registers (int r) +win32_store_inferior_registers (struct regcache *regcache, int r) { current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); /* Check if current_thread exists. Windows sometimes uses a non-existent thread id in its events */ if (current_thread) - do_win32_store_inferior_registers (r); + do_win32_store_inferior_registers (regcache, r); } static int psapi_loaded = 0; @@ -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 (PS_REGNUM); + win32_fetch_inferior_registers (current_regcache, PS_REGNUM); th->context.EFlags |= FLAG_TRACE_BIT; } |