Skip to content

Commit

Permalink
gdb/riscv: use register name enum values in riscv-linux-nat.c
Browse files Browse the repository at this point in the history
There were a few places where we were using integer values rather than
the RISCV_*_REGNUM constants defined in riscv-tdep.h.  This commit
replaces 0 with RISCV_ZERO_REGNUM and 32 with RISCV_PC_REGNUM in a few
places.

There should be no user visible changes after this commit.
  • Loading branch information
T-J-Teru committed Aug 9, 2022
1 parent 298d6e7 commit 8cf61a3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gdb/riscv-linux-nat.c
Original file line number Diff line number Diff line change
@@ -66,17 +66,17 @@ supply_gregset_regnum (struct regcache *regcache, const prgregset_t *gregs,
regcache->raw_supply (i, regp + i);

/* GDB stores PC in reg 32. Linux kernel stores it in reg 0. */
regcache->raw_supply (32, regp + 0);
regcache->raw_supply (RISCV_PC_REGNUM, regp + 0);

/* Fill the inaccessible zero register with zero. */
regcache->raw_supply_zeroed (0);
regcache->raw_supply_zeroed (RISCV_ZERO_REGNUM);
}
else if (regnum == RISCV_ZERO_REGNUM)
regcache->raw_supply_zeroed (0);
regcache->raw_supply_zeroed (RISCV_ZERO_REGNUM);
else if (regnum > RISCV_ZERO_REGNUM && regnum < RISCV_PC_REGNUM)
regcache->raw_supply (regnum, regp + regnum);
else if (regnum == RISCV_PC_REGNUM)
regcache->raw_supply (32, regp + 0);
regcache->raw_supply (RISCV_PC_REGNUM, regp + 0);
}

/* Copy all general purpose registers from regset GREGS into REGCACHE. */
@@ -147,15 +147,15 @@ fill_gregset (const struct regcache *regcache, prgregset_t *gregs, int regnum)
for (int i = RISCV_ZERO_REGNUM + 1; i < RISCV_PC_REGNUM; i++)
regcache->raw_collect (i, regp + i);

regcache->raw_collect (32, regp + 0);
regcache->raw_collect (RISCV_PC_REGNUM, regp + 0);
}
else if (regnum == RISCV_ZERO_REGNUM)
/* Nothing to do here. */
;
else if (regnum > RISCV_ZERO_REGNUM && regnum < RISCV_PC_REGNUM)
regcache->raw_collect (regnum, regp + regnum);
else if (regnum == RISCV_PC_REGNUM)
regcache->raw_collect (32, regp + 0);
regcache->raw_collect (RISCV_PC_REGNUM, regp + 0);
}

/* Copy floating point register REGNUM (or all fp regs if REGNUM == -1)

0 comments on commit 8cf61a3

Please sign in to comment.