all repos — mgba @ 4df2d6de8f72c8df9d980a870618edb095a48154

mGBA Game Boy Advance Emulator

Pause on stub opcodes
Jeffrey Pfau jeffrey@endrift.com
Sat, 13 Apr 2013 13:56:29 -0700
commit

4df2d6de8f72c8df9d980a870618edb095a48154

parent

e5379c99e015d33243a02da824f9b156264335ba

3 files changed, 24 insertions(+), 13 deletions(-)

jump to
M src/debugger.csrc/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.csrc/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); + } }
M src/gba.hsrc/gba.h

@@ -85,6 +85,7 @@ };

struct GBABoard { struct ARMBoard d; + struct GBA* p; }; struct GBA {