Debugger: Add callback for updating while the runloop is suspended; use for GDB

This commit is contained in:
Vicki Pfau 2022-03-27 02:33:32 -07:00
parent e8f8dd429e
commit 5418bb066f
5 changed files with 19 additions and 1 deletions

View File

@ -47,6 +47,7 @@ Other fixes:
Misc:
- Core: Suspend runloop when a core crashes
- Debugger: Save and restore CLI history
- Debugger: GDB now works while the game is paused
- GB Video: Add default SGB border
- GBA: Automatically skip BIOS if ROM has invalid logo
- GBA: Refine multiboot detection (fixes mgba.io/i/2192)

View File

@ -140,6 +140,7 @@ struct mDebugger {
void (*deinit)(struct mDebugger*);
void (*paused)(struct mDebugger*);
void (*update)(struct mDebugger*);
void (*entered)(struct mDebugger*, enum mDebuggerEntryReason, struct mDebuggerEntryInfo*);
void (*custom)(struct mDebugger*);
};

View File

@ -250,7 +250,15 @@ static THREAD_ENTRY _mCoreThreadRun(void* context) {
}
while (impl->state >= mTHREAD_MIN_WAITING && impl->state <= mTHREAD_MAX_WAITING) {
ConditionWait(&impl->stateCond, &impl->stateMutex);
#ifdef USE_DEBUGGERS
if (debugger && debugger->update && debugger->state != DEBUGGER_SHUTDOWN) {
debugger->update(debugger);
ConditionWaitTimed(&impl->stateCond, &impl->stateMutex, 10);
} else
#endif
{
ConditionWait(&impl->stateCond, &impl->stateMutex);
}
if (impl->sync.audioWait) {
MutexUnlock(&impl->stateMutex);

View File

@ -1124,6 +1124,7 @@ void CLIDebuggerCreate(struct CLIDebugger* debugger) {
debugger->d.deinit = _cliDebuggerDeinit;
debugger->d.custom = _cliDebuggerCustom;
debugger->d.paused = _commandLine;
debugger->d.update = NULL;
debugger->d.entered = _reportEntry;
debugger->d.type = DEBUGGER_CLI;

View File

@ -135,6 +135,12 @@ static void _gdbStubWait(struct mDebugger* debugger) {
GDBStubUpdate(stub);
}
static void _gdbStubUpdate(struct mDebugger* debugger) {
struct GDBStub* stub = (struct GDBStub*) debugger;
stub->shouldBlock = false;
GDBStubUpdate(stub);
}
static void _ack(struct GDBStub* stub) {
char ack = '+';
SocketSend(stub->connection, &ack, 1);
@ -758,6 +764,7 @@ void GDBStubCreate(struct GDBStub* stub) {
stub->d.init = 0;
stub->d.deinit = _gdbStubDeinit;
stub->d.paused = _gdbStubWait;
stub->d.update = _gdbStubUpdate;
stub->d.entered = _gdbStubEntered;
stub->d.custom = _gdbStubPoll;
stub->d.type = DEBUGGER_GDB;