diff options
-rw-r--r-- | gdb/ChangeLog | 24 | ||||
-rw-r--r-- | gdb/config/rs6000/tm-rs6000.h | 4 | ||||
-rw-r--r-- | gdb/ppc-bdm.c | 8 | ||||
-rw-r--r-- | gdb/ppc-linux-nat.c | 70 | ||||
-rw-r--r-- | gdb/ppc-linux-tdep.c | 23 | ||||
-rw-r--r-- | gdb/ppc-tdep.h | 29 | ||||
-rw-r--r-- | gdb/ppcnbsd-nat.c | 24 | ||||
-rw-r--r-- | gdb/rs6000-tdep.c | 81 |
8 files changed, 176 insertions, 87 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c055333..e226ad8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,27 @@ +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 diff --git a/gdb/config/rs6000/tm-rs6000.h b/gdb/config/rs6000/tm-rs6000.h index 96eb163..efd96e5 100644 --- a/gdb/config/rs6000/tm-rs6000.h +++ b/gdb/config/rs6000/tm-rs6000.h @@ -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) \ diff --git a/gdb/ppc-bdm.c b/gdb/ppc-bdm.c index 4468caa..b2287ea 100644 --- a/gdb/ppc-bdm.c +++ b/gdb/ppc-bdm.c @@ -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); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 5701476..1d57a9a 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -62,7 +62,8 @@ ppc_register_u_addr (int ustart, int 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 */ @@ -72,17 +73,17 @@ ppc_register_u_addr (int ustart, int regno) /* 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, int regno) 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 diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index fb60385..5c1fa28 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -156,7 +156,7 @@ ppc_linux_in_sigtramp (CORE_ADDR pc, char *func_name) 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 frame_info *fi) 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; } diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h index 9ed1567..8745cb0 100644 --- a/gdb/ppc-tdep.h +++ b/gdb/ppc-tdep.h @@ -44,16 +44,23 @@ int rs6000_frameless_function_invocation (struct frame_info *); 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 diff --git a/gdb/ppcnbsd-nat.c b/gdb/ppcnbsd-nat.c index b206110..55acf95 100644 --- a/gdb/ppcnbsd-nat.c +++ b/gdb/ppcnbsd-nat.c @@ -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_sect, unsigned core_reg_size, int which, /* 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 diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 4450070..2d86bfc 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -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_info *fi) 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_ADDR pc, CORE_ADDR safety) 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_ADDR pc, CORE_ADDR safety) 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, CORE_ADDR pc, CORE_ADDR fun, 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 *fi) } 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 *fi, struct rs6000_framedata *fdatap) /* 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 *thisframe) 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 type *type, int n, 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, char *valbuf) 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 info, struct gdbarch_list *arches) 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 info, struct gdbarch_list *arches) 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); |