From 2ac058fda90201dbc931cd0d2d94c1b4f62d78a8 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 1 Feb 1999 21:17:19 +0000 Subject: Allow PPC users to select which PPC/RS6000 variant they're debugging at run-time. At the moment, the only thing this affects is the set of registers visible. * config/rs6000/tm-rs6000.h (REGISTER_NAME): Define this as a call to the function rs6000_register_name. (rs6000_register_name): Include extern decl. (NUM_REGS): Bump to 183. What's the right way to do this? (FIRST_UISA_SP_REGNUM, LAST_UISA_SP_REGNUM): Renamed from FIRST_SP_REGNUM, LAST_SP_REGNUM. (REGISTER_BYTES): Recompute this. * rs6000-tdep.c: Renamed all uses of FIRST_SP_REGNUM and LAST_SP_REGNUM to FIRST_UISA_SP_REGNUM and LAST_UISA_SP_REGNUM, with some concomitant formatting changes. #include "gdbcmd.h", so we can define commands here. (struct variant): New structure. (COMMON_UISA_REG_NAMES, PPC_UISA_SPR_NAMES, PPC_SEGMENT_REG_NAMES, PPC_32_OEA_SPR_NAMES, num_registers): New macros. (register_names_rs6000, register_names_uisa, register_names_403, register_names_403GC, register_names_505, register_names_860, register_names_601, register_names_602, register_names_603, register_names_604, register_names_750, variants): New variables. (rs6000_register_name, install_variant, find_variant_by_name, install_variant_by_name, list_variants, show_current_variant, set_processor, show_processor): New functions. (_initialize_rs6000_tdep): Define new commands `set processor' and `show processor', and call install_variant_by_name to set the default variant. * rs6000-nat.c: Renamed all uses of FIRST_SP_REGNUM and LAST_SP_REGNUM to FIRST_UISA_SP_REGNUM and LAST_UISA_SP_REGNUM, with some concomitant formatting changes. * configure.in: Accept the `--with-cpu' flag, to specify a default processor variant. * acconfig.h: Provide a blurb for TARGET_CPU_DEFAULT, which is set by configure's `--with-cpu' flag. * config.in, configure: Regenerated. --- gdb/rs6000-nat.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'gdb/rs6000-nat.c') diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index b61af3d..c74a36f 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -110,8 +110,8 @@ fetch_inferior_registers (regno) FPR0+ii, 0); /* read special registers. */ - for (ii=0; ii <= LAST_SP_REGNUM-FIRST_SP_REGNUM; ++ii) - *(int*)®isters[REGISTER_BYTE (FIRST_SP_REGNUM+ii)] = + for (ii=0; ii <= LAST_UISA_SP_REGNUM-FIRST_UISA_SP_REGNUM; ++ii) + *(int*)®isters[REGISTER_BYTE (FIRST_UISA_SP_REGNUM+ii)] = ptrace (PT_READ_GPR, inferior_pid, (PTRACE_ARG3_TYPE) special_regs[ii], 0, 0); @@ -130,13 +130,16 @@ fetch_inferior_registers (regno) (PTRACE_ARG3_TYPE) ®isters [REGISTER_BYTE (regno)], (regno-FP0_REGNUM+FPR0), 0); } - else if (regno <= LAST_SP_REGNUM) { /* a special register */ + else if (regno <= LAST_UISA_SP_REGNUM) { /* a special register */ *(int*)®isters[REGISTER_BYTE (regno)] = ptrace (PT_READ_GPR, inferior_pid, - (PTRACE_ARG3_TYPE) special_regs[regno-FIRST_SP_REGNUM], 0, 0); + (PTRACE_ARG3_TYPE) special_regs[regno-FIRST_UISA_SP_REGNUM], + 0, 0); } else - fprintf_unfiltered (gdb_stderr, "gdb error: register no %d not implemented.\n", regno); + fprintf_unfiltered (gdb_stderr, + "gdb error: register no %d not implemented.\n", + regno); register_valid [regno] = 1; } @@ -190,11 +193,12 @@ store_inferior_registers (regno) } /* write special registers. */ - for (ii=0; ii <= LAST_SP_REGNUM-FIRST_SP_REGNUM; ++ii) + for (ii=0; ii <= LAST_UISA_SP_REGNUM-FIRST_UISA_SP_REGNUM; ++ii) { ptrace (PT_WRITE_GPR, inferior_pid, (PTRACE_ARG3_TYPE) special_regs[ii], - *(int*)®isters[REGISTER_BYTE (FIRST_SP_REGNUM+ii)], 0); + *(int*)®isters[REGISTER_BYTE (FIRST_UISA_SP_REGNUM+ii)], + 0); if (errno) { perror ("ptrace write_gpr"); @@ -218,15 +222,17 @@ store_inferior_registers (regno) regno - FP0_REGNUM + FPR0, 0); } - else if (regno <= LAST_SP_REGNUM) /* a special register */ + else if (regno <= LAST_UISA_SP_REGNUM) /* a special register */ { ptrace (PT_WRITE_GPR, inferior_pid, - (PTRACE_ARG3_TYPE) special_regs [regno-FIRST_SP_REGNUM], + (PTRACE_ARG3_TYPE) special_regs [regno-FIRST_UISA_SP_REGNUM], *(int*)®isters[REGISTER_BYTE (regno)], 0); } else - fprintf_unfiltered (gdb_stderr, "Gdb error: register no %d not implemented.\n", regno); + fprintf_unfiltered (gdb_stderr, + "Gdb error: register no %d not implemented.\n", + regno); if (errno) { @@ -248,8 +254,9 @@ exec_one_dummy_insn () int status, pid; CORE_ADDR prev_pc; - /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We assume that - this address will never be executed again by the real code. */ + /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We + assume that this address will never be executed again by the real + code. */ target_insert_breakpoint (DUMMY_INSN_ADDR, shadow_contents); @@ -294,8 +301,9 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr) /* then comes special registes. They are supposed to be in the same order in gdb template and bfd `.reg' section. */ core_reg_sect += (32 * 4); - memcpy (®isters [REGISTER_BYTE (FIRST_SP_REGNUM)], core_reg_sect, - (LAST_SP_REGNUM - FIRST_SP_REGNUM + 1) * 4); + memcpy (®isters [REGISTER_BYTE (FIRST_UISA_SP_REGNUM)], + core_reg_sect, + (LAST_UISA_SP_REGNUM - FIRST_UISA_SP_REGNUM + 1) * 4); } /* fetch floating point registers from register section 2 in core bfd. */ @@ -303,7 +311,9 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr) memcpy (®isters [REGISTER_BYTE (FP0_REGNUM)], core_reg_sect, 32 * 8); else - fprintf_unfiltered (gdb_stderr, "Gdb error: unknown parameter to fetch_core_registers().\n"); + fprintf_unfiltered + (gdb_stderr, + "Gdb error: unknown parameter to fetch_core_registers().\n"); } /* handle symbol translation on vmapping */ -- cgit v1.1