From f4fcdf35d4d88616a3bda9bce7384df0e83a6964 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 25 Jan 2015 13:28:14 -0800 Subject: [PATCH] Debugger: Clean up debugger interface, removing obsolete state (fixes #67) --- CHANGES | 1 + src/debugger/cli-debugger.c | 1 - src/debugger/debugger.c | 3 --- src/debugger/debugger.h | 1 - src/gba/gba-thread.c | 10 +--------- 5 files changed, 2 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 57d817b20..a60d4cb5b 100644 --- a/CHANGES +++ b/CHANGES @@ -40,6 +40,7 @@ Misc: - Debugger: Clean up GDB stub network interfacing - Debugger: Simplify debugger state machine to play nicer with the GBA thread loop - Debugger: Merge Thumb BL instructions when disassembling + - Debugger: Clean up debugger interface, removing obsolete state (fixes #67) 0.1.1: (2015-01-24) Bugfixes: diff --git a/src/debugger/cli-debugger.c b/src/debugger/cli-debugger.c index f6ac301f7..450e8e60f 100644 --- a/src/debugger/cli-debugger.c +++ b/src/debugger/cli-debugger.c @@ -640,7 +640,6 @@ static void _commandLine(struct ARMDebugger* debugger) { while (debugger->state == DEBUGGER_PAUSED) { line = el_gets(cliDebugger->elstate, &count); if (!line) { - debugger->state = DEBUGGER_EXITING; return; } if (line[0] == '\n') { diff --git a/src/debugger/debugger.c b/src/debugger/debugger.c index 7981aef13..e7d7fc2f1 100644 --- a/src/debugger/debugger.c +++ b/src/debugger/debugger.c @@ -56,9 +56,6 @@ void ARMDebuggerDeinit(struct ARMComponent* component) { void ARMDebuggerRun(struct ARMDebugger* debugger) { switch (debugger->state) { - case DEBUGGER_EXITING: - debugger->state = DEBUGGER_RUNNING; - // Fall through case DEBUGGER_RUNNING: if (!debugger->breakpoints && !debugger->watchpoints) { ARMRunLoop(debugger->cpu); diff --git a/src/debugger/debugger.h b/src/debugger/debugger.h index 95663a75f..040dd17d0 100644 --- a/src/debugger/debugger.h +++ b/src/debugger/debugger.h @@ -16,7 +16,6 @@ enum DebuggerState { DEBUGGER_PAUSED, DEBUGGER_RUNNING, DEBUGGER_CUSTOM, - DEBUGGER_EXITING, DEBUGGER_SHUTDOWN }; diff --git a/src/gba/gba-thread.c b/src/gba/gba-thread.c index 5be65d6c8..9aa5f1008 100644 --- a/src/gba/gba-thread.c +++ b/src/gba/gba-thread.c @@ -77,9 +77,6 @@ static void _waitUntilNotState(struct GBAThread* threadContext, enum ThreadState } static void _pauseThread(struct GBAThread* threadContext, bool onThread) { - if (threadContext->debugger && threadContext->debugger->state == DEBUGGER_RUNNING) { - threadContext->debugger->state = DEBUGGER_EXITING; - } threadContext->state = THREAD_PAUSING; if (!onThread) { _waitUntilNotState(threadContext, THREAD_PAUSING); @@ -392,9 +389,7 @@ bool GBAThreadHasCrashed(struct GBAThread* threadContext) { void GBAThreadEnd(struct GBAThread* threadContext) { MutexLock(&threadContext->stateMutex); - if (threadContext->debugger && threadContext->debugger->state == DEBUGGER_RUNNING) { - threadContext->debugger->state = DEBUGGER_EXITING; - } + _waitOnInterrupt(threadContext); threadContext->state = THREAD_EXITING; if (threadContext->gba) { threadContext->gba->cpu->halted = false; @@ -495,9 +490,6 @@ void GBAThreadInterrupt(struct GBAThread* threadContext) { _waitOnInterrupt(threadContext); threadContext->state = THREAD_INTERRUPTING; threadContext->gba->cpu->nextEvent = 0; - if (threadContext->debugger && threadContext->debugger->state == DEBUGGER_RUNNING) { - threadContext->debugger->state = DEBUGGER_EXITING; - } ConditionWake(&threadContext->stateCond); _waitUntilNotState(threadContext, THREAD_INTERRUPTING); MutexUnlock(&threadContext->stateMutex);