Pause on stub opcodes

This commit is contained in:
Jeffrey Pfau 2013-04-13 13:56:29 -07:00
parent e5379c99e0
commit 4df2d6de8f
3 changed files with 36 additions and 25 deletions

View File

@ -447,30 +447,7 @@ static void _parse(struct ARMDebugger* debugger, const char* line) {
_printStatus(debugger, 0);
}
void ARMDebuggerInit(struct ARMDebugger* debugger, struct ARMCore* cpu) {
debugger->cpu = cpu;
debugger->state = DEBUGGER_PAUSED;
}
void ARMDebuggerRun(struct ARMDebugger* debugger) {
while (debugger->state != DEBUGGER_EXITING) {
while (debugger->state == DEBUGGER_RUNNING) {
ARMRun(debugger->cpu);
}
switch (debugger->state) {
case DEBUGGER_PAUSED:
ARMDebuggerEnter(debugger);
break;
case DEBUGGER_EXITING:
return;
default:
// Should never be reached
break;
}
}
}
void ARMDebuggerEnter(struct ARMDebugger* debugger) {
static void _commandLine(struct ARMDebugger* debugger) {
char* line;
_printStatus(debugger, 0);
while (debugger->state == DEBUGGER_PAUSED) {
@ -483,3 +460,30 @@ void ARMDebuggerEnter(struct ARMDebugger* debugger) {
free(line);
}
}
void ARMDebuggerInit(struct ARMDebugger* debugger, struct ARMCore* cpu) {
debugger->cpu = cpu;
debugger->state = DEBUGGER_PAUSED;
}
void ARMDebuggerRun(struct ARMDebugger* debugger) {
while (debugger->state != DEBUGGER_EXITING) {
while (debugger->state == DEBUGGER_RUNNING) {
ARMRun(debugger->cpu);
}
switch (debugger->state) {
case DEBUGGER_PAUSED:
_commandLine(debugger);
break;
case DEBUGGER_EXITING:
return;
default:
// Should never be reached
break;
}
}
}
void ARMDebuggerEnter(struct ARMDebugger* debugger) {
debugger->state = DEBUGGER_PAUSED;
}

View File

@ -23,6 +23,7 @@ void GBAInit(struct GBA* 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 GBALog(int level, const char* format, ...) {
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);
}
}

View File

@ -85,6 +85,7 @@ struct GBAMemory {
struct GBABoard {
struct ARMBoard d;
struct GBA* p;
};
struct GBA {