aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2002-07-26 22:26:44 +0000
committerKevin Buettner <kevinb@redhat.com>2002-07-26 22:26:44 +0000
commitdd7be90a81ad73ea71516586b8d2d52e58bfcb97 (patch)
treeec1cc653b130ade267a9c2b5ea3bc7f8d184f208
parentfb39dac1ef45db850a7647f4bf1da52ee5900543 (diff)
downloadgdb-dd7be90a81ad73ea71516586b8d2d52e58bfcb97.zip
gdb-dd7be90a81ad73ea71516586b8d2d52e58bfcb97.tar.gz
gdb-dd7be90a81ad73ea71516586b8d2d52e58bfcb97.tar.bz2
Eliminate FIRST_UISA_SP_REGNUM and LAST_UISA_SP_REGNUM.
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/config/rs6000/tm-rs6000.h5
-rw-r--r--gdb/rs6000-nat.c134
3 files changed, 101 insertions, 54 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d22575f..dbdb852 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,19 @@
+2002-07-26 Kevin Buettner <kevinb@redhat.com>
+
+ * rs6000-nat.c (language.h): Include.
+ (special_regs): Delete this array.
+ (regmap): New function.
+ (fetch_register, store_register): Use regmap() to map gdb
+ register numbers to ptrace register numbers. Also, use
+ outputs from regmap() to make decisions regarding type of
+ ptrace() call to make. In particular, don't compare against
+ FIRST_UISA_SP_REGNUM or LAST_UISA_SP_REGNUM.
+ (fetch_inferior_registers, store_inferior_registers): Where
+ possible, obtain register numbers from tdep struct. Don't
+ refer to FIRST_UISA_SP_REGNUM or LAST_UISA_SP_REGNUM.
+ * config/rs6000/tm-rs6000.h (FIRST_UISA_SP_REGNUM)
+ (LAST_UISA_SP_REGNUM): Delete.
+
2002-07-25 Kevin Buettner <kevinb@redhat.com>
* rs6000-nat.c (ppc-tdep.h): Include.
diff --git a/gdb/config/rs6000/tm-rs6000.h b/gdb/config/rs6000/tm-rs6000.h
index 202ac77..ea0c073 100644
--- a/gdb/config/rs6000/tm-rs6000.h
+++ b/gdb/config/rs6000/tm-rs6000.h
@@ -81,11 +81,6 @@ extern void aix_process_linenos (void);
#define FP0_REGNUM 32 /* Floating point register 0 */
#define FPLAST_REGNUM 63 /* Last floating point register */
-/* These #defines are used to parse core files and talk to ptrace, so they
- must remain fixed. */
-#define FIRST_UISA_SP_REGNUM 64 /* first special register number */
-#define LAST_UISA_SP_REGNUM 70 /* last special register number */
-
/* Define other aspects of the stack frame. */
#define INIT_FRAME_PC_FIRST(fromleaf, prev) \
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 95833c6..51a66bd 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -32,6 +32,7 @@
#include "gdb-stabs.h"
#include "regcache.h"
#include "arch-utils.h"
+#include "language.h" /* for local_hex_string(). */
#include "ppc-tdep.h"
#include <sys/ptrace.h>
@@ -145,18 +146,41 @@ static void exec_one_dummy_insn (void);
extern void
fixup_breakpoints (CORE_ADDR low, CORE_ADDR high, CORE_ADDR delta);
-/* Conversion from gdb-to-system special purpose register numbers. */
+/* Given REGNO, a gdb register number, return the corresponding
+ number suitable for use as a ptrace() parameter. Return -1 if
+ there's no suitable mapping. Also, set the int pointed to by
+ ISFLOAT to indicate whether REGNO is a floating point register. */
-static int special_regs[] =
+static int
+regmap (int regno, int *isfloat)
{
- IAR, /* PC_REGNUM */
- MSR, /* PS_REGNUM */
- CR, /* CR_REGNUM */
- LR, /* LR_REGNUM */
- CTR, /* CTR_REGNUM */
- XER, /* XER_REGNUM */
- MQ /* MQ_REGNUM */
-};
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+ *isfloat = 0;
+ if (tdep->ppc_gp0_regnum <= regno && regno <= tdep->ppc_gplast_regnum)
+ return regno;
+ else if (FP0_REGNUM <= regno && regno <= FPLAST_REGNUM)
+ {
+ *isfloat = 1;
+ return regno - FP0_REGNUM + FPR0;
+ }
+ else if (regno == PC_REGNUM)
+ return IAR;
+ else if (regno == tdep->ppc_ps_regnum)
+ return MSR;
+ else if (regno == tdep->ppc_cr_regnum)
+ return CR;
+ else if (regno == tdep->ppc_lr_regnum)
+ return LR;
+ else if (regno == tdep->ppc_ctr_regnum)
+ return CTR;
+ else if (regno == tdep->ppc_xer_regnum)
+ return XER;
+ else if (tdep->ppc_mq_regnum >= 0 && regno == tdep->ppc_mq_regnum)
+ return MQ;
+ else
+ return -1;
+}
/* Call ptrace(REQ, ID, ADDR, DATA, BUF). */
@@ -194,35 +218,30 @@ static void
fetch_register (int regno)
{
int *addr = alloca (MAX_REGISTER_RAW_SIZE);
- int nr;
+ int nr, isfloat;
/* Retrieved values may be -1, so infer errors from errno. */
errno = 0;
+ nr = regmap (regno, &isfloat);
+
/* Floating-point registers. */
- if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
- {
- nr = regno - FP0_REGNUM + FPR0;
- rs6000_ptrace32 (PT_READ_FPR, PIDGET (inferior_ptid), addr, nr, 0);
- }
+ if (isfloat)
+ rs6000_ptrace32 (PT_READ_FPR, PIDGET (inferior_ptid), addr, nr, 0);
/* Bogus register number. */
- else if (regno > LAST_UISA_SP_REGNUM)
+ else if (nr < 0)
{
if (regno >= NUM_REGS)
fprintf_unfiltered (gdb_stderr,
"gdb error: register no %d not implemented.\n",
regno);
+ return;
}
/* Fixed-point registers. */
else
{
- if (regno >= FIRST_UISA_SP_REGNUM)
- nr = special_regs[regno - FIRST_UISA_SP_REGNUM];
- else
- nr = regno;
-
if (!ARCH64 ())
*addr = rs6000_ptrace32 (PT_READ_GPR, PIDGET (inferior_ptid), (int *)nr, 0, 0);
else
@@ -256,7 +275,7 @@ static void
store_register (int regno)
{
int *addr = alloca (MAX_REGISTER_RAW_SIZE);
- int nr;
+ int nr, isfloat;
/* Fetch the register's value from the register cache. */
regcache_collect (regno, addr);
@@ -264,15 +283,14 @@ store_register (int regno)
/* -1 can be a successful return value, so infer errors from errno. */
errno = 0;
+ nr = regmap (regno, &isfloat);
+
/* Floating-point registers. */
- if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
- {
- nr = regno - FP0_REGNUM + FPR0;
- rs6000_ptrace32 (PT_WRITE_FPR, PIDGET (inferior_ptid), addr, nr, 0);
- }
+ if (isfloat)
+ rs6000_ptrace32 (PT_WRITE_FPR, PIDGET (inferior_ptid), addr, nr, 0);
/* Bogus register number. */
- else if (regno > LAST_UISA_SP_REGNUM)
+ else if (nr < 0)
{
if (regno >= NUM_REGS)
fprintf_unfiltered (gdb_stderr,
@@ -291,11 +309,6 @@ store_register (int regno)
(%sp). */
exec_one_dummy_insn ();
- if (regno >= FIRST_UISA_SP_REGNUM)
- nr = special_regs[regno - FIRST_UISA_SP_REGNUM];
- else
- nr = regno;
-
/* The PT_WRITE_GPR operation is rather odd. For 32-bit inferiors,
the register's value is passed by value, but for 64-bit inferiors,
the address of a buffer containing the value is passed. */
@@ -332,17 +345,29 @@ fetch_inferior_registers (int regno)
else
{
- /* read 32 general purpose registers. */
- for (regno = 0; regno < 32; regno++)
- fetch_register (regno);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+ /* Read 32 general purpose registers. */
+ for (regno = tdep->ppc_gp0_regnum;
+ regno <= tdep->ppc_gplast_regnum;
+ regno++)
+ {
+ fetch_register (regno);
+ }
- /* read general purpose floating point registers. */
+ /* Read general purpose floating point registers. */
for (regno = FP0_REGNUM; regno <= FPLAST_REGNUM; regno++)
fetch_register (regno);
- /* read special registers. */
- for (regno = FIRST_UISA_SP_REGNUM; regno <= LAST_UISA_SP_REGNUM; regno++)
- fetch_register (regno);
+ /* Read special registers. */
+ fetch_register (PC_REGNUM);
+ fetch_register (tdep->ppc_ps_regnum);
+ fetch_register (tdep->ppc_cr_regnum);
+ fetch_register (tdep->ppc_lr_regnum);
+ fetch_register (tdep->ppc_ctr_regnum);
+ fetch_register (tdep->ppc_xer_regnum);
+ if (tdep->ppc_mq_regnum >= 0)
+ fetch_register (tdep->ppc_mq_regnum);
}
}
@@ -358,18 +383,29 @@ store_inferior_registers (int regno)
else
{
- /* write general purpose registers first! */
- for (regno = GPR0; regno <= GPR31; regno++)
- store_register (regno);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+
+ /* Write general purpose registers first. */
+ for (regno = tdep->ppc_gp0_regnum;
+ regno <= tdep->ppc_gplast_regnum;
+ regno++)
+ {
+ store_register (regno);
+ }
- /* write floating point registers now. */
+ /* Write floating point registers. */
for (regno = FP0_REGNUM; regno <= FPLAST_REGNUM; regno++)
store_register (regno);
- /* write special registers. */
-
- for (regno = FIRST_UISA_SP_REGNUM; regno <= LAST_UISA_SP_REGNUM; regno++)
- store_register (regno);
+ /* Write special registers. */
+ store_register (PC_REGNUM);
+ store_register (tdep->ppc_ps_regnum);
+ store_register (tdep->ppc_cr_regnum);
+ store_register (tdep->ppc_lr_regnum);
+ store_register (tdep->ppc_ctr_regnum);
+ store_register (tdep->ppc_xer_regnum);
+ if (tdep->ppc_mq_regnum >= 0)
+ store_register (tdep->ppc_mq_regnum);
}
}