aboutsummaryrefslogtreecommitdiff
path: root/gdb/score-tdep.c
diff options
context:
space:
mode:
authorAndreas Arnez <arnez@linux.vnet.ibm.com>2014-07-21 15:33:45 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2014-08-07 17:31:50 +0200
commitc5741217d390041fc43ca83ad00b07355d40e9ad (patch)
tree5a2edaadbeb286bf6c1ff5fcb86d4fc6d78f5a5f /gdb/score-tdep.c
parent81580573ba47d0047d76d4fddabe150b49ee3b54 (diff)
downloadfsf-binutils-gdb-c5741217d390041fc43ca83ad00b07355d40e9ad.zip
fsf-binutils-gdb-c5741217d390041fc43ca83ad00b07355d40e9ad.tar.gz
fsf-binutils-gdb-c5741217d390041fc43ca83ad00b07355d40e9ad.tar.bz2
SCORE: Fill 'collect_regset' in regset structure.
Also rewrite the 'supply_regset' method, making it platform independent. To avoid code duplication, move the logic for both to a register map in regcache_map_entry format.
Diffstat (limited to 'gdb/score-tdep.c')
-rw-r--r--gdb/score-tdep.c86
1 files changed, 40 insertions, 46 deletions
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index 977216d..d61faf0 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -1397,59 +1397,52 @@ score_prologue_frame_base_sniffer (struct frame_info *this_frame)
return &score_prologue_frame_base;
}
-/* Core file support (dirty hack)
-
- The core file MUST be generated by GNU/Linux on S+core. */
+/* Core file support. */
+
+static const struct regcache_map_entry score7_linux_gregmap[] =
+ {
+ /* FIXME: According to the current Linux kernel, r0 is preceded by
+ 9 rather than 7 words. */
+ { 7, REGCACHE_MAP_SKIP, 4 },
+ { 32, 0, 4 }, /* r0 ... r31 */
+ { 1, 55, 4 }, /* CEL */
+ { 1, 54, 4 }, /* CEH */
+ { 1, 53, 4 }, /* sr0, i.e. cnt or COUNTER */
+ { 1, 52, 4 }, /* sr1, i.e. lcr or LDCR */
+ { 1, 51, 4 }, /* sr2, i.e. scr or STCR */
+ { 1, 49, 4 }, /* PC (same slot as EPC) */
+ { 1, 38, 4 }, /* EMA */
+ { 1, 32, 4 }, /* PSR */
+ { 1, 34, 4 }, /* ECR */
+ { 1, 33, 4 }, /* COND */
+ { 0 }
+ };
+
+#define SCORE7_LINUX_EPC_OFFSET (44 * 4)
+#define SCORE7_LINUX_SIZEOF_GREGSET (49 * 4)
static void
score7_linux_supply_gregset(const struct regset *regset,
- struct regcache *regcache,
- int regnum, const void *gregs_buf, size_t len)
+ struct regcache *regcache,
+ int regnum, const void *buf,
+ size_t size)
{
- int regno;
- elf_gregset_t *gregs;
-
- gdb_assert (regset != NULL);
- gdb_assert ((regcache != NULL) && (gregs_buf != NULL));
-
- gregs = (elf_gregset_t *) gregs_buf;
-
- for (regno = 0; regno < 32; regno++)
- if (regnum == -1 || regnum == regno)
- regcache_raw_supply (regcache, regno, gregs->regs + regno);
-
- {
- struct sreg {
- int regnum;
- void *buf;
- } sregs [] = {
- { 55, &(gregs->cel) }, /* CEL */
- { 54, &(gregs->ceh) }, /* CEH */
- { 53, &(gregs->sr0) }, /* sr0, i.e. cnt or COUNTER */
- { 52, &(gregs->sr1) }, /* sr1, i.e. lcr or LDCR */
- { 51, &(gregs->sr1) }, /* sr2, i.e. scr or STCR */
-
- /* Exception occured at this address, exactly the PC we want */
- { 49, &(gregs->cp0_epc) }, /* PC */
-
- { 38, &(gregs->cp0_ema) }, /* EMA */
- { 37, &(gregs->cp0_epc) }, /* EPC */
- { 34, &(gregs->cp0_ecr) }, /* ECR */
- { 33, &(gregs->cp0_condition) }, /* COND */
- { 32, &(gregs->cp0_psr) }, /* PSR */
- };
-
- for (regno = 0; regno < sizeof(sregs)/sizeof(sregs[0]); regno++)
- if (regnum == -1 || regnum == sregs[regno].regnum)
- regcache_raw_supply (regcache,
- sregs[regno].regnum, sregs[regno].buf);
- }
+ regcache_supply_regset (regset, regcache, regnum, buf, size);
+
+ /* Supply the EPC from the same slot as the PC. Note that the
+ collect function will store the PC in that slot. */
+ if ((regnum == -1 || regnum == SCORE_EPC_REGNUM)
+ && size >= SCORE7_LINUX_EPC_OFFSET + 4)
+ regcache_raw_supply (regcache, SCORE_EPC_REGNUM,
+ (const gdb_byte *) buf
+ + SCORE7_LINUX_EPC_OFFSET);
}
static const struct regset score7_linux_gregset =
{
- NULL,
- score7_linux_supply_gregset, NULL
+ score7_linux_gregmap,
+ score7_linux_supply_gregset,
+ regcache_collect_regset
};
/* Return the appropriate register set from the core section identified
@@ -1462,7 +1455,8 @@ score7_linux_regset_from_core_section(struct gdbarch *gdbarch,
gdb_assert (gdbarch != NULL);
gdb_assert (sect_name != NULL);
- if (strcmp(sect_name, ".reg") == 0 && sect_size == sizeof(elf_gregset_t))
+ if (strcmp(sect_name, ".reg") == 0
+ && sect_size == SCORE7_LINUX_SIZEOF_GREGSET)
return &score7_linux_gregset;
return NULL;