arm: Correctly access the stack pointer in GDB
We curently use INTREG_X31 instead of INTREG_SPX when accessing the stack pointer in GDB. gem5 normally uses INTREG_SPX to access the stack pointer, which gets mapped to the stack pointer corresponding (INTREG_SPn) to the current exception level. This changeset updates the GDB interface to use SPX instead of X31 (which is always zero) when transfering CPU state to gdb.
This commit is contained in:
parent
34dcd90b61
commit
804b11a3ed
2 changed files with 10 additions and 4 deletions
|
@ -204,9 +204,10 @@ RemoteGDB::getregs()
|
||||||
memset(gdbregs.regs, 0, gdbregs.bytes());
|
memset(gdbregs.regs, 0, gdbregs.bytes());
|
||||||
|
|
||||||
if (inAArch64(context)) { // AArch64
|
if (inAArch64(context)) { // AArch64
|
||||||
// x0-x31
|
// x0-x30
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 31; ++i)
|
||||||
gdbregs.regs64[GDB64_X0 + i] = context->readIntReg(INTREG_X0 + i);
|
gdbregs.regs64[GDB64_X0 + i] = context->readIntReg(INTREG_X0 + i);
|
||||||
|
gdbregs.regs64[GDB64_SPX] = context->readIntReg(INTREG_SPX);
|
||||||
// pc
|
// pc
|
||||||
gdbregs.regs64[GDB64_PC] = context->pcState().pc();
|
gdbregs.regs64[GDB64_PC] = context->pcState().pc();
|
||||||
// cpsr
|
// cpsr
|
||||||
|
@ -262,13 +263,17 @@ RemoteGDB::setregs()
|
||||||
|
|
||||||
DPRINTF(GDBAcc, "setregs in remotegdb \n");
|
DPRINTF(GDBAcc, "setregs in remotegdb \n");
|
||||||
if (inAArch64(context)) { // AArch64
|
if (inAArch64(context)) { // AArch64
|
||||||
// x0-x31
|
// x0-x30
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 31; ++i)
|
||||||
context->setIntReg(INTREG_X0 + i, gdbregs.regs64[GDB64_X0 + i]);
|
context->setIntReg(INTREG_X0 + i, gdbregs.regs64[GDB64_X0 + i]);
|
||||||
// pc
|
// pc
|
||||||
context->pcState(gdbregs.regs64[GDB64_PC]);
|
context->pcState(gdbregs.regs64[GDB64_PC]);
|
||||||
// cpsr
|
// cpsr
|
||||||
context->setMiscRegNoEffect(MISCREG_CPSR, gdbregs.regs64[GDB64_CPSR]);
|
context->setMiscRegNoEffect(MISCREG_CPSR, gdbregs.regs64[GDB64_CPSR]);
|
||||||
|
// Update the stack pointer. This should be done after
|
||||||
|
// updating CPSR/PSTATE since that might affect how SPX gets
|
||||||
|
// mapped.
|
||||||
|
context->setIntReg(INTREG_SPX, gdbregs.regs64[GDB64_SPX]);
|
||||||
// v0-v31
|
// v0-v31
|
||||||
for (int i = 0; i < 128; i += 4) {
|
for (int i = 0; i < 128; i += 4) {
|
||||||
int gdboff = GDB64_V0_32 + i;
|
int gdboff = GDB64_V0_32 + i;
|
||||||
|
|
|
@ -68,6 +68,7 @@ enum {
|
||||||
// AArch64 registers
|
// AArch64 registers
|
||||||
enum {
|
enum {
|
||||||
GDB64_X0 = 0,
|
GDB64_X0 = 0,
|
||||||
|
GDB64_SPX = 31,
|
||||||
GDB64_PC = 32,
|
GDB64_PC = 32,
|
||||||
GDB64_CPSR = 33,
|
GDB64_CPSR = 33,
|
||||||
GDB64_V0 = 34,
|
GDB64_V0 = 34,
|
||||||
|
|
Loading…
Reference in a new issue