diff options
55 files changed, 740 insertions, 409 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0ed2af062ca..ddb89ad3621 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,145 @@ +2007-06-18 Markus Deuling <deuling@de.ibm.com> + + * gdbarch.sh (SP_REGNUM): Replace by gdbarch_sp_regnum. + * v850-tdep.c (v850_unwind_sp): Likewise. + * std-regs.c (value_of_builtin_frame_sp_reg): Likewise. + * stack.c (frame_info): Likewise. + * stabsread.c (define_symbol): Likewise. + * sh-tdep.c (sh_push_dummy_call_fpu, sh_push_dummy_call_nofpu) + (sh_dwarf2_frame_init_reg, sh_frame_cache, sh_frame_prev_register) + (sh_unwind_sp): Likewise. + * sh64-tdep.c (sh64_push_dummy_call, sh64_frame_cache) + (sh64_frame_prev_register, sh64_unwind_sp): Likewise. + * rs6000-tdep.c (rs6000_push_dummy_call, rs6000_unwind_dummy_id) + (rs6000_frame_cache): Likewise. + * rs6000-nat.c (store_register): Likewise. + * remote-mips.c (mips_wait): Likewise. + * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. + * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call) + (ppc64_sysv_abi_push_dummy_call): Likewise. + * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. + * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. + * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. + * ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise. + * m32r-rom.c (m32r_supply_register): Likewise. + * frame.c (frame_sp_unwind): Likewise. + * mips-tdep.c (mips_insn16_frame_cache) + (mips_insn32_frame_cache): Likewise (comment). + * m68klinux-nat.c (supply_gregset): Likewise. + * m68k-tdep.c (m68k_get_longjmp_target): Likewise. + * ia64-tdep.c (ia64_frame_prev_register): Likewise. + * i386-tdep.c (i386_get_longjmp_target): Likewise. + * dwarf2-frame.c (dwarf2_frame_default_init_reg): Likewise. + * cris-tdep.c (cris_regnums, cris_sigcontext_addr) + (cris_sigtramp_frame_unwind_cache, cris_push_dummy_call) + (cris_scan_prologue, crisv32_scan_prologue, cris_unwind_sp) + (cris_register_type, crisv32_register_type) + (cris_dwarf2_frame_init_reg): Likewise. + * arch-utils.c (legacy_virtual_frame_pointer): Likewise. + * amd64-tdep.c (amd64_frame_prev_register): Likewise. + * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Likewise. + * libunwind-frame.c (libunwind_frame_cache): Likewise. + + * gdbarch.sh (PC_REGNUM): Replace by gdbarch_pc_regnum. + * regcache.c (read_pc_pid, generic_target_write_pc): Likewise. + * xtensa-tdep.c (xtensa_register_type, xtensa_supply_gregset) + (xtensa_unwind_pc, xtensa_frame_cache, xtensa_frame_prev_register) + (xtensa_extract_return_value, xtensa_store_return_value): Likewise. + * v850-tdep.c (v850_unwind_pc): Likewise. + * stack.c (frame_info): Likewise. + * sh-tdep.c (sh_generic_show_regs, sh3_show_regs, sh2e_show_regs) + (sh2a_show_regs, sh2a_nofpu_show_regs, sh3e_show_regs) + (sh3_dsp_show_regs, sh4_show_regs, sh4_nofpu_show_regs) + (sh_dwarf2_frame_init_reg, sh_frame_prev_register, sh_unwind_pc) + (sh_dsp_show_regs): Likewise. + * shnbsd-tdep.c (shnbsd_supply_gregset) + (shnbsd_collect_gregset): Likewise. + * shnbsd-nat.c (GETREGS_SUPPLIES): Likewise. + * sh64-tdep.c (sh64_compact_reg_base_num, sh64_show_media_regs) + (sh64_frame_prev_register, sh64_unwind_pc): Likewise. + * rs6000-tdep.c (ppc_supply_gregset, ppc_collect_gregset) + (6000_register_reggroup_p, rs6000_unwind_pc) + (rs6000_frame_cache): Likewise. + * rs6000-nat.c (regmap, rs6000_fetch_inferior_registers) + (rs6000_store_inferior_registers): Likewise. + * remote-mips.c (mips_wait, mips_load): Likewise. + * procfs.c (procfs_fetch_registers, procfs_store_registers): Likewise. + * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_cache): Likewise. + * ppcobsd-nat.c (ppcobsd_supply_pcb): Likewise. + * ppcnbsd-tdep.c (ppcnbsd_sigtramp_cache_init): Likewise. + * ppcnbsd-nat.c (getregs_supplies, ppcnbsd_supply_pcb): Likewise. + * ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise. + * ppc-linux-nat.c (ppc_register_u_addr, fetch_ppc_registers) + (store_ppc_registers, fill_gregset): Likewise. + * mips-tdep.c (mips_stub_frame_cache, mips_gdbarch_init): Likewise. + * mipsnbsd-tdep.c (mipsnbsd_supply_reg, mipsnbsd_fill_reg): Likewise. + * mipsnbsd-nat.c (getregs_supplies): Likewise. + * m68k-tdep.c (m68k_register_type, m68k_unwind_pc): Likewise. + * m68klinux-nat.c (supply_gregset): Likewise. + * irix5-nat.c (fill_gregset): Likewise. + * i386-tdep.c (i386_unwind_pc): Likewise. + * i386-linux-nat.c (i386_linux_resume): Likewise. + * frame.c (get_prev_frame_1): Likewise. + * dwarf2-frame.c (dwarf2_frame_default_init_reg): Likewise. + * dbug-rom.c (dbug_supply_register): Likewise. + * cris-tdep.c (cris_sigtramp_frame_unwind_cache, cris_scan_prologue) + (crisv32_scan_prologue, cris_unwind_pc, cris_register_size) + (cris_register_type, crisv32_register_type, crisv32_register_name) + (cris_dwarf2_frame_init_reg, find_step_target) + (cris_software_single_step, cris_supply_gregset) + (cris_regnums): Likewise. + * alpha-linux-nat.c (alpha_linux_register_u_offset): Likewise. + * aix-thread.c (special_register_p, supply_sprs64, supply_sprs32) + (fill_sprs64, fill_sprs32, store_regs_user_thread): Likewise. + * std-regs.c (value_of_builtin_frame_pc_reg): Likewise. + * mips-linux-tdep.c (mips_linux_write_pc): Likewise. + + * gdbarch.sh (PS_REGNUM): Replace by gdbarch_ps_regnum. + * dbug-rom.c (dbug_supply_register): Likewise. + * xtensa-tdep.c (xtensa_supply_gregset, xtensa_frame_cache) + (xtensa_frame_prev_register, xtensa_push_dummy_call): Likewise. + * win32-nat.c (win32_resume): Likewise. + * std-regs.c (value_of_builtin_frame_ps_reg): Likewise. + * m68k-tdep.c (m68k_register_type): Likewise. + * m68klinux-nat.c (supply_gregset): Likewise. + + * gdbarch.sh (FP0_REGNUM): Replace by gdbarch_fp0_regnum. + * sh-tdep.c (sh_extract_return_value_fpu, sh_store_return_value_fpu) + (sh2e_show_regs, sh2a_show_regs, sh3e_show_regs, sh4_show_regs) + (sh_sh2a_register_type, sh_sh3e_register_type, sh_sh4_register_type) + (fv_reg_base_num, dr_reg_base_num): Likewise. + * sh64-tdep.c (sh64_fv_reg_base_num, sh64_dr_reg_base_num) + (sh64_fpp_reg_base_num, sh64_compact_reg_base_num, sh64_push_dummy_call) + (sh64_extract_return_value, sh64_store_return_value) + (sh64_show_media_regs, sh64_show_compact_regs, sh64_register_type) + (sh64_do_fp_register, sh64_media_print_registers_info): Likewise. + * procfs.c (procfs_fetch_registers, procfs_store_registers) + (invalidate_cache): Likewise. + * ppc-linux-tdep.c (ppc_linux_sigtramp_cache): Likewise. + * mipsnbsd-tdep.c (mipsnbsd_supply_fpreg) + (mipsnbsd_fill_fpreg): Likewise. + * mipsnbsd-nat.c (mipsnbsd_fetch_inferior_registers) + (mipsnbsd_store_inferior_registers): Likewise. + * mips-linux-tdep.c (mips_supply_fpregset, mips_fill_fpregset) + (mips64_supply_fpregset, mips64_fill_fpregset): Likewise. + * mips-linux-nat.c (mips64_linux_register_addr): Likewise. + * m68k-tdep.c (m68k_register_type, m68k_convert_register_p): Likewise. + * m68klinux-nat.c (getfpregs_supplies, supply_fpregset) + (fill_fpregset): Likewise. + * irix5-nat.c (supply_fpregset, fill_fpregset): Likewise. + * i386-tdep.h (struct_return): Likewise (comment). + * i386-nto-tdep.c (i386nto_register_area): Likewise. + * go32-nat.c (fetch_register, go32_fetch_registers, store_register) + (go32_store_registers): Likewise. + * alpha-tdep.c (alpha_next_pc): Likewise. + * alpha-linux-nat.c (alpha_linux_register_u_offset): Likewise. + * alphabsd-nat.c (alphabsd_fetch_inferior_registers) + (alphabsd_store_inferior_registers): Likewise. + * core-regset.c (fetch_core_registers): Likewise. + * i386v4-nat.c (supply_fpregset, fill_fpregset): Likewise. + + * gdbarch.c, gdbarch.h: Regenerate. + 2007-06-18 Daniel Jacobowitz <dan@codesourcery.com> * coffread.c (coff_sym_fns): Add default_symfile_segments. diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 32b7430d568..4ad6a479a96 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -1065,7 +1065,7 @@ special_register_p (int regno) { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); - return regno == PC_REGNUM + return regno == gdbarch_pc_regnum (current_gdbarch) || regno == tdep->ppc_ps_regnum || regno == tdep->ppc_cr_regnum || regno == tdep->ppc_lr_regnum @@ -1087,7 +1087,8 @@ supply_sprs64 (struct regcache *regcache, { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); - regcache_raw_supply (regcache, PC_REGNUM, (char *) &iar); + regcache_raw_supply (regcache, gdbarch_pc_regnum (current_gdbarch), + (char *) &iar); regcache_raw_supply (regcache, tdep->ppc_ps_regnum, (char *) &msr); regcache_raw_supply (regcache, tdep->ppc_cr_regnum, (char *) &cr); regcache_raw_supply (regcache, tdep->ppc_lr_regnum, (char *) &lr); @@ -1109,7 +1110,8 @@ supply_sprs32 (struct regcache *regcache, { struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); - regcache_raw_supply (regcache, PC_REGNUM, (char *) &iar); + regcache_raw_supply (regcache, gdbarch_pc_regnum (current_gdbarch), + (char *) &iar); regcache_raw_supply (regcache, tdep->ppc_ps_regnum, (char *) &msr); regcache_raw_supply (regcache, tdep->ppc_cr_regnum, (char *) &cr); regcache_raw_supply (regcache, tdep->ppc_lr_regnum, (char *) &lr); @@ -1343,10 +1345,12 @@ fill_sprs64 (const struct regcache *regcache, they're not, then either GDB has been built incorrectly, or there's some other kind of internal error. To be really safe, we should check all of the sizes. */ - gdb_assert (sizeof (*iar) == register_size (current_gdbarch, PC_REGNUM)); + gdb_assert (sizeof (*iar) == register_size + (current_gdbarch, + gdbarch_pc_regnum (current_gdbarch))); - if (regcache_valid_p (regcache, PC_REGNUM)) - regcache_raw_collect (regcache, PC_REGNUM, iar); + if (regcache_valid_p (regcache, gdbarch_pc_regnum (current_gdbarch))) + regcache_raw_collect (regcache, gdbarch_pc_regnum (current_gdbarch), iar); if (regcache_valid_p (regcache, tdep->ppc_ps_regnum)) regcache_raw_collect (regcache, tdep->ppc_ps_regnum, msr); if (regcache_valid_p (regcache, tdep->ppc_cr_regnum)) @@ -1375,10 +1379,12 @@ fill_sprs32 (const struct regcache *regcache, they're not, then either GDB has been built incorrectly, or there's some other kind of internal error. To be really safe, we should check all of the sizes. */ - gdb_assert (sizeof (*iar) == register_size (current_gdbarch, PC_REGNUM)); + gdb_assert (sizeof (*iar) == register_size (current_gdbarch, + gdbarch_pc_regnum + (current_gdbarch))); - if (regcache_valid_p (regcache, PC_REGNUM)) - regcache_raw_collect (regcache, PC_REGNUM, iar); + if (regcache_valid_p (regcache, gdbarch_pc_regnum (current_gdbarch))) + regcache_raw_collect (regcache, gdbarch_pc_regnum (current_gdbarch), iar); if (regcache_valid_p (regcache, tdep->ppc_ps_regnum)) regcache_raw_collect (regcache, tdep->ppc_ps_regnum, msr); if (regcache_valid_p (regcache, tdep->ppc_cr_regnum)) @@ -1459,7 +1465,7 @@ store_regs_user_thread (const struct regcache *regcache, pthdb_pthread_t pdtid) fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr, &tmp_ctr, &tmp_xer, &tmp_fpscr); - if (regcache_valid_p (regcache, PC_REGNUM)) + if (regcache_valid_p (regcache, gdbarch_pc_regnum (current_gdbarch))) ctx.iar = tmp_iar; if (regcache_valid_p (regcache, tdep->ppc_ps_regnum)) ctx.msr = tmp_msr; diff --git a/gdb/alpha-linux-nat.c b/gdb/alpha-linux-nat.c index cebabde0ec7..aafd198f176 100644 --- a/gdb/alpha-linux-nat.c +++ b/gdb/alpha-linux-nat.c @@ -86,14 +86,14 @@ fill_fpregset (const struct regcache *regcache, static CORE_ADDR alpha_linux_register_u_offset (struct gdbarch *gdbarch, int regno, int store_p) { - if (regno == PC_REGNUM) + if (regno == gdbarch_pc_regnum (current_gdbarch)) return PC; if (regno == ALPHA_UNIQUE_REGNUM) return ALPHA_UNIQUE_PTRACE_ADDR; - if (regno < FP0_REGNUM) + if (regno < gdbarch_fp0_regnum (current_gdbarch)) return GPR_BASE + regno; else - return FPR_BASE + regno - FP0_REGNUM; + return FPR_BASE + regno - gdbarch_fp0_regnum (current_gdbarch); } void _initialialize_alpha_linux_nat (void); diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 284809d6976..820c072be26 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -1443,7 +1443,7 @@ alpha_next_pc (struct frame_info *frame, CORE_ADDR pc) case 0x33: /* FBLE */ case 0x32: /* FBLT */ case 0x35: /* FBNE */ - regno += FP0_REGNUM; + regno += gdbarch_fp0_regnum (current_gdbarch); } rav = get_frame_register_signed (frame, regno); diff --git a/gdb/alphabsd-nat.c b/gdb/alphabsd-nat.c index fd21983e236..e10b450f103 100644 --- a/gdb/alphabsd-nat.c +++ b/gdb/alphabsd-nat.c @@ -101,7 +101,7 @@ alphabsd_fetch_inferior_registers (struct regcache *regcache, int regno) return; } - if (regno == -1 || regno >= FP0_REGNUM) + if (regno == -1 || regno >= gdbarch_fp0_regnum (current_gdbarch)) { struct fpreg fpregs; @@ -136,7 +136,7 @@ alphabsd_store_inferior_registers (struct regcache *regcache, int regno) return; } - if (regno == -1 || regno >= FP0_REGNUM) + if (regno == -1 || regno >= gdbarch_fp0_regnum (current_gdbarch)) { struct fpreg fpregs; diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index 5a4c8b1a0f4..1622bf37e93 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -156,7 +156,7 @@ amd64_linux_sigcontext_addr (struct frame_info *next_frame) CORE_ADDR sp; gdb_byte buf[8]; - frame_unwind_register (next_frame, SP_REGNUM, buf); + frame_unwind_register (next_frame, gdbarch_sp_regnum (current_gdbarch), buf); sp = extract_unsigned_integer (buf, 8); /* The sigcontext structure is part of the user context. A pointer diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 57f32d2ed03..531217436c3 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -870,7 +870,7 @@ amd64_frame_prev_register (struct frame_info *next_frame, void **this_cache, gdb_assert (regnum >= 0); - if (regnum == SP_REGNUM && cache->saved_sp) + if (regnum == gdbarch_sp_regnum (current_gdbarch) && cache->saved_sp) { *optimizedp = 0; *lvalp = not_lval; diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 50768e93d66..7a154ba7f23 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -189,8 +189,10 @@ legacy_virtual_frame_pointer (CORE_ADDR pc, if (DEPRECATED_FP_REGNUM >= 0 && DEPRECATED_FP_REGNUM < gdbarch_num_regs (current_gdbarch)) *frame_regnum = DEPRECATED_FP_REGNUM; - else if (SP_REGNUM >= 0 && SP_REGNUM < gdbarch_num_regs (current_gdbarch)) - *frame_regnum = SP_REGNUM; + else if (gdbarch_sp_regnum (current_gdbarch) >= 0 + && gdbarch_sp_regnum (current_gdbarch) + < gdbarch_num_regs (current_gdbarch)) + *frame_regnum = gdbarch_sp_regnum (current_gdbarch); else /* Should this be an internal error? I guess so, it is reflecting an architectural limitation in the current design. */ diff --git a/gdb/core-regset.c b/gdb/core-regset.c index 8dc2c782ad7..bf5d0268078 100644 --- a/gdb/core-regset.c +++ b/gdb/core-regset.c @@ -85,7 +85,7 @@ fetch_core_registers (struct regcache *regcache, else { memcpy (&fpregset, core_reg_sect, sizeof (fpregset)); - if (FP0_REGNUM >= 0) + if (gdbarch_fp0_regnum (current_gdbarch) >= 0) supply_fpregset (regcache, (const gdb_fpregset_t *) &fpregset); } break; diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index 039e24f1fdd..a8817e9b50a 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -74,8 +74,8 @@ enum cris_num_regs ARG2_REGNUM Contains the second parameter to a function. ARG3_REGNUM Contains the third parameter to a function. ARG4_REGNUM Contains the fourth parameter to a function. Rest on stack. - SP_REGNUM Contains address of top of stack. - PC_REGNUM Contains address of next instruction. + gdbarch_sp_regnum Contains address of top of stack. + gdbarch_pc_regnum Contains address of next instruction. SRP_REGNUM Subroutine return pointer register. BRP_REGNUM Breakpoint return pointer register. */ @@ -279,7 +279,7 @@ cris_sigcontext_addr (struct frame_info *next_frame) CORE_ADDR sp; char buf[4]; - frame_unwind_register (next_frame, SP_REGNUM, buf); + frame_unwind_register (next_frame, gdbarch_sp_regnum (current_gdbarch), buf); sp = extract_unsigned_integer (buf, 4); /* Look for normal sigtramp frame first. */ @@ -359,7 +359,7 @@ cris_sigtramp_frame_unwind_cache (struct frame_info *next_frame, info->return_pc = 0; info->leaf_function = 0; - frame_unwind_register (next_frame, SP_REGNUM, buf); + frame_unwind_register (next_frame, gdbarch_sp_regnum (current_gdbarch), buf); info->base = extract_unsigned_integer (buf, 4); addr = cris_sigcontext_addr (next_frame); @@ -385,8 +385,10 @@ cris_sigtramp_frame_unwind_cache (struct frame_info *next_frame, it though since that will mean that the backtrace will show a PC different from what is shown when stopped. */ info->saved_regs[IRP_REGNUM].addr = addr + (19 * 4); - info->saved_regs[PC_REGNUM] = info->saved_regs[IRP_REGNUM]; - info->saved_regs[SP_REGNUM].addr = addr + (24 * 4); + info->saved_regs[gdbarch_pc_regnum (current_gdbarch)] + = info->saved_regs[IRP_REGNUM]; + info->saved_regs[gdbarch_sp_regnum (current_gdbarch)].addr + = addr + (24 * 4); } else { @@ -413,9 +415,11 @@ cris_sigtramp_frame_unwind_cache (struct frame_info *next_frame, This could be solved by a couple of read_memory_unsigned_integer and a trad_frame_set_value. */ - info->saved_regs[PC_REGNUM] = info->saved_regs[ERP_REGNUM]; + info->saved_regs[gdbarch_pc_regnum (current_gdbarch)] + = info->saved_regs[ERP_REGNUM]; - info->saved_regs[SP_REGNUM].addr = addr + (25 * 4); + info->saved_regs[gdbarch_sp_regnum (current_gdbarch)].addr + = addr + (25 * 4); } return info; @@ -986,7 +990,8 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } /* Finally, update the SP register. */ - regcache_cooked_write_unsigned (regcache, SP_REGNUM, sp); + regcache_cooked_write_unsigned (regcache, + gdbarch_sp_regnum (current_gdbarch), sp); return sp; } @@ -1180,7 +1185,7 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, } continue; } - else if (cris_get_operand2 (insn) == SP_REGNUM + else if (cris_get_operand2 (insn) == gdbarch_sp_regnum (current_gdbarch) && cris_get_mode (insn) == 0x0000 && cris_get_opcode (insn) == 0x000A) { @@ -1193,12 +1198,13 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, else if (cris_get_mode (insn) == 0x0002 && cris_get_opcode (insn) == 0x000F && cris_get_size (insn) == 0x0003 - && cris_get_operand1 (insn) == SP_REGNUM) + && cris_get_operand1 (insn) == gdbarch_sp_regnum + (current_gdbarch)) { /* movem r<regsave>,[sp] */ regsave = cris_get_operand2 (insn); } - else if (cris_get_operand2 (insn) == SP_REGNUM + else if (cris_get_operand2 (insn) == gdbarch_sp_regnum (current_gdbarch) && ((insn & 0x0F00) >> 8) == 0x0001 && (cris_get_signed_offset (insn) < 0)) { @@ -1215,7 +1221,8 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, if (cris_get_mode (insn_next) == PREFIX_ASSIGN_MODE && cris_get_opcode (insn_next) == 0x000F && cris_get_size (insn_next) == 0x0003 - && cris_get_operand1 (insn_next) == SP_REGNUM) + && cris_get_operand1 (insn_next) == gdbarch_sp_regnum + (current_gdbarch)) { regsave = cris_get_operand2 (insn_next); } @@ -1257,7 +1264,7 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, insn_next = read_memory_unsigned_integer (pc, 2); pc += 2; regno = cris_get_operand2 (insn_next); - if ((regno >= 0 && regno < SP_REGNUM) + if ((regno >= 0 && regno < gdbarch_sp_regnum (current_gdbarch)) && cris_get_mode (insn_next) == PREFIX_OFFSET_MODE && cris_get_opcode (insn_next) == 0x000F) { @@ -1281,7 +1288,7 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, insn_next = read_memory_unsigned_integer (pc, 2); pc += 2; regno = cris_get_operand2 (insn_next); - if ((regno >= 0 && regno < SP_REGNUM) + if ((regno >= 0 && regno < gdbarch_sp_regnum (current_gdbarch)) && cris_get_mode (insn_next) == PREFIX_OFFSET_MODE && cris_get_opcode (insn_next) == 0x0009 && cris_get_operand1 (insn_next) == regno) @@ -1335,7 +1342,9 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, ULONGEST this_base; /* Assume that the FP is this frame's SP but with that pushed stack space added back. */ - frame_unwind_unsigned_register (next_frame, SP_REGNUM, &this_base); + frame_unwind_unsigned_register (next_frame, + gdbarch_sp_regnum (current_gdbarch), + &this_base); info->base = this_base; info->prev_sp = info->base + info->size; } @@ -1354,7 +1363,8 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, /* The previous frame's SP needed to be computed. Save the computed value. */ - trad_frame_set_value (info->saved_regs, SP_REGNUM, info->prev_sp); + trad_frame_set_value (info->saved_regs, + gdbarch_sp_regnum (current_gdbarch), info->prev_sp); if (!info->leaf_function) { @@ -1372,7 +1382,8 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, } /* The PC is found in SRP (the actual register or located on the stack). */ - info->saved_regs[PC_REGNUM] = info->saved_regs[SRP_REGNUM]; + info->saved_regs[gdbarch_pc_regnum (current_gdbarch)] + = info->saved_regs[SRP_REGNUM]; return pc; } @@ -1403,12 +1414,15 @@ crisv32_scan_prologue (CORE_ADDR pc, struct frame_info *next_frame, } /* The SP is assumed to be unaltered. */ - frame_unwind_unsigned_register (next_frame, SP_REGNUM, &this_base); + frame_unwind_unsigned_register (next_frame, + gdbarch_sp_regnum (current_gdbarch), + &this_base); info->base = this_base; info->prev_sp = this_base; /* The PC is assumed to be found in SRP. */ - info->saved_regs[PC_REGNUM] = info->saved_regs[SRP_REGNUM]; + info->saved_regs[gdbarch_pc_regnum (current_gdbarch)] + = info->saved_regs[SRP_REGNUM]; return pc; } @@ -1447,7 +1461,8 @@ static CORE_ADDR cris_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { ULONGEST pc; - frame_unwind_unsigned_register (next_frame, PC_REGNUM, &pc); + frame_unwind_unsigned_register (next_frame, + gdbarch_pc_regnum (current_gdbarch), &pc); return pc; } @@ -1455,7 +1470,8 @@ static CORE_ADDR cris_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) { ULONGEST sp; - frame_unwind_unsigned_register (next_frame, SP_REGNUM, &sp); + frame_unwind_unsigned_register (next_frame, + gdbarch_sp_regnum (current_gdbarch), &sp); return sp; } @@ -1550,7 +1566,8 @@ cris_register_size (int regno) /* Special register not applicable to this CRIS version. */ return 0; } - else if (regno >= PC_REGNUM && regno < gdbarch_num_regs (current_gdbarch)) + else if (regno >= gdbarch_pc_regnum (current_gdbarch) + && regno < gdbarch_num_regs (current_gdbarch)) { /* This will apply to CRISv32 only where there are additional registers after the special registers (pseudo PC and support registers). */ @@ -1651,11 +1668,12 @@ crisv32_cannot_store_register (int regno) static struct type * cris_register_type (struct gdbarch *gdbarch, int regno) { - if (regno == PC_REGNUM) + if (regno == gdbarch_pc_regnum (current_gdbarch)) return builtin_type_void_func_ptr; - else if (regno == SP_REGNUM || regno == CRIS_FP_REGNUM) + else if (regno == gdbarch_sp_regnum (current_gdbarch) + || regno == CRIS_FP_REGNUM) return builtin_type_void_data_ptr; - else if ((regno >= 0 && regno < SP_REGNUM) + else if ((regno >= 0 && regno < gdbarch_sp_regnum (current_gdbarch)) || (regno >= MOF_REGNUM && regno <= USP_REGNUM)) /* Note: R8 taken care of previous clause. */ return builtin_type_uint32; @@ -1671,9 +1689,10 @@ cris_register_type (struct gdbarch *gdbarch, int regno) static struct type * crisv32_register_type (struct gdbarch *gdbarch, int regno) { - if (regno == PC_REGNUM) + if (regno == gdbarch_pc_regnum (current_gdbarch)) return builtin_type_void_func_ptr; - else if (regno == SP_REGNUM || regno == CRIS_FP_REGNUM) + else if (regno == gdbarch_sp_regnum (current_gdbarch) + || regno == CRIS_FP_REGNUM) return builtin_type_void_data_ptr; else if ((regno >= 0 && regno <= ACR_REGNUM) || (regno >= EXS_REGNUM && regno <= SPC_REGNUM) @@ -1801,7 +1820,7 @@ crisv32_register_name (int regno) { return cris_special_register_name (regno); } - else if (regno == PC_REGNUM) + else if (regno == gdbarch_pc_regnum (current_gdbarch)) { return "pc"; } @@ -1854,11 +1873,11 @@ cris_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, struct frame_info *next_frame) { /* The return address column. */ - if (regnum == PC_REGNUM) + if (regnum == gdbarch_pc_regnum (current_gdbarch)) reg->how = DWARF2_FRAME_REG_RA; /* The call frame address. */ - else if (regnum == SP_REGNUM) + else if (regnum == gdbarch_sp_regnum (current_gdbarch)) reg->how = DWARF2_FRAME_REG_CFA; } @@ -2090,7 +2109,8 @@ find_step_target (struct frame_info *frame, inst_env_type *inst_env) do { /* Read an instruction from the client. */ - insn = read_memory_unsigned_integer (inst_env->reg[PC_REGNUM], 2); + insn = read_memory_unsigned_integer + (inst_env->reg[gdbarch_pc_regnum (current_gdbarch)], 2); /* If the instruction is not in a delay slot the new content of the PC is [PC] + 2. If the instruction is in a delay slot it is not @@ -2099,12 +2119,13 @@ find_step_target (struct frame_info *frame, inst_env_type *inst_env) Just make sure it is a valid instruction. */ if (!inst_env->delay_slot_pc_active) { - inst_env->reg[PC_REGNUM] += 2; + inst_env->reg[gdbarch_pc_regnum (current_gdbarch)] += 2; } else { inst_env->delay_slot_pc_active = 0; - inst_env->reg[PC_REGNUM] = inst_env->delay_slot_pc; + inst_env->reg[gdbarch_pc_regnum (current_gdbarch)] + = inst_env->delay_slot_pc; } /* Analyse the present instruction. */ i = find_cris_op (insn, inst_env); @@ -2144,7 +2165,8 @@ cris_software_single_step (struct frame_info *frame) { /* Insert at most two breakpoints. One for the next PC content and possibly another one for a branch, jump, etc. */ - CORE_ADDR next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM]; + CORE_ADDR next_pc = + (CORE_ADDR) inst_env.reg[gdbarch_pc_regnum (current_gdbarch)]; insert_single_step_breakpoint (next_pc); if (inst_env.branch_found && (CORE_ADDR) inst_env.branch_break_address != next_pc) @@ -3882,7 +3904,7 @@ cris_supply_gregset (struct regcache *regcache, elf_gregset_t *gregsetp) /* Needed to set pseudo-register PC for CRISv32. */ /* FIXME: If ERP is in a delay slot at this point then the PC will be wrong. Issue a warning to alert the user. */ - regcache_raw_supply (regcache, PC_REGNUM, + regcache_raw_supply (regcache, gdbarch_pc_regnum (current_gdbarch), (char *)®p[ERP_REGNUM]); if (*(char *)®p[ERP_REGNUM] & 0x1) diff --git a/gdb/dbug-rom.c b/gdb/dbug-rom.c index 298a28b55fc..c37fbf3d372 100644 --- a/gdb/dbug-rom.c +++ b/gdb/dbug-rom.c @@ -51,12 +51,12 @@ dbug_supply_register (struct regcache *regcache, char *regname, case 'S': if (regname[1] != 'R') return; - regno = PS_REGNUM; + regno = gdbarch_ps_regnum (current_gdbarch); break; case 'P': if (regname[1] != 'C') return; - regno = PC_REGNUM; + regno = gdbarch_pc_regnum (current_gdbarch); break; case 'D': if (regname[1] < '0' || regname[1] > '7') diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index d2770cbc9f0..14acd339548 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -649,9 +649,9 @@ dwarf2_frame_default_init_reg (struct gdbarch *gdbarch, int regnum, (e.g. IBM S/390 and zSeries). Those architectures should provide their own architecture-specific initialization function. */ - if (regnum == PC_REGNUM) + if (regnum == gdbarch_pc_regnum (current_gdbarch)) reg->how = DWARF2_FRAME_REG_RA; - else if (regnum == SP_REGNUM) + else if (regnum == gdbarch_sp_regnum (current_gdbarch)) reg->how = DWARF2_FRAME_REG_CFA; } diff --git a/gdb/frame.c b/gdb/frame.c index 4e26f5a7832..560fcdea38f 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1229,7 +1229,7 @@ get_prev_frame_1 (struct frame_info *this_frame) method set the same lval and location information as frame_register_unwind. */ if (this_frame->level > 0 - && PC_REGNUM >= 0 + && gdbarch_pc_regnum (current_gdbarch) >= 0 && get_frame_type (this_frame) == NORMAL_FRAME && get_frame_type (this_frame->next) == NORMAL_FRAME) { @@ -1237,9 +1237,11 @@ get_prev_frame_1 (struct frame_info *this_frame) enum lval_type lval, nlval; CORE_ADDR addr, naddr; - frame_register_unwind_location (this_frame, PC_REGNUM, &optimized, - &lval, &addr, &realnum); - frame_register_unwind_location (get_next_frame (this_frame), PC_REGNUM, + frame_register_unwind_location (this_frame, + gdbarch_pc_regnum (current_gdbarch), + &optimized, &lval, &addr, &realnum); + frame_register_unwind_location (get_next_frame (this_frame), + gdbarch_pc_regnum (current_gdbarch), &optimized, &nlval, &naddr, &realnum); if (lval == lval_memory && lval == nlval && addr == naddr) @@ -1724,11 +1726,12 @@ frame_sp_unwind (struct frame_info *next_frame) if (gdbarch_unwind_sp_p (current_gdbarch)) return gdbarch_unwind_sp (current_gdbarch, next_frame); /* Now things are really are grim. Hope that the value returned by - the SP_REGNUM register is meaningful. */ - if (SP_REGNUM >= 0) + the gdbarch_sp_regnum register is meaningful. */ + if (gdbarch_sp_regnum (current_gdbarch) >= 0) { ULONGEST sp; - frame_unwind_unsigned_register (next_frame, SP_REGNUM, &sp); + frame_unwind_unsigned_register (next_frame, + gdbarch_sp_regnum (current_gdbarch), &sp); return sp; } internal_error (__FILE__, __LINE__, _("Missing unwind SP method")); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 68089df2458..36bb6c81767 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -839,11 +839,6 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: float_format = %s\n", pformat (current_gdbarch->float_format)); -#ifdef FP0_REGNUM - fprintf_unfiltered (file, - "gdbarch_dump: FP0_REGNUM # %s\n", - XSTRING (FP0_REGNUM)); -#endif fprintf_unfiltered (file, "gdbarch_dump: fp0_regnum = %s\n", paddr_d (current_gdbarch->fp0_regnum)); @@ -928,11 +923,6 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: overlay_update = <0x%lx>\n", (long) current_gdbarch->overlay_update); -#ifdef PC_REGNUM - fprintf_unfiltered (file, - "gdbarch_dump: PC_REGNUM # %s\n", - XSTRING (PC_REGNUM)); -#endif fprintf_unfiltered (file, "gdbarch_dump: pc_regnum = %s\n", paddr_d (current_gdbarch->pc_regnum)); @@ -963,11 +953,6 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: print_vector_info = <0x%lx>\n", (long) current_gdbarch->print_vector_info); -#ifdef PS_REGNUM - fprintf_unfiltered (file, - "gdbarch_dump: PS_REGNUM # %s\n", - XSTRING (PS_REGNUM)); -#endif fprintf_unfiltered (file, "gdbarch_dump: ps_regnum = %s\n", paddr_d (current_gdbarch->ps_regnum)); @@ -1085,11 +1070,6 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: software_single_step = <0x%lx>\n", (long) current_gdbarch->software_single_step); -#ifdef SP_REGNUM - fprintf_unfiltered (file, - "gdbarch_dump: SP_REGNUM # %s\n", - XSTRING (SP_REGNUM)); -#endif fprintf_unfiltered (file, "gdbarch_dump: sp_regnum = %s\n", paddr_d (current_gdbarch->sp_regnum)); diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index e167250707c..a08a98e5c46 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -192,43 +192,19 @@ extern void set_gdbarch_num_pseudo_regs (struct gdbarch *gdbarch, int num_pseudo /* GDB's standard (or well known) register numbers. These can map onto a real register or a pseudo (computed) register or not be defined at all (-1). - SP_REGNUM will hopefully be replaced by UNWIND_SP. */ + gdbarch_sp_regnum will hopefully be replaced by UNWIND_SP. */ extern int gdbarch_sp_regnum (struct gdbarch *gdbarch); extern void set_gdbarch_sp_regnum (struct gdbarch *gdbarch, int sp_regnum); -#if !defined (GDB_TM_FILE) && defined (SP_REGNUM) -#error "Non multi-arch definition of SP_REGNUM" -#endif -#if !defined (SP_REGNUM) -#define SP_REGNUM (gdbarch_sp_regnum (current_gdbarch)) -#endif extern int gdbarch_pc_regnum (struct gdbarch *gdbarch); extern void set_gdbarch_pc_regnum (struct gdbarch *gdbarch, int pc_regnum); -#if !defined (GDB_TM_FILE) && defined (PC_REGNUM) -#error "Non multi-arch definition of PC_REGNUM" -#endif -#if !defined (PC_REGNUM) -#define PC_REGNUM (gdbarch_pc_regnum (current_gdbarch)) -#endif extern int gdbarch_ps_regnum (struct gdbarch *gdbarch); extern void set_gdbarch_ps_regnum (struct gdbarch *gdbarch, int ps_regnum); -#if !defined (GDB_TM_FILE) && defined (PS_REGNUM) -#error "Non multi-arch definition of PS_REGNUM" -#endif -#if !defined (PS_REGNUM) -#define PS_REGNUM (gdbarch_ps_regnum (current_gdbarch)) -#endif extern int gdbarch_fp0_regnum (struct gdbarch *gdbarch); extern void set_gdbarch_fp0_regnum (struct gdbarch *gdbarch, int fp0_regnum); -#if !defined (GDB_TM_FILE) && defined (FP0_REGNUM) -#error "Non multi-arch definition of FP0_REGNUM" -#endif -#if !defined (FP0_REGNUM) -#define FP0_REGNUM (gdbarch_fp0_regnum (current_gdbarch)) -#endif /* Convert stab register number (from `r' declaration) to a gdb REGNUM. */ diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index ca6d0804b0e..a70b06b9911 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -438,11 +438,11 @@ v::int:num_pseudo_regs:::0:0::0 # GDB's standard (or well known) register numbers. These can map onto # a real register or a pseudo (computed) register or not be defined at # all (-1). -# SP_REGNUM will hopefully be replaced by UNWIND_SP. -v:=:int:sp_regnum:::-1:-1::0 -v:=:int:pc_regnum:::-1:-1::0 -v:=:int:ps_regnum:::-1:-1::0 -v:=:int:fp0_regnum:::0:-1::0 +# gdbarch_sp_regnum will hopefully be replaced by UNWIND_SP. +v::int:sp_regnum:::-1:-1::0 +v::int:pc_regnum:::-1:-1::0 +v::int:ps_regnum:::-1:-1::0 +v::int:fp0_regnum:::0:-1::0 # Convert stab register number (from \`r\' declaration) to a gdb REGNUM. f::int:stab_reg_to_regnum:int stab_regnr:stab_regnr::no_op_reg_to_regnum::0 # Provide a default mapping from a ecoff register number to a gdb REGNUM. diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index a794c61b8ff..189570db8bd 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -467,7 +467,7 @@ go32_wait (ptid_t ptid, struct target_waitstatus *status) static void fetch_register (struct regcache *regcache, int regno) { - if (regno < FP0_REGNUM) + if (regno < gdbarch_fp0_regnum (current_gdbarch)) 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)) @@ -484,7 +484,7 @@ go32_fetch_registers (struct regcache *regcache, int regno) fetch_register (regcache, regno); else { - for (regno = 0; regno < FP0_REGNUM; regno++) + for (regno = 0; regno < gdbarch_fp0_regnum (current_gdbarch); regno++) fetch_register (regcache, regno); i387_supply_fsave (regcache, -1, &npx); } @@ -493,7 +493,7 @@ go32_fetch_registers (struct regcache *regcache, int regno) static void store_register (const struct regcache *regcache, int regno) { - if (regno < FP0_REGNUM) + if (regno < gdbarch_fp0_regnum (current_gdbarch)) 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)) @@ -512,7 +512,7 @@ go32_store_registers (struct regcache *regcache, int regno) store_register (regcache, regno); else { - for (r = 0; r < FP0_REGNUM; r++) + for (r = 0; r < gdbarch_fp0_regnum (current_gdbarch); r++) store_register (regcache, r); i387_collect_fsave (regcache, -1, &npx); } diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index 7a2be097eb5..a8d02954804 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -744,7 +744,8 @@ i386_linux_resume (ptid_t ptid, int step, enum target_signal signal) request = PTRACE_SINGLESTEP; - regcache_cooked_read_unsigned (regcache, PC_REGNUM, &pc); + regcache_cooked_read_unsigned (regcache, + gdbarch_pc_regnum (current_gdbarch), &pc); /* Returning from a signal trampoline is done by calling a special system call (sigreturn or rt_sigreturn, see diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c index 30e72f15eab..5083c603a49 100644 --- a/gdb/i386-nto-tdep.c +++ b/gdb/i386-nto-tdep.c @@ -166,7 +166,8 @@ i386nto_register_area (int regno, int regset, unsigned *off) if (regno == -1) return regset_size; - *off = (regno - FP0_REGNUM) * regsize + off_adjust; + *off = (regno - gdbarch_fp0_regnum (current_gdbarch)) + * regsize + off_adjust; return 10; /* Why 10 instead of regsize? GDB only stores 10 bytes per FP register so if we're sending a register back to the target, diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index dc3ca791e46..015f5c9a190 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -914,7 +914,7 @@ i386_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { gdb_byte buf[8]; - frame_unwind_register (next_frame, PC_REGNUM, buf); + frame_unwind_register (next_frame, gdbarch_pc_regnum (current_gdbarch), buf); return extract_typed_address (buf, builtin_type_void_func_ptr); } @@ -1280,7 +1280,7 @@ i386_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) /* Don't use I386_ESP_REGNUM here, since this function is also used for AMD64. */ - get_frame_register (frame, SP_REGNUM, buf); + get_frame_register (frame, gdbarch_sp_regnum (current_gdbarch), buf); sp = extract_typed_address (buf, builtin_type_void_data_ptr); if (target_read_memory (sp + len, buf, len)) return 0; diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index d07d2c8e2d3..8f071c0e0d8 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -40,7 +40,7 @@ struct regcache; - SSE control register The general purpose registers for the x86-64 architecture are quite - different from IA-32. Therefore, the FP0_REGNUM target macro + different from IA-32. Therefore, gdbarch_fp0_regnum determines the register number at which the FPU data registers start. The number of FPU data and control registers is the same for both architectures. The number of SSE registers however, diff --git a/gdb/i386v4-nat.c b/gdb/i386v4-nat.c index 695207b3847..e3bd01c5d67 100644 --- a/gdb/i386v4-nat.c +++ b/gdb/i386v4-nat.c @@ -139,7 +139,7 @@ fill_gregset (const struct regcache *regcache, void supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp) { - if (FP0_REGNUM == 0) + if (gdbarch_fp0_regnum (current_gdbarch) == 0) return; i387_supply_fsave (regcache, -1, fpregsetp); @@ -153,7 +153,7 @@ void fill_fpregset (const struct regcache *regcache, fpregset_t *fpregsetp, int regno) { - if (FP0_REGNUM == 0) + if (gdbarch_fp0_regnum (current_gdbarch) == 0) return; i387_collect_fsave (regcache, regno, fpregsetp); diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 34d72394e8f..afb15190052 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -1618,7 +1618,7 @@ ia64_frame_prev_register (struct frame_info *next_frame, void **this_cache, memset (valuep, 0, register_size (current_gdbarch, regnum)); - if (regnum == SP_REGNUM) + if (regnum == gdbarch_sp_regnum (current_gdbarch)) { /* Handle SP values for all frames but the topmost. */ store_unsigned_integer (valuep, register_size (current_gdbarch, regnum), diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c index 830a6a6229d..bd9fb08c57a 100644 --- a/gdb/irix5-nat.c +++ b/gdb/irix5-nat.c @@ -95,7 +95,7 @@ fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno) *(regp + regi) = extract_signed_integer (buf, size); } - if ((regno == -1) || (regno == PC_REGNUM)) + if ((regno == -1) || (regno == gdbarch_pc_regnum (current_gdbarch))) { regi = mips_regnum (current_gdbarch)->pc; size = register_size (current_gdbarch, regi); @@ -130,7 +130,7 @@ fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno) /* * Now we do the same thing for floating-point registers. - * We don't bother to condition on FP0_REGNUM since any + * We don't bother to condition on gdbarch_fp0_regnum since any * reasonable MIPS configuration has an R3010 in it. * * Again, see the comments in m68k-tdep.c. @@ -146,7 +146,7 @@ supply_fpregset (struct regcache *regcache, const fpregset_t *fpregsetp) /* FIXME, this is wrong for the N32 ABI which has 64 bit FP regs. */ for (regi = 0; regi < 32; regi++) - regcache_raw_supply (regcache, FP0_REGNUM + regi, + regcache_raw_supply (regcache, gdbarch_fp0_regnum (current_gdbarch) + regi, (const char *) &fpregsetp->fp_r.fp_regs[regi]); /* We can't supply the FSR register directly to the regcache, @@ -175,11 +175,13 @@ fill_fpregset (const struct regcache *regcache, fpregset_t *fpregsetp, int regno /* FIXME, this is wrong for the N32 ABI which has 64 bit FP regs. */ - for (regi = FP0_REGNUM; regi < FP0_REGNUM + 32; regi++) + for (regi = gdbarch_fp0_regnum (current_gdbarch); + regi < gdbarch_fp0_regnum (current_gdbarch) + 32; regi++) { if ((regno == -1) || (regno == regi)) { - to = (char *) &(fpregsetp->fp_r.fp_regs[regi - FP0_REGNUM]); + to = (char *) &(fpregsetp->fp_r.fp_regs[regi - gdbarch_fp0_regnum + (current_gdbarch)]); regcache_raw_collect (regcache, regi, to); } } diff --git a/gdb/libunwind-frame.c b/gdb/libunwind-frame.c index ebf7eb21521..4324c3e4456 100644 --- a/gdb/libunwind-frame.c +++ b/gdb/libunwind-frame.c @@ -179,7 +179,7 @@ libunwind_frame_cache (struct frame_info *next_frame, void **this_cache) } /* To get base address, get sp from previous frame. */ - uw_sp_regnum = descr->gdb2uw (SP_REGNUM); + uw_sp_regnum = descr->gdb2uw (gdbarch_sp_regnum (current_gdbarch)); ret = unw_get_reg_p (&cache->cursor, uw_sp_regnum, &fp); if (ret < 0) { diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c index 4e690c05d3e..efed449a38d 100644 --- a/gdb/m32r-rom.c +++ b/gdb/m32r-rom.c @@ -276,9 +276,11 @@ m32r_supply_register (struct regcache *regcache, char *regname, stackmode = psw & 0x80; if (regno == SPI_REGNUM && !stackmode) /* SP == SPI */ - monitor_supply_register (regcache, SP_REGNUM, val); + monitor_supply_register (regcache, + gdbarch_sp_regnum (current_gdbarch), val); else if (regno == SPU_REGNUM && stackmode) /* SP == SPU */ - monitor_supply_register (regcache, SP_REGNUM, val); + monitor_supply_register (regcache, + gdbarch_sp_regnum (current_gdbarch), val); } } } diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index b91384c6491..2be4b44476e 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -85,7 +85,8 @@ m68k_register_type (struct gdbarch *gdbarch, int regnum) if (tdep->fpregs_present) { - if (regnum >= FP0_REGNUM && regnum <= FP0_REGNUM + 7) + if (regnum >= gdbarch_fp0_regnum (current_gdbarch) + && regnum <= gdbarch_fp0_regnum (current_gdbarch) + 7) { if (tdep->flavour == m68k_coldfire_flavour) return builtin_type (gdbarch)->builtin_double; @@ -105,7 +106,7 @@ m68k_register_type (struct gdbarch *gdbarch, int regnum) return builtin_type_int0; } - if (regnum == PC_REGNUM) + if (regnum == gdbarch_pc_regnum (current_gdbarch)) return builtin_type_void_func_ptr; if (regnum >= M68K_A0_REGNUM && regnum <= M68K_A0_REGNUM + 7) @@ -801,7 +802,7 @@ m68k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { gdb_byte buf[8]; - frame_unwind_register (next_frame, PC_REGNUM, buf); + frame_unwind_register (next_frame, gdbarch_pc_regnum (current_gdbarch), buf); return extract_typed_address (buf, builtin_type_void_func_ptr); } @@ -992,7 +993,7 @@ m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc) } buf = alloca (gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT); - sp = get_frame_register_unsigned (frame, SP_REGNUM); + sp = get_frame_register_unsigned (frame, gdbarch_sp_regnum (current_gdbarch)); if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */ buf, diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c index 9d68cf85486..09c64cb20a5 100644 --- a/gdb/m68klinux-nat.c +++ b/gdb/m68klinux-nat.c @@ -81,7 +81,8 @@ getregs_supplies (int regno) int getfpregs_supplies (int regno) { - return FP0_REGNUM <= regno && regno <= M68K_FPI_REGNUM; + return gdbarch_fp0_regnum (current_gdbarch) <= regno + && regno <= M68K_FPI_REGNUM; } /* Does the current host support the GETREGS request? */ @@ -245,10 +246,14 @@ supply_gregset (struct regcache *regcache, const elf_gregset_t *gregsetp) const elf_greg_t *regp = (const elf_greg_t *) gregsetp; int regi; - for (regi = M68K_D0_REGNUM; regi <= SP_REGNUM; regi++) + for (regi = M68K_D0_REGNUM; + regi <= gdbarch_sp_regnum (current_gdbarch); + regi++) regcache_raw_supply (regcache, regi, ®p[regmap[regi]]); - regcache_raw_supply (regcache, PS_REGNUM, ®p[PT_SR]); - regcache_raw_supply (regcache, PC_REGNUM, ®p[PT_PC]); + regcache_raw_supply (regcache, gdbarch_ps_regnum (current_gdbarch), + ®p[PT_SR]); + regcache_raw_supply (regcache, + gdbarch_pc_regnum (current_gdbarch), ®p[PT_PC]); } /* Fill register REGNO (if it is a general-purpose register) in @@ -330,9 +335,12 @@ supply_fpregset (struct regcache *regcache, const elf_fpregset_t *fpregsetp) { int regi; - for (regi = FP0_REGNUM; regi < FP0_REGNUM + 8; regi++) + for (regi = gdbarch_fp0_regnum (current_gdbarch); + regi < gdbarch_fp0_regnum (current_gdbarch) + 8; regi++) regcache_raw_supply (regcache, regi, - FPREG_ADDR (fpregsetp, regi - FP0_REGNUM)); + FPREG_ADDR (fpregsetp, + regi - gdbarch_fp0_regnum + (current_gdbarch))); regcache_raw_supply (regcache, M68K_FPC_REGNUM, &fpregsetp->fpcntl[0]); regcache_raw_supply (regcache, M68K_FPS_REGNUM, &fpregsetp->fpcntl[1]); regcache_raw_supply (regcache, M68K_FPI_REGNUM, &fpregsetp->fpcntl[2]); @@ -349,10 +357,13 @@ fill_fpregset (const struct regcache *regcache, int i; /* Fill in the floating-point registers. */ - for (i = FP0_REGNUM; i < FP0_REGNUM + 8; i++) + for (i = gdbarch_fp0_regnum (current_gdbarch); + i < gdbarch_fp0_regnum (current_gdbarch) + 8; i++) if (regno == -1 || regno == i) regcache_raw_collect (regcache, i, - FPREG_ADDR (fpregsetp, i - FP0_REGNUM)); + FPREG_ADDR (fpregsetp, + i - gdbarch_fp0_regnum + (current_gdbarch))); /* Fill in the floating-point control registers. */ for (i = M68K_FPC_REGNUM; i <= M68K_FPI_REGNUM; i++) diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c index 79fa3584ebc..9dd58dcbbb9 100644 --- a/gdb/mips-linux-nat.c +++ b/gdb/mips-linux-nat.c @@ -104,7 +104,7 @@ mips64_linux_register_addr (struct gdbarch *gdbarch, int regno, int store) regaddr = regno; else if ((regno >= mips_regnum (gdbarch)->fp0) && (regno < mips_regnum (gdbarch)->fp0 + 32)) - regaddr = MIPS64_FPR_BASE + (regno - FP0_REGNUM); + regaddr = MIPS64_FPR_BASE + (regno - gdbarch_fp0_regnum (current_gdbarch)); else if (regno == mips_regnum (gdbarch)->pc) regaddr = MIPS64_PC; else if (regno == mips_regnum (gdbarch)->cause) diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index 4b773d560e0..301843e847c 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -199,7 +199,9 @@ mips_supply_fpregset (struct regcache *regcache, memset (zerobuf, 0, MAX_REGISTER_SIZE); for (regi = 0; regi < 32; regi++) - regcache_raw_supply (regcache, FP0_REGNUM + regi, *fpregsetp + regi); + regcache_raw_supply (regcache, + gdbarch_fp0_regnum (current_gdbarch) + regi, + *fpregsetp + regi); regcache_raw_supply (regcache, mips_regnum (current_gdbarch)->fp_control_status, @@ -220,9 +222,10 @@ mips_fill_fpregset (const struct regcache *regcache, { char *from, *to; - if ((regno >= FP0_REGNUM) && (regno < FP0_REGNUM + 32)) + if ((regno >= gdbarch_fp0_regnum (current_gdbarch)) + && (regno < gdbarch_fp0_regnum (current_gdbarch) + 32)) { - to = (char *) (*fpregsetp + regno - FP0_REGNUM); + to = (char *) (*fpregsetp + regno - gdbarch_fp0_regnum (current_gdbarch)); regcache_raw_collect (regcache, regno, to); } else if (regno == mips_regnum (current_gdbarch)->fp_control_status) @@ -235,7 +238,8 @@ mips_fill_fpregset (const struct regcache *regcache, int regi; for (regi = 0; regi < 32; regi++) - mips_fill_fpregset (regcache, fpregsetp, FP0_REGNUM + regi); + mips_fill_fpregset (regcache, fpregsetp, + gdbarch_fp0_regnum (current_gdbarch) + regi); mips_fill_fpregset (regcache, fpregsetp, mips_regnum (current_gdbarch)->fp_control_status); } @@ -407,18 +411,22 @@ mips64_supply_fpregset (struct regcache *regcache, /* See mips_linux_o32_sigframe_init for a description of the peculiar FP register layout. */ - if (register_size (current_gdbarch, FP0_REGNUM) == 4) + if (register_size (current_gdbarch, + gdbarch_fp0_regnum (current_gdbarch)) == 4) for (regi = 0; regi < 32; regi++) { const gdb_byte *reg_ptr = (const gdb_byte *)(*fpregsetp + (regi & ~1)); if ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) != (regi & 1)) reg_ptr += 4; - regcache_raw_supply (regcache, FP0_REGNUM + regi, reg_ptr); + regcache_raw_supply (regcache, + gdbarch_fp0_regnum (current_gdbarch) + regi, + reg_ptr); } else for (regi = 0; regi < 32; regi++) - regcache_raw_supply (regcache, FP0_REGNUM + regi, + regcache_raw_supply (regcache, + gdbarch_fp0_regnum (current_gdbarch) + regi, (const char *)(*fpregsetp + regi)); supply_32bit_reg (regcache, mips_regnum (current_gdbarch)->fp_control_status, @@ -441,13 +449,14 @@ mips64_fill_fpregset (const struct regcache *regcache, { gdb_byte *to; - if ((regno >= FP0_REGNUM) && (regno < FP0_REGNUM + 32)) + if ((regno >= gdbarch_fp0_regnum (current_gdbarch)) + && (regno < gdbarch_fp0_regnum (current_gdbarch) + 32)) { /* See mips_linux_o32_sigframe_init for a description of the peculiar FP register layout. */ if (register_size (current_gdbarch, regno) == 4) { - int regi = regno - FP0_REGNUM; + int regi = regno - gdbarch_fp0_regnum (current_gdbarch); to = (gdb_byte *) (*fpregsetp + (regi & ~1)); if ((gdbarch_byte_order (current_gdbarch) @@ -457,7 +466,8 @@ mips64_fill_fpregset (const struct regcache *regcache, } else { - to = (gdb_byte *) (*fpregsetp + regno - FP0_REGNUM); + to = (gdb_byte *) (*fpregsetp + regno + - gdbarch_fp0_regnum (current_gdbarch)); regcache_raw_collect (regcache, regno, to); } } @@ -488,7 +498,8 @@ mips64_fill_fpregset (const struct regcache *regcache, int regi; for (regi = 0; regi < 32; regi++) - mips64_fill_fpregset (regcache, fpregsetp, FP0_REGNUM + regi); + mips64_fill_fpregset (regcache, fpregsetp, + gdbarch_fp0_regnum (current_gdbarch) + regi); mips64_fill_fpregset (regcache, fpregsetp, mips_regnum (current_gdbarch)->fp_control_status); mips64_fill_fpregset (regcache, fpregsetp, @@ -1056,7 +1067,8 @@ mips_linux_n32n64_sigframe_init (const struct tramp_frame *self, static void mips_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) { - regcache_cooked_write_unsigned (regcache, PC_REGNUM, pc); + regcache_cooked_write_unsigned (regcache, + gdbarch_pc_regnum (current_gdbarch), pc); /* Clear the syscall restart flag. */ if (mips_linux_restart_reg_p (current_gdbarch)) diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 3ef2fc0ad5d..8a966d4188a 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -1751,7 +1751,7 @@ mips_insn16_frame_cache (struct frame_info *next_frame, void **this_cache) mips16_scan_prologue (start_addr, pc, next_frame, *this_cache); } - /* SP_REGNUM, contains the value and not the address. */ + /* gdbarch_sp_regnum contains the value and not the address. */ trad_frame_set_value (cache->saved_regs, gdbarch_num_regs (current_gdbarch) + MIPS_SP_REGNUM, cache->base); @@ -2086,7 +2086,7 @@ mips_insn32_frame_cache (struct frame_info *next_frame, void **this_cache) mips32_scan_prologue (start_addr, pc, next_frame, *this_cache); } - /* SP_REGNUM, contains the value and not the address. */ + /* gdbarch_sp_regnum contains the value and not the address. */ trad_frame_set_value (cache->saved_regs, gdbarch_num_regs (current_gdbarch) + MIPS_SP_REGNUM, cache->base); @@ -2173,7 +2173,9 @@ mips_stub_frame_cache (struct frame_info *next_frame, void **this_cache) (*this_cache) = this_trad_cache; /* The return address is in the link register. */ - trad_frame_set_reg_realreg (this_trad_cache, PC_REGNUM, MIPS_RA_REGNUM); + trad_frame_set_reg_realreg (this_trad_cache, + gdbarch_pc_regnum (current_gdbarch), + MIPS_RA_REGNUM); /* Frame ID, since it's a frameless / stackless function, no stack space is allocated and SP on entry is the current SP. */ @@ -5195,7 +5197,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) else reg_names = mips_generic_reg_names; } - /* FIXME: cagney/2003-11-15: For MIPS, hasn't PC_REGNUM been + /* FIXME: cagney/2003-11-15: For MIPS, hasn't gdbarch_pc_regnum been replaced by read_pc? */ set_gdbarch_pc_regnum (gdbarch, regnum->pc + num_regs); set_gdbarch_sp_regnum (gdbarch, MIPS_SP_REGNUM + num_regs); diff --git a/gdb/mipsnbsd-nat.c b/gdb/mipsnbsd-nat.c index 721b4a0d457..44ccb3c7da4 100644 --- a/gdb/mipsnbsd-nat.c +++ b/gdb/mipsnbsd-nat.c @@ -36,7 +36,8 @@ static int getregs_supplies (int regno) { - return ((regno) >= MIPS_ZERO_REGNUM && (regno) <= PC_REGNUM); + return ((regno) >= MIPS_ZERO_REGNUM + && (regno) <= gdbarch_pc_regnum (current_gdbarch)); } static void @@ -55,7 +56,7 @@ mipsnbsd_fetch_inferior_registers (struct regcache *regcache, int regno) return; } - if (regno == -1 || regno >= FP0_REGNUM) + if (regno == -1 || regno >= gdbarch_fp0_regnum (current_gdbarch)) { struct fpreg fpregs; @@ -88,7 +89,7 @@ mipsnbsd_store_inferior_registers (struct regcache *regcache, int regno) return; } - if (regno == -1 || regno >= FP0_REGNUM) + if (regno == -1 || regno >= gdbarch_fp0_regnum (current_gdbarch)) { struct fpreg fpregs; diff --git a/gdb/mipsnbsd-tdep.c b/gdb/mipsnbsd-tdep.c index 5008211ad6e..b0c57676d78 100644 --- a/gdb/mipsnbsd-tdep.c +++ b/gdb/mipsnbsd-tdep.c @@ -146,7 +146,7 @@ mipsnbsd_supply_reg (struct regcache *regcache, const char *regs, int regno) { int i; - for (i = 0; i <= PC_REGNUM; i++) + for (i = 0; i <= gdbarch_pc_regnum (current_gdbarch); i++) { if (regno == i || regno == -1) { @@ -164,7 +164,7 @@ mipsnbsd_fill_reg (const struct regcache *regcache, char *regs, int regno) { int i; - for (i = 0; i <= PC_REGNUM; i++) + for (i = 0; i <= gdbarch_pc_regnum (current_gdbarch); i++) if ((regno == i || regno == -1) && ! gdbarch_cannot_store_register (current_gdbarch, i)) regcache_raw_collect (regcache, i, @@ -176,7 +176,7 @@ mipsnbsd_supply_fpreg (struct regcache *regcache, const char *fpregs, int regno) { int i; - for (i = FP0_REGNUM; + for (i = gdbarch_fp0_regnum (current_gdbarch); i <= mips_regnum (current_gdbarch)->fp_implementation_revision; i++) { @@ -186,7 +186,9 @@ mipsnbsd_supply_fpreg (struct regcache *regcache, const char *fpregs, int regno) regcache_raw_supply (regcache, i, NULL); else regcache_raw_supply (regcache, i, - fpregs + ((i - FP0_REGNUM) * mips_isa_regsize (current_gdbarch))); + fpregs + + ((i - gdbarch_fp0_regnum (current_gdbarch)) + * mips_isa_regsize (current_gdbarch))); } } } @@ -196,12 +198,15 @@ mipsnbsd_fill_fpreg (const struct regcache *regcache, char *fpregs, int regno) { int i; - for (i = FP0_REGNUM; i <= mips_regnum (current_gdbarch)->fp_control_status; + for (i = gdbarch_fp0_regnum (current_gdbarch); + i <= mips_regnum (current_gdbarch)->fp_control_status; i++) if ((regno == i || regno == -1) && ! gdbarch_cannot_store_register (current_gdbarch, i)) regcache_raw_collect (regcache, i, - fpregs + ((i - FP0_REGNUM) * mips_isa_regsize (current_gdbarch))); + fpregs + ((i - gdbarch_fp0_regnum + (current_gdbarch)) + * mips_isa_regsize (current_gdbarch))); } /* Under NetBSD/mips, signal handler invocations can be identified by the diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index c6d2fe66122..0016ecbbf1c 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -188,7 +188,7 @@ ppc_register_u_addr (int regno) u_addr = (PT_FPR0 * wordsize) + ((regno - tdep->ppc_fp0_regnum) * 8); /* UISA special purpose registers: 1 slot each */ - if (regno == PC_REGNUM) + if (regno == gdbarch_pc_regnum (current_gdbarch)) u_addr = PT_NIP * wordsize; if (regno == tdep->ppc_lr_regnum) u_addr = PT_LNK * wordsize; @@ -463,7 +463,7 @@ fetch_ppc_registers (struct regcache *regcache, int tid) if (tdep->ppc_fp0_regnum >= 0) for (i = 0; i < ppc_num_fprs; i++) fetch_register (regcache, tid, tdep->ppc_fp0_regnum + i); - fetch_register (regcache, tid, PC_REGNUM); + fetch_register (regcache, tid, gdbarch_pc_regnum (current_gdbarch)); if (tdep->ppc_ps_regnum != -1) fetch_register (regcache, tid, tdep->ppc_ps_regnum); if (tdep->ppc_cr_regnum != -1) @@ -747,7 +747,7 @@ store_ppc_registers (const struct regcache *regcache, int tid) if (tdep->ppc_fp0_regnum >= 0) for (i = 0; i < ppc_num_fprs; i++) store_register (regcache, tid, tdep->ppc_fp0_regnum + i); - store_register (regcache, tid, PC_REGNUM); + store_register (regcache, tid, gdbarch_pc_regnum (current_gdbarch)); if (tdep->ppc_ps_regnum != -1) store_register (regcache, tid, tdep->ppc_ps_regnum); if (tdep->ppc_cr_regnum != -1) @@ -946,8 +946,9 @@ fill_gregset (const struct regcache *regcache, (regp + PT_R0 + regi)); } - if ((regno == -1) || regno == PC_REGNUM) - right_fill_reg (regcache, PC_REGNUM, regp + PT_NIP); + if ((regno == -1) || regno == gdbarch_pc_regnum (current_gdbarch)) + right_fill_reg (regcache, gdbarch_pc_regnum (current_gdbarch), + regp + PT_NIP); if ((regno == -1) || regno == tdep->ppc_lr_regnum) right_fill_reg (regcache, tdep->ppc_lr_regnum, regp + PT_LNK); if ((regno == -1) || regno == tdep->ppc_cr_regnum) diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 5834b6d2de4..5cf0f236cf8 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -753,7 +753,8 @@ ppc_linux_sigtramp_cache (struct frame_info *next_frame, struct gdbarch *gdbarch = get_frame_arch (next_frame); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - base = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + base = frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (current_gdbarch)); if (bias > 0 && frame_pc_unwind (next_frame) != func) /* See below, some signal trampolines increment the stack as their first instruction, need to compensate for that. */ @@ -772,7 +773,9 @@ ppc_linux_sigtramp_cache (struct frame_info *next_frame, int regnum = i + tdep->ppc_gp0_regnum; trad_frame_set_reg_addr (this_cache, regnum, gpregs + i * tdep->wordsize); } - trad_frame_set_reg_addr (this_cache, PC_REGNUM, gpregs + 32 * tdep->wordsize); + trad_frame_set_reg_addr (this_cache, + gdbarch_pc_regnum (current_gdbarch), + gpregs + 32 * tdep->wordsize); trad_frame_set_reg_addr (this_cache, tdep->ppc_ctr_regnum, gpregs + 35 * tdep->wordsize); trad_frame_set_reg_addr (this_cache, tdep->ppc_lr_regnum, @@ -787,7 +790,7 @@ ppc_linux_sigtramp_cache (struct frame_info *next_frame, /* Floating point registers. */ for (i = 0; i < 32; i++) { - int regnum = i + FP0_REGNUM; + int regnum = i + gdbarch_fp0_regnum (current_gdbarch); trad_frame_set_reg_addr (this_cache, regnum, fpregs + i * tdep->wordsize); } diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 05fda1d0100..e045ca8696f 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -55,7 +55,9 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int argspace = 0; /* 0 is an initial wrong guess. */ int write_pass; - regcache_cooked_read_unsigned (regcache, SP_REGNUM, &saved_sp); + regcache_cooked_read_unsigned (regcache, + gdbarch_sp_regnum (current_gdbarch), + &saved_sp); /* Go through the argument list twice. @@ -307,7 +309,8 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } /* Update %sp. */ - regcache_cooked_write_signed (regcache, SP_REGNUM, sp); + regcache_cooked_write_signed (regcache, + gdbarch_sp_regnum (current_gdbarch), sp); /* Write the backchain (it occupies WORDSIZED bytes). */ write_memory_signed_integer (sp, tdep->wordsize, saved_sp); @@ -601,7 +604,9 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* By this stage in the proceedings, SP has been decremented by "red zone size" + "struct return size". Fetch the stack-pointer from before this and use that as the BACK_CHAIN. */ - regcache_cooked_read_unsigned (regcache, SP_REGNUM, &back_chain); + regcache_cooked_read_unsigned (regcache, + gdbarch_sp_regnum (current_gdbarch), + &back_chain); /* Go through the argument list twice. @@ -832,7 +837,8 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } /* Update %sp. */ - regcache_cooked_write_signed (regcache, SP_REGNUM, sp); + regcache_cooked_write_signed (regcache, + gdbarch_sp_regnum (current_gdbarch), sp); /* Write the backchain (it occupies WORDSIZED bytes). */ write_memory_signed_integer (sp, tdep->wordsize, back_chain); diff --git a/gdb/ppcnbsd-nat.c b/gdb/ppcnbsd-nat.c index 2c735733b46..bbf13cc39a9 100644 --- a/gdb/ppcnbsd-nat.c +++ b/gdb/ppcnbsd-nat.c @@ -52,7 +52,7 @@ getregs_supplies (int regnum) || regnum == tdep->ppc_cr_regnum || regnum == tdep->ppc_xer_regnum || regnum == tdep->ppc_ctr_regnum - || regnum == PC_REGNUM); + || regnum == gdbarch_pc_regnum (current_gdbarch)); } /* Like above, but for PT_GETFPREGS. */ @@ -169,7 +169,7 @@ ppcnbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) read_memory(cf.sp, (gdb_byte *)&cf, sizeof(cf)); regcache_raw_supply (regcache, tdep->ppc_lr_regnum, &cf.lr); - regcache_raw_supply (regcache, PC_REGNUM, &cf.lr); + regcache_raw_supply (regcache, gdbarch_pc_regnum (current_gdbarch), &cf.lr); return 1; } diff --git a/gdb/ppcnbsd-tdep.c b/gdb/ppcnbsd-tdep.c index 12ac5cb06f9..b79f5d4b687 100644 --- a/gdb/ppcnbsd-tdep.c +++ b/gdb/ppcnbsd-tdep.c @@ -115,7 +115,8 @@ ppcnbsd_sigtramp_cache_init (const struct tramp_frame *self, CORE_ADDR addr, base; int i; - base = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + base = frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (current_gdbarch)); if (self == &ppcnbsd2_sigtramp) addr = base + 0x10 + 2 * tdep->wordsize; else @@ -133,7 +134,9 @@ ppcnbsd_sigtramp_cache_init (const struct tramp_frame *self, addr += tdep->wordsize; trad_frame_set_reg_addr (this_cache, tdep->ppc_ctr_regnum, addr); addr += tdep->wordsize; - trad_frame_set_reg_addr (this_cache, PC_REGNUM, addr); /* SRR0? */ + trad_frame_set_reg_addr (this_cache, + gdbarch_pc_regnum (current_gdbarch), + addr); /* SRR0? */ addr += tdep->wordsize; /* Construct the frame ID using the function start. */ diff --git a/gdb/ppcobsd-nat.c b/gdb/ppcobsd-nat.c index 918690775bd..acb9d8b2c12 100644 --- a/gdb/ppcobsd-nat.c +++ b/gdb/ppcobsd-nat.c @@ -169,14 +169,14 @@ ppcobsd_supply_pcb (struct regcache *regcache, struct pcb *pcb) return 0; read_memory (pcb->pcb_sp, (gdb_byte *)&sf, sizeof sf); - regcache_raw_supply (regcache, SP_REGNUM, &sf.sp); + regcache_raw_supply (regcache, gdbarch_sp_regnum (current_gdbarch), &sf.sp); regcache_raw_supply (regcache, tdep->ppc_cr_regnum, &sf.cr); regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 2, &sf.fixreg2); for (i = 0, regnum = tdep->ppc_gp0_regnum + 13; i < 19; i++, regnum++) regcache_raw_supply (regcache, regnum, &sf.fixreg[i]); read_memory (sf.sp, (gdb_byte *)&cf, sizeof cf); - regcache_raw_supply (regcache, PC_REGNUM, &cf.lr); + regcache_raw_supply (regcache, gdbarch_pc_regnum (current_gdbarch), &cf.lr); regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 30, &cf.r30); regcache_raw_supply (regcache, tdep->ppc_gp0_regnum + 31, &cf.r31); diff --git a/gdb/ppcobsd-tdep.c b/gdb/ppcobsd-tdep.c index b826fba145c..3e82c6f0b19 100644 --- a/gdb/ppcobsd-tdep.c +++ b/gdb/ppcobsd-tdep.c @@ -211,7 +211,8 @@ ppcobsd_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache) insn = extract_unsigned_integer (buf, PPC_INSN_SIZE); sigcontext_offset = (0x10000 - (insn & 0x0000ffff)) + 8; - base = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + base = frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (current_gdbarch)); addr = base + sigcontext_offset + 2 * tdep->wordsize; for (i = 0; i < ppc_num_gprs; i++, addr += tdep->wordsize) { @@ -226,7 +227,8 @@ ppcobsd_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache) addr += tdep->wordsize; trad_frame_set_reg_addr (cache, tdep->ppc_ctr_regnum, addr); addr += tdep->wordsize; - trad_frame_set_reg_addr (cache, PC_REGNUM, addr); /* SRR0? */ + trad_frame_set_reg_addr (cache, gdbarch_pc_regnum (current_gdbarch), addr); + /* SRR0? */ addr += tdep->wordsize; /* Construct the frame ID using the function start. */ diff --git a/gdb/procfs.c b/gdb/procfs.c index b3a3fc27174..c3568746429 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -3709,13 +3709,13 @@ procfs_fetch_registers (struct regcache *regcache, int regnum) supply_gregset (regcache, (const gdb_gregset_t *) gregs); - if (FP0_REGNUM >= 0) /* Do we have an FPU? */ + if (gdbarch_fp0_regnum (current_gdbarch) >= 0) /* Do we have an FPU? */ { gdb_fpregset_t *fpregs; - if ((regnum >= 0 && regnum < FP0_REGNUM) - || regnum == PC_REGNUM - || regnum == SP_REGNUM) + if ((regnum >= 0 && regnum < gdbarch_fp0_regnum (current_gdbarch)) + || regnum == gdbarch_pc_regnum (current_gdbarch) + || regnum == gdbarch_sp_regnum (current_gdbarch)) return; /* Not a floating point register. */ fpregs = proc_get_fpregs (pi); @@ -3776,13 +3776,13 @@ procfs_store_registers (struct regcache *regcache, int regnum) if (!proc_set_gregs (pi)) proc_error (pi, "store_registers, set_gregs", __LINE__); - if (FP0_REGNUM >= 0) /* Do we have an FPU? */ + if (gdbarch_fp0_regnum (current_gdbarch) >= 0) /* Do we have an FPU? */ { gdb_fpregset_t *fpregs; - if ((regnum >= 0 && regnum < FP0_REGNUM) - || regnum == PC_REGNUM - || regnum == SP_REGNUM) + if ((regnum >= 0 && regnum < gdbarch_fp0_regnum (current_gdbarch)) + || regnum == gdbarch_pc_regnum (current_gdbarch) + || regnum == gdbarch_sp_regnum (current_gdbarch)) return; /* Not a floating point register. */ fpregs = proc_get_fpregs (pi); @@ -4413,7 +4413,7 @@ invalidate_cache (procinfo *parent, procinfo *pi, void *ptr) if (!proc_set_gregs (pi)) /* flush gregs cache */ proc_warn (pi, "target_resume, set_gregs", __LINE__); - if (FP0_REGNUM >= 0) + if (gdbarch_fp0_regnum (current_gdbarch) >= 0) if (pi->fpregs_dirty) if (parent == NULL || proc_get_current_thread (parent) != pi->tid) diff --git a/gdb/regcache.c b/gdb/regcache.c index 6c0fca82aca..05dc4bb77a2 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -839,10 +839,12 @@ read_pc_pid (ptid_t ptid) if (gdbarch_read_pc_p (gdbarch)) pc_val = gdbarch_read_pc (gdbarch, regcache); /* Else use per-frame method on get_current_frame. */ - else if (PC_REGNUM >= 0) + else if (gdbarch_pc_regnum (current_gdbarch) >= 0) { ULONGEST raw_val; - regcache_cooked_read_unsigned (regcache, PC_REGNUM, &raw_val); + regcache_cooked_read_unsigned (regcache, + gdbarch_pc_regnum (current_gdbarch), + &raw_val); pc_val = gdbarch_addr_bits_remove (current_gdbarch, raw_val); } else @@ -865,8 +867,9 @@ write_pc_pid (CORE_ADDR pc, ptid_t ptid) if (gdbarch_write_pc_p (gdbarch)) gdbarch_write_pc (gdbarch, regcache, pc); - else if (PC_REGNUM >= 0) - regcache_cooked_write_unsigned (regcache, PC_REGNUM, pc); + if (gdbarch_pc_regnum (current_gdbarch) >= 0) + regcache_cooked_write_unsigned (regcache, + gdbarch_pc_regnum (current_gdbarch), pc); else internal_error (__FILE__, __LINE__, _("write_pc_pid: Unable to update PC")); diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index 0acc606253b..d63bbcb09f2 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -1758,14 +1758,20 @@ mips_wait (ptid_t ptid, struct target_waitstatus *status) struct regcache *regcache = get_current_regcache (); char buf[MAX_REGISTER_SIZE]; - store_unsigned_integer (buf, register_size (current_gdbarch, PC_REGNUM), rpc); - regcache_raw_supply (regcache, PC_REGNUM, buf); - - store_unsigned_integer (buf, register_size (current_gdbarch, PC_REGNUM), rfp); + store_unsigned_integer (buf, + register_size + (current_gdbarch, gdbarch_pc_regnum + (current_gdbarch)), rpc); + regcache_raw_supply (regcache, gdbarch_pc_regnum (current_gdbarch), buf); + + store_unsigned_integer + (buf, register_size (current_gdbarch, + gdbarch_pc_regnum (current_gdbarch)), rfp); regcache_raw_supply (regcache, 30, buf); /* This register they are avoiding and so it is unnamed */ - store_unsigned_integer (buf, register_size (current_gdbarch, SP_REGNUM), rsp); - regcache_raw_supply (regcache, SP_REGNUM, buf); + store_unsigned_integer (buf, register_size (current_gdbarch, + gdbarch_sp_regnum (current_gdbarch)), rsp); + regcache_raw_supply (regcache, gdbarch_sp_regnum (current_gdbarch), buf); store_unsigned_integer (buf, register_size (current_gdbarch, DEPRECATED_FP_REGNUM), 0); regcache_raw_supply (regcache, DEPRECATED_FP_REGNUM, buf); @@ -3263,7 +3269,7 @@ mips_load (char *file, int from_tty) /* Work around problem where PMON monitor updates the PC after a load to a different value than GDB thinks it has. The following ensures that the write_pc() WILL update the PC value: */ - deprecated_register_valid[PC_REGNUM] = 0; + deprecated_register_valid[gdbarch_pc_regnum (current_gdbarch)] = 0; } if (exec_bfd) write_pc (bfd_get_start_address (exec_bfd)); diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 2c77328aad3..f8866aa0d22 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -157,7 +157,7 @@ regmap (int regno, int *isfloat) *isfloat = 1; return regno - tdep->ppc_fp0_regnum + FPR0; } - else if (regno == PC_REGNUM) + else if (regno == gdbarch_pc_regnum (current_gdbarch)) return IAR; else if (regno == tdep->ppc_ps_regnum) return MSR; @@ -297,7 +297,7 @@ store_register (const struct regcache *regcache, int regno) /* Fixed-point registers. */ else { - if (regno == SP_REGNUM) + if (regno == gdbarch_sp_regnum (current_gdbarch)) /* Execute one dummy instruction (which is a breakpoint) in inferior process to give kernel a chance to do internal housekeeping. Otherwise the following ptrace(2) calls will mess up user stack @@ -357,7 +357,7 @@ rs6000_fetch_inferior_registers (struct regcache *regcache, int regno) fetch_register (regcache, tdep->ppc_fp0_regnum + regno); /* Read special registers. */ - fetch_register (regcache, PC_REGNUM); + fetch_register (regcache, gdbarch_pc_regnum (current_gdbarch)); fetch_register (regcache, tdep->ppc_ps_regnum); fetch_register (regcache, tdep->ppc_cr_regnum); fetch_register (regcache, tdep->ppc_lr_regnum); @@ -398,7 +398,7 @@ rs6000_store_inferior_registers (struct regcache *regcache, int regno) store_register (regcache, tdep->ppc_fp0_regnum + regno); /* Write special registers. */ - store_register (regcache, PC_REGNUM); + store_register (regcache, gdbarch_pc_regnum (current_gdbarch)); store_register (regcache, tdep->ppc_ps_regnum); store_register (regcache, tdep->ppc_cr_regnum); store_register (regcache, tdep->ppc_lr_regnum); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index c470ab9325d..ac5b091afca 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -342,8 +342,9 @@ ppc_supply_gregset (const struct regset *regset, struct regcache *regcache, ppc_supply_reg (regcache, i, gregs, offset); } - if (regnum == -1 || regnum == PC_REGNUM) - ppc_supply_reg (regcache, PC_REGNUM, gregs, offsets->pc_offset); + if (regnum == -1 || regnum == gdbarch_pc_regnum (current_gdbarch)) + ppc_supply_reg (regcache, gdbarch_pc_regnum (current_gdbarch), + gregs, offsets->pc_offset); if (regnum == -1 || regnum == tdep->ppc_ps_regnum) ppc_supply_reg (regcache, tdep->ppc_ps_regnum, gregs, offsets->ps_offset); @@ -418,8 +419,9 @@ ppc_collect_gregset (const struct regset *regset, ppc_collect_reg (regcache, i, gregs, offset); } - if (regnum == -1 || regnum == PC_REGNUM) - ppc_collect_reg (regcache, PC_REGNUM, gregs, offsets->pc_offset); + if (regnum == -1 || regnum == gdbarch_pc_regnum (current_gdbarch)) + ppc_collect_reg (regcache, gdbarch_pc_regnum (current_gdbarch), + gregs, offsets->pc_offset); if (regnum == -1 || regnum == tdep->ppc_ps_regnum) ppc_collect_reg (regcache, tdep->ppc_ps_regnum, gregs, offsets->ps_offset); @@ -1697,7 +1699,9 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, ran_out_of_registers_for_arguments: - regcache_cooked_read_unsigned (regcache, SP_REGNUM, &saved_sp); + regcache_cooked_read_unsigned (regcache, + gdbarch_sp_regnum (current_gdbarch), + &saved_sp); /* Location for 8 parameters are always reserved. */ sp -= wordsize * 8; @@ -1739,7 +1743,8 @@ ran_out_of_registers_for_arguments: to use this area. So, update %sp first before doing anything else. */ - regcache_raw_write_signed (regcache, SP_REGNUM, sp); + regcache_raw_write_signed (regcache, + gdbarch_sp_regnum (current_gdbarch), sp); /* If the last argument copied into the registers didn't fit there completely, push the rest of it into stack. */ @@ -1786,7 +1791,7 @@ ran_out_of_registers_for_arguments: Not doing this can lead to conflicts with the kernel which thinks that it still has control over this not-yet-allocated stack region. */ - regcache_raw_write_signed (regcache, SP_REGNUM, sp); + regcache_raw_write_signed (regcache, gdbarch_sp_regnum (current_gdbarch), sp); /* Set back chain properly. */ store_unsigned_integer (tmp_buffer, wordsize, saved_sp); @@ -2210,7 +2215,7 @@ rs6000_register_reggroup_p (struct gdbarch *gdbarch, int regnum, || regnum == tdep->ppc_lr_regnum || regnum == tdep->ppc_ctr_regnum || regnum == tdep->ppc_xer_regnum - || regnum == PC_REGNUM); + || regnum == gdbarch_pc_regnum (current_gdbarch)); if (group == general_reggroup) return general_p; @@ -3119,15 +3124,16 @@ gdb_print_insn_powerpc (bfd_vma memaddr, disassemble_info *info) static CORE_ADDR rs6000_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_unwind_register_unsigned (next_frame, PC_REGNUM); + return frame_unwind_register_unsigned (next_frame, + gdbarch_pc_regnum (current_gdbarch)); } static struct frame_id rs6000_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_id_build (frame_unwind_register_unsigned (next_frame, - SP_REGNUM), - frame_pc_unwind (next_frame)); + return frame_id_build (frame_unwind_register_unsigned + (next_frame, gdbarch_sp_regnum (current_gdbarch)), + frame_pc_unwind (next_frame)); } struct rs6000_frame_cache @@ -3164,7 +3170,8 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) ->frame pointed to the outer-most address of the frame. In the mean time, the address of the prev frame is used as the base address of this frame. */ - cache->base = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + cache->base = frame_unwind_register_unsigned + (next_frame, gdbarch_sp_regnum (current_gdbarch)); /* If the function appears to be frameless, check a couple of likely indicators that we have simply failed to find the frame setup. @@ -3202,7 +3209,8 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) /* Frameless really means stackless. */ cache->base = read_memory_addr (cache->base, wordsize); - trad_frame_set_value (cache->saved_regs, SP_REGNUM, cache->base); + trad_frame_set_value (cache->saved_regs, + gdbarch_sp_regnum (current_gdbarch), cache->base); /* if != -1, fdata.saved_fpr is the smallest number of saved_fpr. All fpr's from saved_fpr to fp31 are saved. */ @@ -3281,7 +3289,8 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) if (fdata.lr_offset != 0) cache->saved_regs[tdep->ppc_lr_regnum].addr = cache->base + fdata.lr_offset; /* The PC is found in the link register. */ - cache->saved_regs[PC_REGNUM] = cache->saved_regs[tdep->ppc_lr_regnum]; + cache->saved_regs[gdbarch_pc_regnum (current_gdbarch)] = + cache->saved_regs[tdep->ppc_lr_regnum]; /* If != 0, fdata.vrsave_offset is the offset from the frame that holds the VRSAVE. */ @@ -3291,7 +3300,8 @@ rs6000_frame_cache (struct frame_info *next_frame, void **this_cache) if (fdata.alloca_reg < 0) /* If no alloca register used, then fi->frame is the value of the %sp for this frame, and it is good enough. */ - cache->initial_sp = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + cache->initial_sp = frame_unwind_register_unsigned + (next_frame, gdbarch_sp_regnum (current_gdbarch)); else cache->initial_sp = frame_unwind_register_unsigned (next_frame, fdata.alloca_reg); diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index 34df35da510..ca800cacd50 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -1134,7 +1134,8 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch, regcache_cooked_write_unsigned (regcache, PR_REGNUM, bp_addr); /* Update stack pointer. */ - regcache_cooked_write_unsigned (regcache, SP_REGNUM, sp); + regcache_cooked_write_unsigned (regcache, + gdbarch_sp_regnum (current_gdbarch), sp); return sp; } @@ -1204,7 +1205,8 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch, regcache_cooked_write_unsigned (regcache, PR_REGNUM, bp_addr); /* Update stack pointer. */ - regcache_cooked_write_unsigned (regcache, SP_REGNUM, sp); + regcache_cooked_write_unsigned (regcache, + gdbarch_sp_regnum (current_gdbarch), sp); return sp; } @@ -1245,7 +1247,7 @@ sh_extract_return_value_fpu (struct type *type, struct regcache *regcache, if (sh_treat_as_flt_p (type)) { int len = TYPE_LENGTH (type); - int i, regnum = FP0_REGNUM; + int i, regnum = gdbarch_fp0_regnum (current_gdbarch); for (i = 0; i < len; i += 4) if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) regcache_raw_read (regcache, regnum++, (char *) valbuf + len - 4 - i); @@ -1289,7 +1291,7 @@ sh_store_return_value_fpu (struct type *type, struct regcache *regcache, if (sh_treat_as_flt_p (type)) { int len = TYPE_LENGTH (type); - int i, regnum = FP0_REGNUM; + int i, regnum = gdbarch_fp0_regnum (current_gdbarch); for (i = 0; i < len; i += 4) if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) regcache_raw_write (regcache, regnum++, @@ -1336,7 +1338,8 @@ sh_generic_show_regs (struct frame_info *frame) { printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1374,7 +1377,8 @@ sh3_show_regs (struct frame_info *frame) { printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1416,7 +1420,8 @@ sh2e_show_regs (struct frame_info *frame) { printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1456,24 +1461,40 @@ sh2e_show_regs (struct frame_info *frame) printf_filtered ("FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 0), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 1), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 2), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 3), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 4), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 5), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 6), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 7)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 0), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 1), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 2), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 3), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 4), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 5), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 6), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 7)); printf_filtered ("FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 8), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 9), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 10), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 11), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 12), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 13), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 14), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 15)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 8), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 9), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 10), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 11), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 12), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 13), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 14), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 15)); } static void @@ -1483,7 +1504,8 @@ sh2a_show_regs (struct frame_info *frame) printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1525,25 +1547,41 @@ sh2a_show_regs (struct frame_info *frame) printf_filtered (pr ? "DR0-DR6 %08lx%08lx %08lx%08lx %08lx%08lx %08lx%08lx\n" : "FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 0), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 1), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 2), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 3), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 4), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 5), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 6), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 7)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 0), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 1), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 2), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 3), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 4), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 5), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 6), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 7)); printf_filtered (pr ? "DR8-DR14 %08lx%08lx %08lx%08lx %08lx%08lx %08lx%08lx\n" : "FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 8), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 9), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 10), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 11), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 12), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 13), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 14), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 15)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 8), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 9), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 10), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 11), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 12), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 13), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 14), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 15)); printf_filtered ("BANK=%-3d\n", (int) get_frame_register_unsigned (frame, BANK_REGNUM)); printf_filtered @@ -1581,7 +1619,8 @@ sh2a_nofpu_show_regs (struct frame_info *frame) printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1655,7 +1694,8 @@ sh3e_show_regs (struct frame_info *frame) { printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1695,24 +1735,40 @@ sh3e_show_regs (struct frame_info *frame) printf_filtered ("FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 0), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 1), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 2), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 3), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 4), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 5), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 6), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 7)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 0), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 1), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 2), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 3), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 4), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 5), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 6), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 7)); printf_filtered ("FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 8), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 9), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 10), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 11), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 12), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 13), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 14), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 15)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 8), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 9), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 10), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 11), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 12), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 13), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 14), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 15)); } static void @@ -1720,7 +1776,8 @@ sh3_dsp_show_regs (struct frame_info *frame) { printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1784,7 +1841,8 @@ sh4_show_regs (struct frame_info *frame) printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1825,25 +1883,41 @@ sh4_show_regs (struct frame_info *frame) printf_filtered (pr ? "DR0-DR6 %08lx%08lx %08lx%08lx %08lx%08lx %08lx%08lx\n" : "FP0-FP7 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 0), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 1), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 2), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 3), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 4), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 5), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 6), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 7)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 0), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 1), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 2), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 3), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 4), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 5), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 6), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 7)); printf_filtered (pr ? "DR8-DR14 %08lx%08lx %08lx%08lx %08lx%08lx %08lx%08lx\n" : "FP8-FP15 %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 8), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 9), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 10), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 11), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 12), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 13), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 14), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + 15)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 8), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 9), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 10), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 11), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 12), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 13), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 14), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + 15)); } static void @@ -1851,7 +1925,8 @@ sh4_nofpu_show_regs (struct frame_info *frame) { printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1895,7 +1970,8 @@ sh_dsp_show_regs (struct frame_info *frame) { printf_filtered (" PC %s SR %08lx PR %08lx MACH %08lx\n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long) get_frame_register_unsigned (frame, SR_REGNUM), (long) get_frame_register_unsigned (frame, PR_REGNUM), (long) get_frame_register_unsigned (frame, MACH_REGNUM)); @@ -1956,7 +2032,7 @@ sh_show_regs_command (char *args, int from_tty) static struct type * sh_sh2a_register_type (struct gdbarch *gdbarch, int reg_nr) { - if ((reg_nr >= FP0_REGNUM + if ((reg_nr >= gdbarch_fp0_regnum (current_gdbarch) && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM)) return builtin_type_float; else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM) @@ -1970,7 +2046,7 @@ sh_sh2a_register_type (struct gdbarch *gdbarch, int reg_nr) static struct type * sh_sh3e_register_type (struct gdbarch *gdbarch, int reg_nr) { - if ((reg_nr >= FP0_REGNUM + if ((reg_nr >= gdbarch_fp0_regnum (current_gdbarch) && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM)) return builtin_type_float; else @@ -1989,7 +2065,7 @@ sh_sh4_build_float_register_type (int high) static struct type * sh_sh4_register_type (struct gdbarch *gdbarch, int reg_nr) { - if ((reg_nr >= FP0_REGNUM + if ((reg_nr >= gdbarch_fp0_regnum (current_gdbarch) && (reg_nr <= FP_LAST_REGNUM)) || (reg_nr == FPUL_REGNUM)) return builtin_type_float; else if (reg_nr >= DR0_REGNUM && reg_nr <= DR_LAST_REGNUM) @@ -2109,7 +2185,8 @@ fv_reg_base_num (int fv_regnum) { int fp_regnum; - fp_regnum = FP0_REGNUM + (fv_regnum - FV0_REGNUM) * 4; + fp_regnum = gdbarch_fp0_regnum (current_gdbarch) + + (fv_regnum - FV0_REGNUM) * 4; return fp_regnum; } @@ -2119,7 +2196,8 @@ dr_reg_base_num (int dr_regnum) { int fp_regnum; - fp_regnum = FP0_REGNUM + (dr_regnum - DR0_REGNUM) * 2; + fp_regnum = gdbarch_fp0_regnum (current_gdbarch) + + (dr_regnum - DR0_REGNUM) * 2; return fp_regnum; } @@ -2269,11 +2347,11 @@ sh_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum, struct frame_info *next_frame) { /* Mark the PC as the destination for the return address. */ - if (regnum == PC_REGNUM) + if (regnum == gdbarch_pc_regnum (current_gdbarch)) reg->how = DWARF2_FRAME_REG_RA; /* Mark the stack pointer as the call frame address. */ - else if (regnum == SP_REGNUM) + else if (regnum == gdbarch_sp_regnum (current_gdbarch)) reg->how = DWARF2_FRAME_REG_CFA; /* The above was taken from the default init_reg in dwarf2-frame.c @@ -2375,7 +2453,8 @@ sh_frame_cache (struct frame_info *next_frame, void **this_cache) setup yet. Try to reconstruct the base address for the stack frame by looking at the stack pointer. For truly "frameless" functions this might work too. */ - cache->base = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + cache->base = frame_unwind_register_unsigned + (next_frame, gdbarch_sp_regnum (current_gdbarch)); } /* Now that we have the base address for the stack frame we can @@ -2401,7 +2480,7 @@ sh_frame_prev_register (struct frame_info *next_frame, void **this_cache, gdb_assert (regnum >= 0); - if (regnum == SP_REGNUM && cache->saved_sp) + if (regnum == gdbarch_sp_regnum (current_gdbarch) && cache->saved_sp) { *optimizedp = 0; *lvalp = not_lval; @@ -2418,7 +2497,7 @@ sh_frame_prev_register (struct frame_info *next_frame, void **this_cache, /* The PC of the previous frame is stored in the PR register of the current frame. Frob regnum so that we pull the value from the correct place. */ - if (regnum == PC_REGNUM) + if (regnum == gdbarch_pc_regnum (current_gdbarch)) regnum = PR_REGNUM; if (regnum < SH_NUM_REGS && cache->saved_regs[regnum] != -1) @@ -2472,13 +2551,15 @@ sh_frame_sniffer (struct frame_info *next_frame) static CORE_ADDR sh_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_unwind_register_unsigned (next_frame, SP_REGNUM); + return frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (current_gdbarch)); } static CORE_ADDR sh_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_unwind_register_unsigned (next_frame, PC_REGNUM); + return frame_unwind_register_unsigned (next_frame, + gdbarch_pc_regnum (current_gdbarch)); } static struct frame_id diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c index f89d6ac7b16..7190ef888a8 100644 --- a/gdb/sh64-tdep.c +++ b/gdb/sh64-tdep.c @@ -95,7 +95,7 @@ enum DR0_REGNUM = 141, DR_LAST_REGNUM = 172, /* FPP stands for Floating Point Pair, to avoid confusion with - GDB's FP0_REGNUM, which is the number of the first Floating + GDB's gdbarch_fp0_regnum, which is the number of the first Floating point register. Unfortunately on the sh5, the floating point registers are called FR, and the floating point pairs are called FP. */ FPP0_REGNUM = 173, @@ -691,7 +691,7 @@ sh64_fv_reg_base_num (int fv_regnum) { int fp_regnum; - fp_regnum = FP0_REGNUM + + fp_regnum = gdbarch_fp0_regnum (current_gdbarch) + (fv_regnum - FV0_REGNUM) * 4; return fp_regnum; } @@ -702,7 +702,7 @@ sh64_dr_reg_base_num (int dr_regnum) { int fp_regnum; - fp_regnum = FP0_REGNUM + + fp_regnum = gdbarch_fp0_regnum (current_gdbarch) + (dr_regnum - DR0_REGNUM) * 2; return fp_regnum; } @@ -713,7 +713,7 @@ sh64_fpp_reg_base_num (int fpp_regnum) { int fp_regnum; - fp_regnum = FP0_REGNUM + + fp_regnum = gdbarch_fp0_regnum (current_gdbarch) + (fpp_regnum - FPP0_REGNUM) * 2; return fp_regnum; } @@ -793,7 +793,7 @@ sh64_compact_reg_base_num (int reg_nr) /* floating point register N maps to floating point register N */ else if (reg_nr >= FP0_C_REGNUM && reg_nr <= FP_LAST_C_REGNUM) - base_regnum = reg_nr - FP0_C_REGNUM + FP0_REGNUM; + base_regnum = reg_nr - FP0_C_REGNUM + gdbarch_fp0_regnum (current_gdbarch); /* double prec register N maps to base regnum for double prec register N */ else if (reg_nr >= DR0_C_REGNUM @@ -806,7 +806,7 @@ sh64_compact_reg_base_num (int reg_nr) base_regnum = sh64_fv_reg_base_num (FV0_REGNUM + reg_nr - FV0_C_REGNUM); else if (reg_nr == PC_C_REGNUM) - base_regnum = PC_REGNUM; + base_regnum = gdbarch_pc_regnum (current_gdbarch); else if (reg_nr == GBR_C_REGNUM) base_regnum = 16; @@ -825,7 +825,7 @@ sh64_compact_reg_base_num (int reg_nr) base_regnum = FPSCR_REGNUM; /*???? this register is a mess. */ else if (reg_nr == FPUL_C_REGNUM) - base_regnum = FP0_REGNUM + 32; + base_regnum = gdbarch_fp0_regnum (current_gdbarch) + 32; return base_regnum; } @@ -1087,7 +1087,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch, in eight registers available. Loop thru args from first to last. */ int_argreg = ARG0_REGNUM; - float_argreg = FP0_REGNUM; + float_argreg = gdbarch_fp0_regnum (current_gdbarch); double_argreg = DR0_REGNUM; for (argnum = 0, stack_offset = 0; argnum < nargs; argnum++) @@ -1157,7 +1157,8 @@ sh64_push_dummy_call (struct gdbarch *gdbarch, { /* Goes in FR0...FR11 */ regcache_cooked_write (regcache, - FP0_REGNUM + float_arg_index, + gdbarch_fp0_regnum (current_gdbarch) + + float_arg_index, val); fp_args[float_arg_index] = 1; /* Skip the corresponding general argument register. */ @@ -1201,7 +1202,8 @@ sh64_push_dummy_call (struct gdbarch *gdbarch, regcache_cooked_write_unsigned (regcache, PR_REGNUM, bp_addr); /* Update stack pointer. */ - regcache_cooked_write_unsigned (regcache, SP_REGNUM, sp); + regcache_cooked_write_unsigned (regcache, + gdbarch_sp_regnum (current_gdbarch), sp); return sp; } @@ -1220,8 +1222,9 @@ sh64_extract_return_value (struct type *type, struct regcache *regcache, { if (len == 4) { - /* Return value stored in FP0_REGNUM */ - regcache_raw_read (regcache, FP0_REGNUM, valbuf); + /* Return value stored in gdbarch_fp0_regnum */ + regcache_raw_read (regcache, + gdbarch_fp0_regnum (current_gdbarch), valbuf); } else if (len == 8) { @@ -1278,7 +1281,7 @@ sh64_store_return_value (struct type *type, struct regcache *regcache, if (TYPE_CODE (type) == TYPE_CODE_FLT) { - int i, regnum = FP0_REGNUM; + int i, regnum = gdbarch_fp0_regnum (current_gdbarch); for (i = 0; i < len; i += 4) if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) regcache_raw_write (regcache, regnum++, @@ -1330,7 +1333,8 @@ sh64_show_media_regs (struct frame_info *frame) printf_filtered ("PC=%s SR=%016llx \n", - paddr (get_frame_register_unsigned (frame, PC_REGNUM)), + paddr (get_frame_register_unsigned (frame, + gdbarch_pc_regnum (current_gdbarch))), (long long) get_frame_register_unsigned (frame, SR_REGNUM)); printf_filtered @@ -1356,14 +1360,22 @@ sh64_show_media_regs (struct frame_info *frame) printf_filtered ("FR%d-FR%d %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", i, i + 7, - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 0), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 1), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 2), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 3), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 4), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 5), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 6), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 7)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 0), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 1), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 2), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 3), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 4), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 5), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 6), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 7)); } static void @@ -1402,14 +1414,22 @@ sh64_show_compact_regs (struct frame_info *frame) printf_filtered ("FR%d-FR%d %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", i, i + 7, - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 0), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 1), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 2), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 3), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 4), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 5), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 6), - (long) get_frame_register_unsigned (frame, FP0_REGNUM + i + 7)); + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 0), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 1), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 2), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 3), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 4), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 5), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 6), + (long) get_frame_register_unsigned + (frame, gdbarch_fp0_regnum (current_gdbarch) + i + 7)); } /* FIXME!!! This only shows the registers for shmedia, excluding the @@ -1505,7 +1525,7 @@ sh64_build_float_register_type (int high) static struct type * sh64_register_type (struct gdbarch *gdbarch, int reg_nr) { - if ((reg_nr >= FP0_REGNUM + if ((reg_nr >= gdbarch_fp0_regnum (current_gdbarch) && reg_nr <= FP_LAST_REGNUM) || (reg_nr >= FP0_C_REGNUM && reg_nr <= FP_LAST_C_REGNUM)) @@ -1974,7 +1994,10 @@ sh64_do_fp_register (struct gdbarch *gdbarch, struct ui_file *file, int j; /* Allocate space for the float. */ - raw_buffer = (unsigned char *) alloca (register_size (gdbarch, FP0_REGNUM)); + raw_buffer = (unsigned char *) alloca + (register_size (gdbarch, + gdbarch_fp0_regnum + (current_gdbarch))); /* Get the data in raw format. */ if (!frame_register_read (frame, regnum, raw_buffer)) @@ -2161,7 +2184,8 @@ sh64_media_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file, regnum ++; } else - regnum += FP_LAST_REGNUM - FP0_REGNUM; /* skip FP regs */ + regnum += FP_LAST_REGNUM - gdbarch_fp0_regnum (current_gdbarch); + /* skip FP regs */ } else { @@ -2284,7 +2308,8 @@ sh64_frame_cache (struct frame_info *next_frame, void **this_cache) setup yet. Try to reconstruct the base address for the stack frame by looking at the stack pointer. For truly "frameless" functions this might work too. */ - cache->base = frame_unwind_register_unsigned (next_frame, SP_REGNUM); + cache->base = frame_unwind_register_unsigned + (next_frame, gdbarch_sp_regnum (current_gdbarch)); } /* Now that we have the base address for the stack frame we can @@ -2310,7 +2335,7 @@ sh64_frame_prev_register (struct frame_info *next_frame, void **this_cache, gdb_assert (regnum >= 0); - if (regnum == SP_REGNUM && cache->saved_sp) + if (regnum == gdbarch_sp_regnum (current_gdbarch) && cache->saved_sp) { *optimizedp = 0; *lvalp = not_lval; @@ -2320,7 +2345,8 @@ sh64_frame_prev_register (struct frame_info *next_frame, void **this_cache, { /* Store the value. */ store_unsigned_integer (valuep, - register_size (current_gdbarch, SP_REGNUM), + register_size (current_gdbarch, + gdbarch_sp_regnum (current_gdbarch)), cache->saved_sp); } return; @@ -2329,7 +2355,7 @@ sh64_frame_prev_register (struct frame_info *next_frame, void **this_cache, /* The PC of the previous frame is stored in the PR register of the current frame. Frob regnum so that we pull the value from the correct place. */ - if (regnum == PC_REGNUM) + if (regnum == gdbarch_pc_regnum (current_gdbarch)) regnum = PR_REGNUM; if (regnum < SIM_SH64_NR_REGS && cache->saved_regs[regnum] != -1) @@ -2393,13 +2419,15 @@ sh64_frame_sniffer (struct frame_info *next_frame) static CORE_ADDR sh64_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_unwind_register_unsigned (next_frame, SP_REGNUM); + return frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (current_gdbarch)); } static CORE_ADDR sh64_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_unwind_register_unsigned (next_frame, PC_REGNUM); + return frame_unwind_register_unsigned (next_frame, + gdbarch_pc_regnum (current_gdbarch)); } static struct frame_id diff --git a/gdb/shnbsd-nat.c b/gdb/shnbsd-nat.c index 6afa5734a92..3236bb7b1cf 100644 --- a/gdb/shnbsd-nat.c +++ b/gdb/shnbsd-nat.c @@ -37,7 +37,7 @@ /* Determine if PT_GETREGS fetches this register. */ #define GETREGS_SUPPLIES(regno) \ (((regno) >= R0_REGNUM && (regno) <= (R0_REGNUM + 15)) \ -|| (regno) == PC_REGNUM || (regno) == PR_REGNUM \ +|| (regno) == gdbarch_pc_regnum (current_gdbarch) || (regno) == PR_REGNUM \ || (regno) == MACH_REGNUM || (regno) == MACL_REGNUM \ || (regno) == SR_REGNUM) diff --git a/gdb/shnbsd-tdep.c b/gdb/shnbsd-tdep.c index 5108fc4ef6d..6fdf677e710 100644 --- a/gdb/shnbsd-tdep.c +++ b/gdb/shnbsd-tdep.c @@ -74,8 +74,10 @@ shnbsd_supply_gregset (const struct regset *regset, gdb_assert (len >= SHNBSD_SIZEOF_GREGS); - if (regnum == PC_REGNUM || regnum == -1) - regcache_raw_supply (regcache, PC_REGNUM, regs + (0 * 4)); + if (regnum == gdbarch_pc_regnum (current_gdbarch) || regnum == -1) + regcache_raw_supply (regcache, + gdbarch_pc_regnum (current_gdbarch), + regs + (0 * 4)); if (regnum == SR_REGNUM || regnum == -1) regcache_raw_supply (regcache, SR_REGNUM, regs + (1 * 4)); @@ -111,8 +113,9 @@ shnbsd_collect_gregset (const struct regset *regset, gdb_assert (len >= SHNBSD_SIZEOF_GREGS); - if (regnum == PC_REGNUM || regnum == -1) - regcache_raw_collect (regcache, PC_REGNUM, regs + (0 * 4)); + if (regnum == gdbarch_pc_regnum (current_gdbarch) || regnum == -1) + regcache_raw_collect (regcache, gdbarch_pc_regnum (current_gdbarch), + regs + (0 * 4)); if (regnum == SR_REGNUM || regnum == -1) regcache_raw_collect (regcache, SR_REGNUM, regs + (1 * 4)); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 79d4acce0ae..d4d5c3599fd 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1030,7 +1030,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, gdbarch_num_regs (current_gdbarch) + gdbarch_num_pseudo_regs (current_gdbarch), SYMBOL_PRINT_NAME (sym)); - SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ + SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch); + /* Known safe, though useless */ } SYMBOL_DOMAIN (sym) = VAR_DOMAIN; add_symbol_to_list (sym, &local_symbols); @@ -1048,7 +1049,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, gdbarch_num_regs (current_gdbarch) + gdbarch_num_pseudo_regs (current_gdbarch), SYMBOL_PRINT_NAME (sym)); - SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ + SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch); + /* Known safe, though useless */ } SYMBOL_DOMAIN (sym) = VAR_DOMAIN; if (within_function) @@ -1322,7 +1324,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, gdbarch_num_regs (current_gdbarch) + gdbarch_num_pseudo_regs (current_gdbarch), SYMBOL_PRINT_NAME (sym)); - SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ + SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch); + /* Known safe, though useless */ } SYMBOL_DOMAIN (sym) = VAR_DOMAIN; add_symbol_to_list (sym, &local_symbols); diff --git a/gdb/stack.c b/gdb/stack.c index f10882d92f4..aaeb1d1c209 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -840,13 +840,14 @@ frame_info (char *addr_exp, int from_tty) /* Name of the value returned by get_frame_pc(). Per comments, "pc" is not a good name. */ - if (PC_REGNUM >= 0) - /* OK, this is weird. The PC_REGNUM hardware register's value can + if (gdbarch_pc_regnum (current_gdbarch) >= 0) + /* OK, this is weird. The gdbarch_pc_regnum hardware register's value can easily not match that of the internal value returned by get_frame_pc(). */ - pc_regname = gdbarch_register_name (current_gdbarch, PC_REGNUM); + pc_regname = gdbarch_register_name (current_gdbarch, + gdbarch_pc_regnum (current_gdbarch)); else - /* But then, this is weird to. Even without PC_REGNUM, an + /* But then, this is weird to. Even without gdbarch_pc_regnum, an architectures will often have a hardware register called "pc", and that register's value, again, can easily not match get_frame_pc(). */ @@ -1021,22 +1022,26 @@ frame_info (char *addr_exp, int from_tty) at one stage the frame cached the previous frame's SP instead of its address, hence it was easiest to just display the cached value. */ - if (SP_REGNUM >= 0) + if (gdbarch_sp_regnum (current_gdbarch) >= 0) { /* Find out the location of the saved stack pointer with out actually evaluating it. */ - frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr, + frame_register_unwind (fi, gdbarch_sp_regnum (current_gdbarch), + &optimized, &lval, &addr, &realnum, NULL); if (!optimized && lval == not_lval) { gdb_byte value[MAX_REGISTER_SIZE]; CORE_ADDR sp; - frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr, + frame_register_unwind (fi, gdbarch_sp_regnum (current_gdbarch), + &optimized, &lval, &addr, &realnum, value); /* NOTE: cagney/2003-05-22: This is assuming that the stack pointer was packed as an unsigned integer. That may or may not be valid. */ - sp = extract_unsigned_integer (value, register_size (current_gdbarch, SP_REGNUM)); + sp = extract_unsigned_integer (value, + register_size (current_gdbarch, + gdbarch_sp_regnum (current_gdbarch))); printf_filtered (" Previous frame's sp is "); deprecated_print_address_numeric (sp, 1, gdb_stdout); printf_filtered ("\n"); @@ -1062,7 +1067,7 @@ frame_info (char *addr_exp, int from_tty) numregs = gdbarch_num_regs (current_gdbarch) + gdbarch_num_pseudo_regs (current_gdbarch); for (i = 0; i < numregs; i++) - if (i != SP_REGNUM + if (i != gdbarch_sp_regnum (current_gdbarch) && gdbarch_register_reggroup_p (current_gdbarch, i, all_reggroup)) { /* Find out the location of the saved register without diff --git a/gdb/std-regs.c b/gdb/std-regs.c index f1a1abc8fc6..16f0b8a4af1 100644 --- a/gdb/std-regs.c +++ b/gdb/std-regs.c @@ -56,8 +56,8 @@ value_of_builtin_frame_fp_reg (struct frame_info *frame, const void *baton) static struct value * value_of_builtin_frame_pc_reg (struct frame_info *frame, const void *baton) { - if (PC_REGNUM >= 0) - return value_of_register (PC_REGNUM, frame); + if (gdbarch_pc_regnum (current_gdbarch) >= 0) + return value_of_register (gdbarch_pc_regnum (current_gdbarch), frame); else { struct value *val = allocate_value (builtin_type_void_data_ptr); @@ -74,20 +74,16 @@ value_of_builtin_frame_pc_reg (struct frame_info *frame, const void *baton) static struct value * value_of_builtin_frame_sp_reg (struct frame_info *frame, const void *baton) { -#ifdef SP_REGNUM - if (SP_REGNUM >= 0) - return value_of_register (SP_REGNUM, frame); -#endif + if (gdbarch_sp_regnum (current_gdbarch) >= 0) + return value_of_register (gdbarch_sp_regnum (current_gdbarch), frame); error (_("Standard register ``$sp'' is not available for this target")); } static struct value * value_of_builtin_frame_ps_reg (struct frame_info *frame, const void *baton) { -#ifdef PS_REGNUM - if (PS_REGNUM >= 0) - return value_of_register (PS_REGNUM, frame); -#endif + if (gdbarch_ps_regnum (current_gdbarch) >= 0) + return value_of_register (gdbarch_ps_regnum (current_gdbarch), frame); error (_("Standard register ``$ps'' is not available for this target")); } diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index 7aa7dc33bbc..65e20b10234 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -940,13 +940,15 @@ v850_frame_sniffer (struct frame_info *next_frame) static CORE_ADDR v850_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_unwind_register_unsigned (next_frame, SP_REGNUM); + return frame_unwind_register_unsigned (next_frame, + gdbarch_sp_regnum (current_gdbarch)); } static CORE_ADDR v850_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) { - return frame_unwind_register_unsigned (next_frame, PC_REGNUM); + return frame_unwind_register_unsigned (next_frame, + gdbarch_pc_regnum (current_gdbarch)); } static struct frame_id diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c index c5627c79fb0..d312d17bc69 100644 --- a/gdb/win32-nat.c +++ b/gdb/win32-nat.c @@ -1318,7 +1318,8 @@ win32_resume (ptid_t ptid, int step, enum target_signal sig) if (step) { /* Single step by setting t bit */ - win32_fetch_inferior_registers (get_current_regcache (), PS_REGNUM); + win32_fetch_inferior_registers (get_current_regcache (), + gdbarch_ps_regnum (current_gdbarch)); th->context.EFlags |= FLAG_TRACE_BIT; } diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 0db4935665d..f8024a7a73a 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -209,7 +209,7 @@ xtensa_register_type (struct gdbarch *gdbarch, int regnum) || (regnum >= A0_BASE && regnum < A0_BASE + 16)) return builtin_type_int; - if (regnum == PC_REGNUM || regnum == A1_REGNUM) + if (regnum == gdbarch_pc_regnum (current_gdbarch) || regnum == A1_REGNUM) return lookup_pointer_type (builtin_type_void); /* Return the stored type for all other registers. */ @@ -748,10 +748,13 @@ xtensa_supply_gregset (const struct regset *regset, DEBUGTRACE ("xtensa_supply_gregset (..., regnum==%d, ...) \n", regnum); - if (regnum == PC_REGNUM || regnum == -1) - regcache_raw_supply (rc, PC_REGNUM, (char *) ®s->pc); - if (regnum == PS_REGNUM || regnum == -1) - regcache_raw_supply (rc, PS_REGNUM, (char *) ®s->ps); + if (regnum == gdbarch_pc_regnum (current_gdbarch) || regnum == -1) + regcache_raw_supply (rc, + gdbarch_pc_regnum (current_gdbarch), + (char *) ®s->pc); + if (regnum == gdbarch_ps_regnum (current_gdbarch) || regnum == -1) + regcache_raw_supply (rc, gdbarch_ps_regnum (current_gdbarch), + (char *) ®s->ps); if (regnum == WB_REGNUM || regnum == -1) regcache_raw_supply (rc, WB_REGNUM, (char *) ®s->windowbase); if (regnum == WS_REGNUM || regnum == -1) @@ -868,7 +871,7 @@ xtensa_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame) DEBUGTRACE ("xtensa_unwind_pc (next_frame = %p)\n", next_frame); - frame_unwind_register (next_frame, PC_REGNUM, buf); + frame_unwind_register (next_frame, gdbarch_pc_regnum (current_gdbarch), buf); DEBUGINFO ("[xtensa_unwind_pc] pc = 0x%08x\n", (unsigned int) extract_typed_address (buf, builtin_type_void_func_ptr)); @@ -918,8 +921,10 @@ xtensa_frame_cache (struct frame_info *next_frame, void **this_cache) /* Get windowbase, windowstart, ps, and pc. */ wb = frame_unwind_register_unsigned (next_frame, WB_REGNUM); ws = frame_unwind_register_unsigned (next_frame, WS_REGNUM); - ps = frame_unwind_register_unsigned (next_frame, PS_REGNUM); - pc = frame_unwind_register_unsigned (next_frame, PC_REGNUM); + ps = frame_unwind_register_unsigned (next_frame, + gdbarch_ps_regnum (current_gdbarch)); + pc = frame_unwind_register_unsigned (next_frame, + gdbarch_pc_regnum (current_gdbarch)); op1 = read_memory_integer (pc, 1); if (XTENSA_IS_ENTRY (op1) || !windowing_enabled (ps)) @@ -1062,9 +1067,9 @@ xtensa_frame_prev_register (struct frame_info *next_frame, } else if (regnum == WB_REGNUM) saved_reg = cache->wb; - else if (regnum == PC_REGNUM) + else if (regnum == gdbarch_pc_regnum (current_gdbarch)) saved_reg = cache->pc; - else if (regnum == PS_REGNUM) + else if (regnum == gdbarch_ps_regnum (current_gdbarch)) saved_reg = cache->ps; else done = 0; @@ -1169,7 +1174,8 @@ xtensa_extract_return_value (struct type *type, gdb_assert(len > 0); /* First, we have to find the caller window in the register file. */ - regcache_raw_read_unsigned (regcache, PC_REGNUM, &pc); + regcache_raw_read_unsigned (regcache, + gdbarch_pc_regnum (current_gdbarch), &pc); callsize = extract_call_winsize (pc); /* On Xtensa, we can return up to 4 words (or 2 when called by call12). */ @@ -1212,7 +1218,8 @@ xtensa_store_return_value (struct type *type, DEBUGTRACE ("xtensa_store_return_value (...)\n"); regcache_raw_read_unsigned (regcache, WB_REGNUM, &wb); - regcache_raw_read_unsigned (regcache, PC_REGNUM, &pc); + regcache_raw_read_unsigned (regcache, + gdbarch_pc_regnum (current_gdbarch), &pc); callsize = extract_call_winsize (pc); if (len > (callsize > 8 ? 8 : 16)) @@ -1492,10 +1499,12 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, saved in the dummy frame, so we can savely overwrite A0 here. */ ra = (bp_addr & 0x3fffffff) | 0x40000000; - regcache_raw_read (regcache, PS_REGNUM, buf); + regcache_raw_read (regcache, gdbarch_ps_regnum (current_gdbarch), buf); ps = extract_unsigned_integer (buf, 4) & ~0x00030000; regcache_cooked_write_unsigned (regcache, A4_REGNUM, ra); - regcache_cooked_write_unsigned (regcache, PS_REGNUM, ps | 0x00010000); + regcache_cooked_write_unsigned (regcache, + gdbarch_ps_regnum (current_gdbarch), + ps | 0x00010000); /* Set new stack pointer and return it. */ regcache_cooked_write_unsigned (regcache, A1_REGNUM, sp); |