all repos — mgba @ 7969bac2b20e85439bc2f425a23d6dee7e707a3d

mGBA Game Boy Advance Emulator

DS: Add ability to switch CPUs while debugging
Jeffrey Pfau jeffrey@endrift.com
Sat, 04 Jun 2016 17:06:36 -0700
commit

7969bac2b20e85439bc2f425a23d6dee7e707a3d

parent

36b3f07ed18afe430689933beb31c052e49b52bb

3 files changed, 26 insertions(+), 4 deletions(-)

jump to
M src/ds/core.csrc/ds/core.c

@@ -38,7 +38,7 @@ free(arm9);

free(ds); return false; } - core->cpu = arm7; + core->cpu = arm9; core->board = ds; core->debugger = NULL; dscore->arm7 = arm7;

@@ -343,9 +343,6 @@ if (core->debugger) {

DSDetachDebugger(core->board); } DSAttachDebugger(core->board, debugger); - struct ARMCore* cpu = core->cpu; - cpu->components[CPU_COMPONENT_DEBUGGER] = &debugger->d; - ARMHotplugAttach(cpu, CPU_COMPONENT_DEBUGGER); core->debugger = debugger; }
M src/ds/ds.csrc/ds/ds.c

@@ -216,6 +216,10 @@ }

void DSAttachDebugger(struct DS* ds, struct mDebugger* debugger) { ds->debugger = (struct ARMDebugger*) debugger->platform; + ds->arm7->components[CPU_COMPONENT_DEBUGGER] = &debugger->d; + ds->arm9->components[CPU_COMPONENT_DEBUGGER] = &debugger->d; + ARMHotplugAttach(ds->arm7, CPU_COMPONENT_DEBUGGER); + ARMHotplugAttach(ds->arm9, CPU_COMPONENT_DEBUGGER); } void DSDetachDebugger(struct DS* ds) {
M src/ds/extra/cli.csrc/ds/extra/cli.c

@@ -6,6 +6,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "cli.h" #include "arm/debugger/cli-debugger.h" +#include "core/core.h" +#include "ds/core.h" +#include "ds/ds.h" #ifdef USE_CLI_DEBUGGER

@@ -14,9 +17,11 @@ static bool _DSCLIDebuggerCustom(struct CLIDebuggerSystem*);

static uint32_t _DSCLIDebuggerLookupIdentifier(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv); static void _frame(struct CLIDebugger*, struct CLIDebugVector*); +static void _switchCpu(struct CLIDebugger*, struct CLIDebugVector*); struct CLIDebuggerCommandSummary _DSCLIDebuggerCommands[] = { { "frame", _frame, 0, "Frame advance" }, + { "cpu", _switchCpu, 0 , "Switch active CPU" }, { 0, 0, 0, 0 } };

@@ -59,4 +64,20 @@

struct DSCLIDebugger* dsDebugger = (struct DSCLIDebugger*) debugger->system; dsDebugger->frameAdvance = true; } + +static void _switchCpu(struct CLIDebugger* debugger, struct CLIDebugVector* dv) { + UNUSED(dv); + struct DSCLIDebugger* dsDebugger = (struct DSCLIDebugger*) debugger->system; + struct mCore* core = dsDebugger->core; + struct DS* ds = core->board; + debugger->d.platform->deinit(debugger->d.platform); + if (core->cpu == ds->arm9) { + core->cpu = ds->arm7; + } else { + core->cpu = ds->arm9; + } + debugger->d.platform->init(core->cpu, debugger->d.platform); + debugger->system->printStatus(debugger->system); +} + #endif