Pause on stub opcodes
Jeffrey Pfau jeffrey@endrift.com
Sat, 13 Apr 2013 13:56:29 -0700
3 files changed,
24 insertions(+),
13 deletions(-)
M
src/debugger.c
→
src/debugger.c
@@ -447,6 +447,20 @@ ARMRun(debugger->cpu);
_printStatus(debugger, 0); } +static void _commandLine(struct ARMDebugger* debugger) { + char* line; + _printStatus(debugger, 0); + while (debugger->state == DEBUGGER_PAUSED) { + line = linenoise("> "); + if (!line) { + debugger->state = DEBUGGER_EXITING; + return; + } + _parse(debugger, line); + free(line); + } +} + void ARMDebuggerInit(struct ARMDebugger* debugger, struct ARMCore* cpu) { debugger->cpu = cpu; debugger->state = DEBUGGER_PAUSED;@@ -459,7 +473,7 @@ ARMRun(debugger->cpu);
} switch (debugger->state) { case DEBUGGER_PAUSED: - ARMDebuggerEnter(debugger); + _commandLine(debugger); break; case DEBUGGER_EXITING: return;@@ -471,15 +485,5 @@ }
} void ARMDebuggerEnter(struct ARMDebugger* debugger) { - char* line; - _printStatus(debugger, 0); - while (debugger->state == DEBUGGER_PAUSED) { - line = linenoise("> "); - if (!line) { - debugger->state = DEBUGGER_EXITING; - return; - } - _parse(debugger, line); - free(line); - } + debugger->state = DEBUGGER_PAUSED; }
M
src/gba.c
→
src/gba.c
@@ -23,6 +23,7 @@ gba->memory.p = gba;
GBAMemoryInit(&gba->memory); ARMAssociateMemory(&gba->cpu, &gba->memory.d); + gba->board.p = gba; GBABoardInit(&gba->board); ARMAssociateBoard(&gba->cpu, &gba->board.d);@@ -390,5 +391,10 @@ }
void GBAHitStub(struct ARMBoard* board, uint32_t opcode) { GBALog(GBA_LOG_STUB, "Stub opcode: %08x", opcode); - abort(); + struct GBABoard* gbaBoard = (struct GBABoard*) board; + if (!gbaBoard->p->debugger) { + abort(); + } else { + ARMDebuggerEnter(gbaBoard->p->debugger); + } }