all repos — mgba @ 99d75ee9edba832e8a5015067c9fb83c73012f56

mGBA Game Boy Advance Emulator

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
commit

99d75ee9edba832e8a5015067c9fb83c73012f56

parent

1f75e41bae9a0f3fd76b9197b22ca6a900255f23

2 files changed, 22 insertions(+), 34 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.csrc/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; } }