+2001-12-09 Elena Zannoni <ezannoni@redhat.com>
+
+ * config/rs6000/tm-rs6000.h (STAB_REG_TO_REGNUM): Remove
+ definition, it is now multiarched.
+ * ppc-tdep.h (struct gdbarch_tdep): Move from rs6000-tdep.c. Add
+ fields for special register numbers.
+ * rs6000-tdep.c (rs6000_gdbarch_init): Initialize new tdep special
+ regnum fields.
+ (rs6000_saved_pc_after_call): Use gdbarch_tdep registers fields
+ instead of hardcoded macros.
+ (branch_dest, rs6000_pop_frame, rs6000_fix_call_dummy,
+ ppc_push_return_address, rs6000_frame_saved_pc,
+ frame_get_saved_regs, rs6000_frame_chain,
+ rs6000_store_return_value): Ditto.
+ (rs6000_stab_reg_to_regnum): New function.
+ * ppcnbsd-nat.c (fetch_inferior_registers,
+ store_inferior_registers, fetch_core_registers): Ditto.
+ * ppc-linux-tdep.c (ppc_linux_in_sigtramp,
+ ppc_linux_frame_init_saved_regs): Ditto.
+ * ppc-linux-nat.c (ppc_register_u_addr, supply_gregset,
+ fill_gregset): Ditto.
+ * ppc-bdm.c (bdm_ppc_fetch_registers, bdm_ppc_store_registers):
+ Ditto.
+
2001-12-08 Fred Fish <fnf@redhat.com>
* c-lang.c (c_create_fundamental_type): For FT_CHAR, pass
#define FIRST_UISA_SP_REGNUM 64 /* first special register number */
#define LAST_UISA_SP_REGNUM 70 /* last special register number */
-/* convert a dbx stab register number (from `r' declaration) to a gdb REGNUM */
-
-#define STAB_REG_TO_REGNUM(value) (value)
-
/* Define other aspects of the stack frame. */
#define INIT_FRAME_PC_FIRST(fromleaf, prev) \
/* printf("Asking for register %d\n", first_regno); */
/* if asking for an invalid register */
- if ((first_regno == PPC_MQ_REGNUM) ||
- ((first_regno >= FP0_REGNUM) && (first_regno <= FPLAST_REGNUM)))
+ if ((first_regno == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
+ || ((first_regno >= FP0_REGNUM) && (first_regno <= FPLAST_REGNUM)))
{
/* printf("invalid reg request!\n"); */
supply_register (first_regno, NULL);
/* only attempt to write if it's a valid ppc 8xx register */
/* (need to avoid FP regs and MQ reg) */
- if ((i != PPC_MQ_REGNUM) && ((i < FP0_REGNUM) || (i > FPLAST_REGNUM)))
+ if ((i != gdbarch_tdep (current_gdbarch)->ppc_mq_regnum) && ((i < FP0_REGNUM) || (i > FPLAST_REGNUM)))
{
/* printf("write valid reg %d\n", bdm_regno); */
ocd_write_bdm_registers (bdm_regno, registers + REGISTER_BYTE (i), 4);
}
/*
- else if (i == PPC_MQ_REGNUM)
+ else if (i == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
printf("don't write invalid reg %d (PPC_MQ_REGNUM)\n", bdm_regno);
else
printf("don't write invalid reg %d\n", bdm_regno);
int u_addr = -1;
/* General purpose registers occupy 1 slot each in the buffer */
- if (regno >= PPC_GP0_REGNUM && regno <= PPC_GPLAST_REGNUM )
+ if (regno >= gdbarch_tdep (current_gdbarch)->ppc_gp0_regnum
+ && regno <= gdbarch_tdep (current_gdbarch)->ppc_gplast_regnum )
u_addr = (ustart + (PT_R0 + regno) * 4);
/* Floating point regs: 2 slots each */
/* UISA special purpose registers: 1 slot each */
if (regno == PC_REGNUM)
u_addr = ustart + PT_NIP * 4;
- if (regno == PPC_LR_REGNUM)
+ if (regno == gdbarch_tdep (current_gdbarch)->ppc_lr_regnum)
u_addr = ustart + PT_LNK * 4;
- if (regno == PPC_CR_REGNUM)
+ if (regno == gdbarch_tdep (current_gdbarch)->ppc_cr_regnum)
u_addr = ustart + PT_CCR * 4;
- if (regno == PPC_XER_REGNUM)
+ if (regno == gdbarch_tdep (current_gdbarch)->ppc_xer_regnum)
u_addr = ustart + PT_XER * 4;
- if (regno == PPC_CTR_REGNUM)
+ if (regno == gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum)
u_addr = ustart + PT_CTR * 4;
- if (regno == PPC_MQ_REGNUM)
+ if (regno == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
u_addr = ustart + PT_MQ * 4;
- if (regno == PPC_PS_REGNUM)
+ if (regno == gdbarch_tdep (current_gdbarch)->ppc_ps_regnum)
u_addr = ustart + PT_MSR * 4;
return u_addr;
supply_register (regi, (char *) (regp + regi));
supply_register (PC_REGNUM, (char *) (regp + PT_NIP));
- supply_register (PPC_LR_REGNUM, (char *) (regp + PT_LNK));
- supply_register (PPC_CR_REGNUM, (char *) (regp + PT_CCR));
- supply_register (PPC_XER_REGNUM, (char *) (regp + PT_XER));
- supply_register (PPC_CTR_REGNUM, (char *) (regp + PT_CTR));
- supply_register (PPC_MQ_REGNUM, (char *) (regp + PT_MQ));
- supply_register (PPC_PS_REGNUM, (char *) (regp + PT_MSR));
+ supply_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum,
+ (char *) (regp + PT_LNK));
+ supply_register (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum,
+ (char *) (regp + PT_CCR));
+ supply_register (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum,
+ (char *) (regp + PT_XER));
+ supply_register (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum,
+ (char *) (regp + PT_CTR));
+ supply_register (gdbarch_tdep (current_gdbarch)->ppc_mq_regnum,
+ (char *) (regp + PT_MQ));
+ supply_register (gdbarch_tdep (current_gdbarch)->ppc_ps_regnum,
+ (char *) (regp + PT_MSR));
+
}
void
if ((regno == -1) || regno == PC_REGNUM)
regcache_collect (PC_REGNUM, regp + PT_NIP);
- if ((regno == -1) || regno == PPC_LR_REGNUM)
- regcache_collect (PPC_LR_REGNUM, regp + PT_LNK);
- if ((regno == -1) || regno == PPC_CR_REGNUM)
- regcache_collect (PPC_CR_REGNUM, regp + PT_CCR);
- if ((regno == -1) || regno == PPC_XER_REGNUM)
- regcache_collect (PPC_XER_REGNUM, regp + PT_XER);
- if ((regno == -1) || regno == PPC_CTR_REGNUM)
- regcache_collect (PPC_CTR_REGNUM, regp + PT_CTR);
- if ((regno == -1) || regno == PPC_MQ_REGNUM)
- regcache_collect (PPC_MQ_REGNUM, regp + PT_MQ);
- if ((regno == -1) || regno == PPC_PS_REGNUM)
- regcache_collect (PPC_PS_REGNUM, regp + PT_MSR);
+ if ((regno == -1)
+ || regno == gdbarch_tdep (current_gdbarch)->ppc_lr_regnum)
+ regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum,
+ regp + PT_LNK);
+ if ((regno == -1)
+ || regno == gdbarch_tdep (current_gdbarch)->ppc_cr_regnum)
+ regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum,
+ regp + PT_CCR);
+ if ((regno == -1)
+ || regno == gdbarch_tdep (current_gdbarch)->ppc_xer_regnum)
+ regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum,
+ regp + PT_XER);
+ if ((regno == -1)
+ || regno == gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum)
+ regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum,
+ regp + PT_CTR);
+ if ((regno == -1)
+ || regno == gdbarch_tdep (current_gdbarch)->ppc_mq_regnum)
+ regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_mq_regnum,
+ regp + PT_MQ);
+ if ((regno == -1)
+ || regno == gdbarch_tdep (current_gdbarch)->ppc_ps_regnum)
+ regcache_collect (gdbarch_tdep (current_gdbarch)->ppc_ps_regnum,
+ regp + PT_MSR);
}
void
char buf[4];
CORE_ADDR handler;
- lr = read_register (PPC_LR_REGNUM);
+ lr = read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
if (!ppc_linux_at_sigtramp_return_path (lr))
return 0;
regs_addr =
read_memory_integer (fi->frame + PPC_LINUX_REGS_PTR_OFFSET, 4);
fi->saved_regs[PC_REGNUM] = regs_addr + 4 * PPC_LINUX_PT_NIP;
- fi->saved_regs[PPC_PS_REGNUM] = regs_addr + 4 * PPC_LINUX_PT_MSR;
- fi->saved_regs[PPC_CR_REGNUM] = regs_addr + 4 * PPC_LINUX_PT_CCR;
- fi->saved_regs[PPC_LR_REGNUM] = regs_addr + 4 * PPC_LINUX_PT_LNK;
- fi->saved_regs[PPC_CTR_REGNUM] = regs_addr + 4 * PPC_LINUX_PT_CTR;
- fi->saved_regs[PPC_XER_REGNUM] = regs_addr + 4 * PPC_LINUX_PT_XER;
- fi->saved_regs[PPC_MQ_REGNUM] = regs_addr + 4 * PPC_LINUX_PT_MQ;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_ps_regnum] =
+ regs_addr + 4 * PPC_LINUX_PT_MSR;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_cr_regnum] =
+ regs_addr + 4 * PPC_LINUX_PT_CCR;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_lr_regnum] =
+ regs_addr + 4 * PPC_LINUX_PT_LNK;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum] =
+ regs_addr + 4 * PPC_LINUX_PT_CTR;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_xer_regnum] =
+ regs_addr + 4 * PPC_LINUX_PT_XER;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_mq_regnum] =
+ regs_addr + 4 * PPC_LINUX_PT_MQ;
for (i = 0; i < 32; i++)
- fi->saved_regs[PPC_GP0_REGNUM + i] = regs_addr + 4 * PPC_LINUX_PT_R0 + 4 * i;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_gp0_regnum + i] =
+ regs_addr + 4 * PPC_LINUX_PT_R0 + 4 * i;
for (i = 0; i < 32; i++)
fi->saved_regs[FP0_REGNUM + i] = regs_addr + 4 * PPC_LINUX_PT_FPR0 + 8 * i;
}
void rs6000_frame_init_saved_regs (struct frame_info *);
CORE_ADDR rs6000_frame_chain (struct frame_info *);
-/* Some important register numbers. */
-
-#define PPC_GP0_REGNUM 0 /* GPR register 0 */
-#define PPC_GPLAST_REGNUM 31 /* GPR register 31 */
-#define PPC_TOC_REGNUM 2 /* TOC register */
-#define PPC_PS_REGNUM 65 /* Processor (or machine) status (%msr) */
-#define PPC_CR_REGNUM 66 /* Condition register */
-#define PPC_LR_REGNUM 67 /* Link register */
-#define PPC_CTR_REGNUM 68 /* Count register */
-#define PPC_XER_REGNUM 69 /* Integer exception register */
-#define PPC_MQ_REGNUM 70 /* Multiply/Divide extension register */
+/* Private data that this module attaches to struct gdbarch. */
+
+struct gdbarch_tdep
+ {
+ int wordsize; /* size in bytes of fixed-point word */
+ int osabi; /* OS / ABI from ELF header */
+ int *regoff; /* byte offsets in register arrays */
+ const struct reg *regs; /* from current variant */
+ int ppc_gp0_regnum; /* GPR register 0 */
+ int ppc_gplast_regnum; /* GPR register 31 */
+ int ppc_toc_regnum; /* TOC register */
+ int ppc_ps_regnum; /* Processor (or machine) status (%msr) */
+ int ppc_cr_regnum; /* Condition register */
+ int ppc_lr_regnum; /* Link register */
+ int ppc_ctr_regnum; /* Count register */
+ int ppc_xer_regnum; /* Integer exception register */
+ int ppc_mq_regnum; /* Multiply/Divide extension register */
+};
#endif
(PTRACE_ARG3_TYPE) & inferior_registers, 0);
for (i = 0; i < 32; i++)
RF (i, inferior_registers.fixreg[i]);
- RF (PPC_LR_REGNUM, inferior_registers.lr);
- RF (PPC_CR_REGNUM, inferior_registers.cr);
- RF (PPC_XER_REGNUM, inferior_registers.xer);
- RF (PPC_CTR_REGNUM, inferior_registers.ctr);
+ RF (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum, inferior_registers.lr);
+ RF (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum, inferior_registers.cr);
+ RF (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum, inferior_registers.xer);
+ RF (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum, inferior_registers.ctr);
RF (PC_REGNUM, inferior_registers.pc);
#ifdef PT_GETFPREGS
for (i = 0; i < 32; i++)
RS (i, inferior_registers.fixreg[i]);
- RS (PPC_LR_REGNUM, inferior_registers.lr);
- RS (PPC_CR_REGNUM, inferior_registers.cr);
- RS (PPC_XER_REGNUM, inferior_registers.xer);
- RS (PPC_CTR_REGNUM, inferior_registers.ctr);
+ RS (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum, inferior_registers.lr);
+ RS (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum, inferior_registers.cr);
+ RS (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum, inferior_registers.xer);
+ RS (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum, inferior_registers.ctr);
RS (PC_REGNUM, inferior_registers.pc);
ptrace (PT_SETREGS, PIDGET (inferior_ptid),
/* Integer registers */
for (i = 0; i < 32; i++)
RF (i, core_reg->intreg.fixreg[i]);
- RF (PPC_LR_REGNUM, core_reg->intreg.lr);
- RF (PPC_CR_REGNUM, core_reg->intreg.cr);
- RF (PPC_XER_REGNUM, core_reg->intreg.xer);
- RF (PPC_CTR_REGNUM, core_reg->intreg.ctr);
+ RF (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum, core_reg->intreg.lr);
+ RF (gdbarch_tdep (current_gdbarch)->ppc_cr_regnum, core_reg->intreg.cr);
+ RF (gdbarch_tdep (current_gdbarch)->ppc_xer_regnum, core_reg->intreg.xer);
+ RF (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum, core_reg->intreg.ctr);
RF (PC_REGNUM, core_reg->intreg.pc);
#ifdef PT_FPGETREGS
unsigned char fpr; /* whether register is floating-point */
};
-/* Private data that this module attaches to struct gdbarch. */
-
-struct gdbarch_tdep
- {
- int wordsize; /* size in bytes of fixed-point word */
- int osabi; /* OS / ABI from ELF header */
- int *regoff; /* byte offsets in register arrays */
- const struct reg *regs; /* from current variant */
- };
-
/* Return the current architecture's gdbarch_tdep structure. */
#define TDEP gdbarch_tdep (current_gdbarch)
static CORE_ADDR
rs6000_saved_pc_after_call (struct frame_info *fi)
{
- return read_register (PPC_LR_REGNUM);
+ return read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
}
/* Calculate the destination of a branch/jump. Return -1 if not a branch. */
if (ext_op == 16) /* br conditional register */
{
- dest = read_register (PPC_LR_REGNUM) & ~3;
+ dest = read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum) & ~3;
/* If we are about to return from a signal handler, dest is
something like 0x3c90. The current frame is a signal handler
else if (ext_op == 528) /* br cond to count reg */
{
- dest = read_register (PPC_CTR_REGNUM) & ~3;
+ dest = read_register (gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum) & ~3;
/* If we are about to execute a system call, dest is something
like 0x22fc or 0x3b00. Upon completion the system call
will return to the address in the link register. */
if (dest < TEXT_SEGMENT_BASE)
- dest = read_register (PPC_LR_REGNUM) & ~3;
+ dest = read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum) & ~3;
}
else
return -1;
else
prev_sp = read_memory_addr (sp, wordsize);
if (fdata.lr_offset == 0)
- lr = read_register (PPC_LR_REGNUM);
+ lr = read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
else
lr = read_memory_addr (prev_sp + fdata.lr_offset, wordsize);
if (rs6000_find_toc_address_hook != NULL)
{
CORE_ADDR tocvalue = (*rs6000_find_toc_address_hook) (fun);
- write_register (PPC_TOC_REGNUM, tocvalue);
+ write_register (gdbarch_tdep (current_gdbarch)->ppc_toc_regnum,
+ tocvalue);
}
}
static CORE_ADDR
ppc_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
{
- write_register (PPC_LR_REGNUM, CALL_DUMMY_ADDRESS ());
+ write_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum,
+ CALL_DUMMY_ADDRESS ());
return sp;
}
}
if (fdata.lr_offset == 0)
- return read_register (PPC_LR_REGNUM);
+ return read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
return read_memory_addr (FRAME_CHAIN (fi) + fdata.lr_offset, wordsize);
}
/* If != 0, fdatap->cr_offset is the offset from the frame that holds
the CR. */
if (fdatap->cr_offset != 0)
- fi->saved_regs[PPC_CR_REGNUM] = frame_addr + fdatap->cr_offset;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_cr_regnum] =
+ frame_addr + fdatap->cr_offset;
/* If != 0, fdatap->lr_offset is the offset from the frame that holds
the LR. */
if (fdatap->lr_offset != 0)
- fi->saved_regs[PPC_LR_REGNUM] = frame_addr + fdatap->lr_offset;
+ fi->saved_regs[gdbarch_tdep (current_gdbarch)->ppc_lr_regnum] =
+ frame_addr + fdatap->lr_offset;
}
/* Return the address of a frame. This is the inital %sp value when the frame
else
fp = read_memory_addr ((thisframe)->frame, wordsize);
- lr = read_register (PPC_LR_REGNUM);
+ lr = read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
if (lr == entry_point_address ())
if (fp != 0 && (fpp = read_memory_addr (fp, wordsize)) != 0)
if (PC_IN_CALL_DUMMY (lr, fpp, fpp))
memcpy (to, from, REGISTER_RAW_SIZE (n));
}
+/* Convert a dbx stab register number (from `r' declaration) to a gdb
+ REGNUM. */
+static int
+rs6000_stab_reg_to_regnum (int num)
+{
+ int regnum;
+ switch (num)
+ {
+ case 64:
+ regnum = gdbarch_tdep (current_gdbarch)->ppc_mq_regnum;
+ break;
+ case 65:
+ regnum = gdbarch_tdep (current_gdbarch)->ppc_lr_regnum;
+ break;
+ case 66:
+ regnum = gdbarch_tdep (current_gdbarch)->ppc_ctr_regnum;
+ break;
+ case 76:
+ regnum = gdbarch_tdep (current_gdbarch)->ppc_xer_regnum;
+ break;
+ default:
+ regnum = num;
+ break;
+ }
+ return regnum;
+}
+
/* Store the address of the place in which to copy the structure the
subroutine will return. This is called from call_function.
TYPE_LENGTH (type));
else
/* Everything else is returned in GPR3 and up. */
- write_register_bytes (REGISTER_BYTE (PPC_GP0_REGNUM + 3), valbuf,
- TYPE_LENGTH (type));
+ write_register_bytes (REGISTER_BYTE (gdbarch_tdep (current_gdbarch)->ppc_gp0_regnum + 3),
+ valbuf, TYPE_LENGTH (type));
}
/* Extract from an array REGBUF containing the (raw) register state
v = find_variant_by_name (power ? "power" : "powerpc");
tdep->regs = v->regs;
+ tdep->ppc_gp0_regnum = 0;
+ tdep->ppc_gplast_regnum = 31;
+ tdep->ppc_toc_regnum = 2;
+ tdep->ppc_ps_regnum = 65;
+ tdep->ppc_cr_regnum = 66;
+ tdep->ppc_lr_regnum = 67;
+ tdep->ppc_ctr_regnum = 68;
+ tdep->ppc_xer_regnum = 69;
+ if (v->mach == bfd_mach_ppc_601)
+ tdep->ppc_mq_regnum = 124;
+ else
+ tdep->ppc_mq_regnum = 70;
+
/* Calculate byte offsets in raw register array. */
tdep->regoff = xmalloc (v->nregs * sizeof (int));
for (i = off = 0; i < v->nregs; i++)
set_gdbarch_register_convertible (gdbarch, rs6000_register_convertible);
set_gdbarch_register_convert_to_virtual (gdbarch, rs6000_register_convert_to_virtual);
set_gdbarch_register_convert_to_raw (gdbarch, rs6000_register_convert_to_raw);
+ set_gdbarch_stab_reg_to_regnum (gdbarch, rs6000_stab_reg_to_regnum);
set_gdbarch_extract_return_value (gdbarch, rs6000_extract_return_value);