Debugger: Show current banks

This commit is contained in:
Vicki Pfau 2017-06-02 19:37:36 -07:00
parent 9c144266ec
commit 19ecae8ca1
3 changed files with 40 additions and 1 deletions

View File

@ -26,6 +26,12 @@ struct LR35902DebugWatchpoint {
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 LR35902Debugger {
struct LR35902DebugBreakpointList breakpoints;
struct LR35902DebugWatchpointList watchpoints;
struct LR35902Memory originalMemory;
const struct LR35902Segment* segments;
};
struct mDebuggerPlatform* LR35902DebuggerPlatformCreate(void);

View File

@ -37,6 +37,20 @@ const static struct mCoreChannelInfo _GBAudioChannels[] = {
{ 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 bool _GBCoreSupportsDebuggerType(struct mCore* core, enum mDebuggerType t
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;
}

View File

@ -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 @@ static void _printStatus(struct CLIDebuggerSystem* debugger) {
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));
}