/* Native-dependent code for Alpha BSD's.
- Copyright 2000, 2001 Free Software Foundation, Inc.
+ Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of GDB.
for (i = 0; i < NUM_GREGS; i++)
if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i))
- memcpy (&gregsetp->r_regs[i], ®isters[REGISTER_BYTE (i)],
- REGISTER_RAW_SIZE (i));
+ regcache_collect (i, (char *) &gregsetp->r_regs[i]);
/* The PC travels in the R_ZERO slot. */
if (regno == -1 || regno == PC_REGNUM)
- memcpy (&gregsetp->r_regs[R_ZERO], ®isters[REGISTER_BYTE (PC_REGNUM)],
- REGISTER_RAW_SIZE (PC_REGNUM));
+ regcache_collect (PC_REGNUM, (char *) &gregsetp->r_regs[R_ZERO]);
}
/* Fill GDB's register array with the floating-point register values
for (i = FP0_REGNUM; i < FP0_REGNUM + NUM_FPREGS; i++)
if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i))
- memcpy (&fpregsetp->fpr_regs[i - FP0_REGNUM],
- ®isters[REGISTER_BYTE (i)], REGISTER_RAW_SIZE (i));
+ regcache_collect (i, (char *) &fpregsetp->fpr_regs[i - FP0_REGNUM]);
if (regno == -1 || regno == FPCR_REGNUM)
- memcpy (&fpregsetp->fpr_cr, ®isters[REGISTER_BYTE (FPCR_REGNUM)],
- REGISTER_RAW_SIZE (FPCR_REGNUM));
+ regcache_collect (FPCR_REGNUM, (char *) &fpregsetp->fpr_cr);
}
+
+/* Determine if PT_GETREGS fetches this register. */
+
+static int
+getregs_supplies (int regno)
+{
+
+ return ((regno >= V0_REGNUM && regno <= ZERO_REGNUM)
+ || regno >= PC_REGNUM);
+}
+
+
/* Fetch register REGNO from the inferior. If REGNO is -1, do this
for all registers (including the floating point registers). */
void
fetch_inferior_registers (int regno)
{
- gregset_t gregs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
- (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
- perror_with_name ("Couldn't get registers");
+ if (regno == -1 || getregs_supplies (regno))
+ {
+ gregset_t gregs;
+
+ if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+ perror_with_name ("Couldn't get registers");
- supply_gregset (&gregs);
+ supply_gregset (&gregs);
+ if (regno != -1)
+ return;
+ }
if (regno == -1 || regno >= FP0_REGNUM)
{
void
store_inferior_registers (int regno)
{
- gregset_t gregs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
- (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
- perror_with_name ("Couldn't get registers");
+ if (regno == -1 || getregs_supplies (regno))
+ {
+ gregset_t gregs;
+ if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+ perror_with_name ("Couldn't get registers");
+
+ fill_gregset (&gregs, regno);
- fill_gregset (&gregs, regno);
+ if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+ perror_with_name ("Couldn't write registers");
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
- (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
- perror_with_name ("Couldn't write registers");
+ if (regno != -1)
+ return;
+ }
if (regno == -1 || regno >= FP0_REGNUM)
{