Debugger: Simplify debugger state machine to play nicer with the GBA thread loop
Jeffrey Pfau jeffrey@endrift.com
Sun, 18 Jan 2015 02:27:25 -0800
2 files changed,
22 insertions(+),
34 deletions(-)
M
CHANGES
→
CHANGES
@@ -77,6 +77,7 @@ - GBA Video: Start video at the last scanline instead of the first
- Debugger: Watchpoints now work on STM/LDM instructions - GBA: Improve accuracy of event timing - Debugger: Clean up GDB stub network interfacing + - Debugger: Simplify debugger state machine to play nicer with the GBA thread loop 0.1.0: (2014-12-13) - Initial release
M
src/debugger/debugger.c
→
src/debugger/debugger.c
@@ -55,45 +55,32 @@ debugger->deinit(debugger);
} void ARMDebuggerRun(struct ARMDebugger* debugger) { - if (debugger->state == DEBUGGER_EXITING) { + switch (debugger->state) { + case DEBUGGER_EXITING: debugger->state = DEBUGGER_RUNNING; - } - while (debugger->state < DEBUGGER_EXITING) { + // Fall through + case DEBUGGER_RUNNING: if (!debugger->breakpoints && !debugger->watchpoints) { - while (debugger->state == DEBUGGER_RUNNING) { - ARMRunLoop(debugger->cpu); - } - } else if (!debugger->breakpoints) { - while (debugger->state == DEBUGGER_RUNNING) { - ARMRun(debugger->cpu); - } + ARMRunLoop(debugger->cpu); } else { - while (debugger->state == DEBUGGER_RUNNING) { - ARMRun(debugger->cpu); - _checkBreakpoints(debugger); - } + ARMRun(debugger->cpu); + _checkBreakpoints(debugger); } - switch (debugger->state) { - case DEBUGGER_RUNNING: - break; - case DEBUGGER_CUSTOM: - while (debugger->state == DEBUGGER_CUSTOM) { - ARMRun(debugger->cpu); - _checkBreakpoints(debugger); - debugger->custom(debugger); - } - break; - case DEBUGGER_PAUSED: - if (debugger->paused) { - debugger->paused(debugger); - } else { - debugger->state = DEBUGGER_RUNNING; - } - break; - case DEBUGGER_EXITING: - case DEBUGGER_SHUTDOWN: - return; + break; + case DEBUGGER_CUSTOM: + ARMRun(debugger->cpu); + _checkBreakpoints(debugger); + debugger->custom(debugger); + break; + case DEBUGGER_PAUSED: + if (debugger->paused) { + debugger->paused(debugger); + } else { + debugger->state = DEBUGGER_RUNNING; } + break; + case DEBUGGER_SHUTDOWN: + return; } }