Debugger: Show current banks
Vicki Pfau vi@endrift.com
Fri, 02 Jun 2017 19:37:36 -0700
3 files changed,
40 insertions(+),
1 deletions(-)
M
include/mgba/internal/lr35902/debugger/debugger.h
→
include/mgba/internal/lr35902/debugger/debugger.h
@@ -26,6 +26,12 @@ int segment;
enum mWatchpointType type; }; +struct LR35902Segment { + uint16_t start; + uint16_t end; + const char* name; +}; + DECLARE_VECTOR(LR35902DebugBreakpointList, struct LR35902DebugBreakpoint); DECLARE_VECTOR(LR35902DebugWatchpointList, struct LR35902DebugWatchpoint);@@ -36,6 +42,8 @@
struct LR35902DebugBreakpointList breakpoints; struct LR35902DebugWatchpointList watchpoints; struct LR35902Memory originalMemory; + + const struct LR35902Segment* segments; }; struct mDebuggerPlatform* LR35902DebuggerPlatformCreate(void);
M
src/gb/core.c
→
src/gb/core.c
@@ -37,6 +37,20 @@ { 2, "ch2", "Channel 2", "PCM" },
{ 3, "ch3", "Channel 3", "Noise" }, }; +const static struct LR35902Segment _GBSegments[] = { + { .name = "ROM", .start = GB_BASE_CART_BANK1, .end = GB_BASE_VRAM }, + { .name = "RAM", .start = GB_BASE_EXTERNAL_RAM, .end = GB_BASE_WORKING_RAM_BANK0 }, + { 0 } +}; + +const static struct LR35902Segment _GBCSegments[] = { + { .name = "ROM", .start = GB_BASE_CART_BANK1, .end = GB_BASE_VRAM }, + { .name = "RAM", .start = GB_BASE_EXTERNAL_RAM, .end = GB_BASE_WORKING_RAM_BANK0 }, + { .name = "WRAM", .start = GB_BASE_WORKING_RAM_BANK1, .end = 0xE000 }, + { .name = "VRAM", .start = GB_BASE_VRAM, .end = GB_BASE_EXTERNAL_RAM }, + { 0 } +}; + struct mVideoLogContext; struct GBCore { struct mCore d;@@ -529,8 +543,15 @@ }
static struct mDebuggerPlatform* _GBCoreDebuggerPlatform(struct mCore* core) { struct GBCore* gbcore = (struct GBCore*) core; + struct GB* gb = core->board; if (!gbcore->debuggerPlatform) { - gbcore->debuggerPlatform = LR35902DebuggerPlatformCreate(); + struct LR35902Debugger* platform = (struct LR35902Debugger*) LR35902DebuggerPlatformCreate(); + if (gb->model >= GB_MODEL_CGB) { + platform->segments = _GBCSegments; + } else { + platform->segments = _GBSegments; + } + gbcore->debuggerPlatform = &platform->d; } return gbcore->debuggerPlatform; }
M
src/lr35902/debugger/cli-debugger.c
→
src/lr35902/debugger/cli-debugger.c
@@ -8,6 +8,7 @@
#include <mgba/core/core.h> #include <mgba/internal/debugger/cli-debugger.h> #include <mgba/internal/lr35902/decoder.h> +#include <mgba/internal/lr35902/debugger/debugger.h> #include <mgba/internal/lr35902/lr35902.h> static void _printStatus(struct CLIDebuggerSystem*);@@ -86,6 +87,15 @@ be->printf(be, "B: %02X C: %02X (BC: %04X)\n", cpu->b, cpu->c, cpu->bc);
be->printf(be, "D: %02X E: %02X (DE: %04X)\n", cpu->d, cpu->e, cpu->de); be->printf(be, "H: %02X L: %02X (HL: %04X)\n", cpu->h, cpu->l, cpu->hl); be->printf(be, "PC: %04X SP: %04X\n", cpu->pc, cpu->sp); + + struct LR35902Debugger* platDebugger = (struct LR35902Debugger*) debugger->p->d.platform; + size_t i; + for (i = 0; platDebugger->segments[i].name; ++i) { + be->printf(be, "%s%s: %02X", i ? " " : "", platDebugger->segments[i].name, cpu->memory.currentSegment(cpu, platDebugger->segments[i].start)); + } + if (i) { + be->printf(be, "\n"); + } _printFlags(be, cpu->f); _printLine(debugger->p, cpu->pc, cpu->memory.currentSegment(cpu, cpu->pc)); }