* [RFA] ppc: include register numbers in gdbarch_tdep structure.
@ 2001-12-09 11:58 Elena Zannoni
2001-12-09 13:24 ` Kevin Buettner
2001-12-10 11:33 ` Michael Snyder
0 siblings, 2 replies; 10+ messages in thread
From: Elena Zannoni @ 2001-12-09 11:58 UTC (permalink / raw)
To: gdb-patches
This is a new patch for
http://sources.redhat.com/ml/gdb-patches/2001-12/msg00160.html
Tested on aix4.3, solaris-x-powerpc-eabi, ppcnbsd, ppclinux.
Elena
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.
Index: ppc-bdm.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-bdm.c,v
retrieving revision 1.11
diff -u -p -r1.11 ppc-bdm.c
--- ppc-bdm.c 2001/05/04 04:15:26 1.11
+++ ppc-bdm.c 2001/12/09 19:55:12
@@ -200,8 +200,8 @@ bdm_ppc_fetch_registers (int regno)
/* 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);
@@ -289,13 +289,13 @@ bdm_ppc_store_registers (int regno)
/* 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);
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.11
diff -u -p -r1.11 ppc-linux-nat.c
--- ppc-linux-nat.c 2001/11/30 02:14:08 1.11
+++ ppc-linux-nat.c 2001/12/09 19:55:12
@@ -62,7 +62,8 @@ ppc_register_u_addr (int ustart, int reg
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 */
@@ -72,17 +73,17 @@ ppc_register_u_addr (int ustart, int reg
/* 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;
@@ -98,12 +99,19 @@ supply_gregset (gdb_gregset_t *gregsetp)
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
@@ -120,18 +128,30 @@ fill_gregset (gdb_gregset_t *gregsetp, i
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
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.11
diff -u -p -r1.11 ppc-linux-tdep.c
--- ppc-linux-tdep.c 2001/12/01 00:23:37 1.11
+++ ppc-linux-tdep.c 2001/12/09 19:55:13
@@ -156,7 +156,7 @@ ppc_linux_in_sigtramp (CORE_ADDR pc, cha
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;
@@ -378,14 +378,21 @@ ppc_linux_frame_init_saved_regs (struct
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;
}
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.4
diff -u -p -r1.4 ppc-tdep.h
--- ppc-tdep.h 2001/12/01 00:23:37 1.4
+++ ppc-tdep.h 2001/12/09 19:55:14
@@ -44,16 +44,23 @@ int rs6000_frameless_function_invocation
void rs6000_frame_init_saved_regs (struct frame_info *);
CORE_ADDR rs6000_frame_chain (struct frame_info *);
-/* Some important register numbers. */
+/* Private data that this module attaches to struct gdbarch. */
-#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 */
+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
Index: ppcnbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppcnbsd-nat.c,v
retrieving revision 1.7
diff -u -p -r1.7 ppcnbsd-nat.c
--- ppcnbsd-nat.c 2001/05/04 04:15:26 1.7
+++ ppcnbsd-nat.c 2001/12/09 19:55:14
@@ -49,10 +49,10 @@ fetch_inferior_registers (int regno)
(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
@@ -76,10 +76,10 @@ store_inferior_registers (int regno)
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),
@@ -111,10 +111,10 @@ fetch_core_registers (char *core_reg_sec
/* 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
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.29
diff -u -p -r1.29 rs6000-tdep.c
--- rs6000-tdep.c 2001/12/01 00:23:37 1.29
+++ rs6000-tdep.c 2001/12/09 19:55:16
@@ -82,16 +82,6 @@ struct reg
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)
@@ -205,7 +195,7 @@ rs6000_frame_args_address (struct frame_
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. */
@@ -243,7 +233,7 @@ branch_dest (int opcode, int instr, CORE
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
@@ -262,13 +252,13 @@ branch_dest (int opcode, int instr, CORE
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;
@@ -809,7 +799,7 @@ rs6000_pop_frame (void)
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);
@@ -860,7 +850,8 @@ rs6000_fix_call_dummy (char *dummyname,
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);
}
}
@@ -1083,7 +1074,8 @@ ran_out_of_registers_for_arguments:
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;
}
@@ -1297,7 +1289,7 @@ rs6000_frame_saved_pc (struct frame_info
}
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);
}
@@ -1368,12 +1360,14 @@ frame_get_saved_regs (struct frame_info
/* 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
@@ -1483,7 +1477,7 @@ rs6000_frame_chain (struct frame_info *t
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))
@@ -1614,6 +1608,33 @@ rs6000_register_convert_to_raw (struct t
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.
@@ -1645,8 +1666,8 @@ rs6000_store_return_value (struct type *
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
@@ -2236,6 +2257,19 @@ rs6000_gdbarch_init (struct gdbarch_info
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++)
@@ -2295,6 +2329,7 @@ rs6000_gdbarch_init (struct gdbarch_info
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);
Index: config/rs6000/tm-rs6000.h
===================================================================
RCS file: /cvs/src/src/gdb/config/rs6000/tm-rs6000.h,v
retrieving revision 1.13
diff -u -p -r1.13 tm-rs6000.h
--- tm-rs6000.h 2001/05/01 19:36:11 1.13
+++ tm-rs6000.h 2001/12/09 19:55:17
@@ -86,10 +86,6 @@ extern void aix_process_linenos (void);
#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) \
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-09 11:58 [RFA] ppc: include register numbers in gdbarch_tdep structure Elena Zannoni
@ 2001-12-09 13:24 ` Kevin Buettner
2001-12-09 13:38 ` Elena Zannoni
2001-12-09 15:09 ` Andrew Cagney
2001-12-10 11:33 ` Michael Snyder
1 sibling, 2 replies; 10+ messages in thread
From: Kevin Buettner @ 2001-12-09 13:24 UTC (permalink / raw)
To: Elena Zannoni, gdb-patches
On Dec 9, 3:04pm, Elena Zannoni wrote:
> This is a new patch for
>
> http://sources.redhat.com/ml/gdb-patches/2001-12/msg00160.html
>
> Tested on aix4.3, solaris-x-powerpc-eabi, ppcnbsd, ppclinux.
>
> Elena
>
> 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.
Approved.
Though I do wonder if it was really necessary to move register
numbers which are truly constant to the gdbarch_tdep struct. BTW,
this wouldn't bother me so much if we could use inline functions
in C.
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-09 13:24 ` Kevin Buettner
@ 2001-12-09 13:38 ` Elena Zannoni
2001-12-09 15:09 ` Andrew Cagney
1 sibling, 0 replies; 10+ messages in thread
From: Elena Zannoni @ 2001-12-09 13:38 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
Kevin Buettner writes:
> On Dec 9, 3:04pm, Elena Zannoni wrote:
>
> > This is a new patch for
> >
> > http://sources.redhat.com/ml/gdb-patches/2001-12/msg00160.html
> >
> > Tested on aix4.3, solaris-x-powerpc-eabi, ppcnbsd, ppclinux.
> >
> > Elena
> >
> > 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.
>
> Approved.
>
> Though I do wonder if it was really necessary to move register
> numbers which are truly constant to the gdbarch_tdep struct. BTW,
> this wouldn't bother me so much if we could use inline functions
> in C.
>
> Kevin
Thanks Kevin!
Committed.
The reason for moving the regnums to the tdep structure is that they
are all in one place. It seems cleaner to have defintions like these
be localized. I also found that in case of another processor, newer
revisions moved the regs around a bit, so I had to multiarch them
anyway. It seems like the ppc is a bit more stable in this regard
though.
Elena
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-09 13:24 ` Kevin Buettner
2001-12-09 13:38 ` Elena Zannoni
@ 2001-12-09 15:09 ` Andrew Cagney
2001-12-12 12:16 ` Mark Kettenis
1 sibling, 1 reply; 10+ messages in thread
From: Andrew Cagney @ 2001-12-09 15:09 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, gdb-patches
> Though I do wonder if it was really necessary to move register
> numbers which are truly constant to the gdbarch_tdep struct. BTW,
> this wouldn't bother me so much if we could use inline functions
> in C.
Based on the pains I'm experiencing with going through trying to get
some MMX changes for x86 in a state where I can submit them, I suspect
it is the better of the alternatives.
The x86 has a mix and that is just confusing. I don't know what can
change and what can't change and what secret relationships there are
between the constants and variables.
On paper, it should be possible to describe the entire raw regcache
using constants. I'm finding that, in reality, until all the relevant
framework is fleshed out (eg my regcache breakage, everything
multi-arch) it isn't really possible. Sigh.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-09 15:09 ` Andrew Cagney
@ 2001-12-12 12:16 ` Mark Kettenis
0 siblings, 0 replies; 10+ messages in thread
From: Mark Kettenis @ 2001-12-12 12:16 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Kevin Buettner, Elena Zannoni, gdb-patches
Andrew Cagney <ac131313@cygnus.com> writes:
> Based on the pains I'm experiencing with going through trying to get
> some MMX changes for x86 in a state where I can submit them, I suspect
> it is the better of the alternatives.
>
> The x86 has a mix and that is just confusing. I don't know what can
> change and what can't change and what secret relationships there are
> between the constants and variables.
I'm working on that. Unfortunately I have to improve the
documentation a bit.
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-09 11:58 [RFA] ppc: include register numbers in gdbarch_tdep structure Elena Zannoni
2001-12-09 13:24 ` Kevin Buettner
@ 2001-12-10 11:33 ` Michael Snyder
2001-12-10 12:25 ` Kevin Buettner
1 sibling, 1 reply; 10+ messages in thread
From: Michael Snyder @ 2001-12-10 11:33 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches
Elena Zannoni wrote:
> +++ ppc-bdm.c 2001/12/09 19:55:12
> @@ -200,8 +200,8 @@ bdm_ppc_fetch_registers (int regno)
> /* 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)))
[and many similar changes]
Not to be nit-picky, and I realize it's already been approved and
committed,
but wouldn't this code look prettier if we simply provided something
like:
#define PPC_MQ_REGNUM gdbarch_tdep (current_gdbarch)->ppc_mq_regnum
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-10 11:33 ` Michael Snyder
@ 2001-12-10 12:25 ` Kevin Buettner
2001-12-10 12:41 ` Elena Zannoni
0 siblings, 1 reply; 10+ messages in thread
From: Kevin Buettner @ 2001-12-10 12:25 UTC (permalink / raw)
To: Michael Snyder, Elena Zannoni; +Cc: gdb-patches
On Dec 10, 11:30am, Michael Snyder wrote:
> Elena Zannoni wrote:
>
> > +++ ppc-bdm.c 2001/12/09 19:55:12
> > @@ -200,8 +200,8 @@ bdm_ppc_fetch_registers (int regno)
> > /* 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)))
>
> [and many similar changes]
>
> Not to be nit-picky, and I realize it's already been approved and
> committed,
> but wouldn't this code look prettier if we simply provided something
> like:
>
> #define PPC_MQ_REGNUM gdbarch_tdep (current_gdbarch)->ppc_mq_regnum
As with most things we do there are pros and cons. On the pro side, I
agree that it looks prettier and is easier to read. Also, having
these defines makes it easier to convert the code back to using actual
constants some day. These are both excellent reasons to do as Michael
suggests.
The drawback to using a macro like this is that it hides what's really
going on. (But note that it is this very same quality that enhances
readability.) In this case, the macro looks like a constant, leading
to the expectation that it is a constant and has the usual costs
associated with constants. However, the runtime costs associated with
using this expression are significantly greater than using a constant.
That said, those of us accustomed to working on GDB are used to this
by now, aren't we? E.g, consider:
for (regno = 0; regno < NUM_REGS; regno++)
...
We all realize that a function is being called each time the test
``regno < NUM_REGS'' is performed, don't we?
If so, then I'm all in favor of Michael's suggestion. (Actually, I'm
in favor of Michael's suggestion anyway. But, I do think we need to
be more careful about how we write code that might potentially contain
a hidden function call.)
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-10 12:25 ` Kevin Buettner
@ 2001-12-10 12:41 ` Elena Zannoni
2001-12-10 13:22 ` Kevin Buettner
0 siblings, 1 reply; 10+ messages in thread
From: Elena Zannoni @ 2001-12-10 12:41 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Michael Snyder, Elena Zannoni, gdb-patches
Kevin Buettner writes:
> On Dec 10, 11:30am, Michael Snyder wrote:
>
> > Elena Zannoni wrote:
> >
> > > +++ ppc-bdm.c 2001/12/09 19:55:12
> > > @@ -200,8 +200,8 @@ bdm_ppc_fetch_registers (int regno)
> > > /* 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)))
> >
> > [and many similar changes]
> >
> > Not to be nit-picky, and I realize it's already been approved and
> > committed,
> > but wouldn't this code look prettier if we simply provided something
> > like:
> >
> > #define PPC_MQ_REGNUM gdbarch_tdep (current_gdbarch)->ppc_mq_regnum
>
> As with most things we do there are pros and cons. On the pro side, I
> agree that it looks prettier and is easier to read. Also, having
> these defines makes it easier to convert the code back to using actual
> constants some day. These are both excellent reasons to do as Michael
> suggests.
>
Why would you want to convert the code back? Anyway, I find it also
easier to debug the code, if you don't have a macro.
> The drawback to using a macro like this is that it hides what's really
> going on. (But note that it is this very same quality that enhances
> readability.) In this case, the macro looks like a constant, leading
> to the expectation that it is a constant and has the usual costs
> associated with constants. However, the runtime costs associated with
> using this expression are significantly greater than using a constant.
>
But having a macro defined to be the same function call is not going
to speed up the evaluation.
> That said, those of us accustomed to working on GDB are used to this
> by now, aren't we? E.g, consider:
>
> for (regno = 0; regno < NUM_REGS; regno++)
> ...
>
> We all realize that a function is being called each time the test
> ``regno < NUM_REGS'' is performed, don't we?
Sometimes, doing something because it was done in the past is not a
good metric. I think multiarch was developed leaving the macros
because it was a necessary thing to both minimize changes and keep
compatibility with non-multiarched targets. But here I would argue it
is a different situation.
>
> If so, then I'm all in favor of Michael's suggestion. (Actually, I'm
> in favor of Michael's suggestion anyway. But, I do think we need to
> be more careful about how we write code that might potentially contain
> a hidden function call.)
>
Sorry, I disagree.
> Kevin
Elena
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-10 12:41 ` Elena Zannoni
@ 2001-12-10 13:22 ` Kevin Buettner
2001-12-10 14:34 ` Andrew Cagney
0 siblings, 1 reply; 10+ messages in thread
From: Kevin Buettner @ 2001-12-10 13:22 UTC (permalink / raw)
To: Elena Zannoni, Kevin Buettner; +Cc: Michael Snyder, gdb-patches
On Dec 10, 3:47pm, Elena Zannoni wrote:
> Subject: Re: [RFA] ppc: include register numbers in gdbarch_tdep structure
> > > #define PPC_MQ_REGNUM gdbarch_tdep (current_gdbarch)->ppc_mq_regnum
> >
> > As with most things we do there are pros and cons. On the pro side, I
> > agree that it looks prettier and is easier to read. Also, having
> > these defines makes it easier to convert the code back to using actual
> > constants some day. These are both excellent reasons to do as Michael
> > suggests.
>
> Why would you want to convert the code back?
Andrew recently said the following:
On paper, it should be possible to describe the entire raw regcache
using constants. I'm finding that, in reality, until all the relevant
framework is fleshed out (eg my regcache breakage, everything
multi-arch) it isn't really possible. Sigh.
This suggests to me that someday, though probably not very soon, it
may indeed be possible to use actual constants. As you can probably
tell, I really, really hate the overhead of a function call to provide
the value of something that ought to be a constant.
> Anyway, I find it also
> easier to debug the code, if you don't have a macro.
So do I. Perhaps someday GDB will have support for macros.
> > The drawback to using a macro like this is that it hides what's really
> > going on. (But note that it is this very same quality that enhances
> > readability.) In this case, the macro looks like a constant, leading
> > to the expectation that it is a constant and has the usual costs
> > associated with constants. However, the runtime costs associated with
> > using this expression are significantly greater than using a constant.
> >
>
> But having a macro defined to be the same function call is not going
> to speed up the evaluation.
I wasn't claiming that it would. I was providing an argument against
the use of a macro. My argument is that the macro hides (in the sense
that you have to go look at the macro's definition) the fact that a
function is being called. I wasn't claiming that the macro eliminated
the function call.
> > That said, those of us accustomed to working on GDB are used to this
> > by now, aren't we? E.g, consider:
> >
> > for (regno = 0; regno < NUM_REGS; regno++)
> > ...
> >
> > We all realize that a function is being called each time the test
> > ``regno < NUM_REGS'' is performed, don't we?
>
> Sometimes, doing something because it was done in the past is not a
> good metric. I think multiarch was developed leaving the macros
> because it was a necessary thing to both minimize changes and keep
> compatibility with non-multiarched targets. But here I would argue it
> is a different situation.
I agree. But I wasn't citing NUM_REGS as a historical precedent.
Rather, I was noting that since we're all used to macros performing
function calls for us, that my argument against the use of the macro
wasn't a very strong one.
> > If so, then I'm all in favor of Michael's suggestion. (Actually, I'm
> > in favor of Michael's suggestion anyway. But, I do think we need to
> > be more careful about how we write code that might potentially contain
> > a hidden function call.)
>
> Sorry, I disagree.
That's okay. I don't plan to do anything about this one way or another
until there's been more discussion.
Kevin
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [RFA] ppc: include register numbers in gdbarch_tdep structure.
2001-12-10 13:22 ` Kevin Buettner
@ 2001-12-10 14:34 ` Andrew Cagney
0 siblings, 0 replies; 10+ messages in thread
From: Andrew Cagney @ 2001-12-10 14:34 UTC (permalink / raw)
To: Kevin Buettner; +Cc: Elena Zannoni, Michael Snyder, gdb-patches
>
> Andrew recently said the following:
>
> On paper, it should be possible to describe the entire raw regcache
> using constants. I'm finding that, in reality, until all the relevant
> framework is fleshed out (eg my regcache breakage, everything
> multi-arch) it isn't really possible. Sigh.
>
> This suggests to me that someday, though probably not very soon, it
> may indeed be possible to use actual constants. As you can probably
> tell, I really, really hate the overhead of a function call to provide
> the value of something that ought to be a constant.
Hmm, something else we're doing is moving away from the assumption that
there is a global current_gdbarch. Consequently the macro should be
parameterized vis:
#define PPC_MQ_REGNUM(ARCH) (gdbarch_tdep ((ARCH))->ppc_mq_regnum)
As for other alternatives, I used something like:
{
const struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
....
... tdep->ppc_mq_regnum ...
....
}
in remote.c. Still, I figure this is all small fish compared to the
possability of actually fixing GDB's thread and frame code so that more
than one instance was available and thus we dramatically cut down on the
number of system / remote calls - which are the real killer.
BTW, even if GDB did support macro's I'd still argue agains them - call
by name semantics for instance. They just sux.
enjoy,
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2001-12-12 20:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-09 11:58 [RFA] ppc: include register numbers in gdbarch_tdep structure Elena Zannoni
2001-12-09 13:24 ` Kevin Buettner
2001-12-09 13:38 ` Elena Zannoni
2001-12-09 15:09 ` Andrew Cagney
2001-12-12 12:16 ` Mark Kettenis
2001-12-10 11:33 ` Michael Snyder
2001-12-10 12:25 ` Kevin Buettner
2001-12-10 12:41 ` Elena Zannoni
2001-12-10 13:22 ` Kevin Buettner
2001-12-10 14:34 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox