all repos — mgba @ c03f9bcc039c7c3f10cfe6df28f63bacec22dbb9

mGBA Game Boy Advance Emulator

Debugger: Fix identifier lookup
Jeffrey Pfau jeffrey@endrift.com
Mon, 25 Apr 2016 22:44:44 -0700
commit

c03f9bcc039c7c3f10cfe6df28f63bacec22dbb9

parent

b365628aad6c92ad2b2e0db652d52500052d58ff

M src/arm/cli-debugger.csrc/arm/cli-debugger.c

@@ -179,9 +179,8 @@ uint32_t address = dv->intValue;

ARMDebuggerSetSoftwareBreakpoint(&debugger->d, address, MODE_THUMB); } -static uint32_t _lookupIdentifier(struct mDebugger* debugger, const char* name, struct CLIDebugVector* dv) { - struct CLIDebugger* cliDebugger = (struct CLIDebugger*) debugger; - struct ARMCore* cpu = debugger->core->cpu; +static uint32_t _lookupPlatformIdentifier(struct CLIDebuggerSystem* debugger, const char* name, struct CLIDebugVector* dv) { + struct ARMCore* cpu = debugger->p->d.core->cpu; if (strcmp(name, "sp") == 0) { return cpu->gprs[ARM_SP]; }

@@ -204,20 +203,14 @@ if (reg < 16) {

return cpu->gprs[reg]; } } - if (cliDebugger->system) { - uint32_t value = cliDebugger->system->lookupIdentifier(cliDebugger->system, name, dv); - if (dv->type != CLIDV_ERROR_TYPE) { - return value; - } - } else { - dv->type = CLIDV_ERROR_TYPE; - } + dv->type = CLIDV_ERROR_TYPE; return 0; } void ARMCLIDebuggerCreate(struct CLIDebuggerSystem* debugger) { debugger->printStatus = _printStatus; debugger->disassemble = _disassemble; + debugger->lookupPlatformIdentifier = _lookupPlatformIdentifier; debugger->platformName = "ARM"; debugger->platformCommands = _armCommands; }
M src/debugger/cli-debugger.csrc/debugger/cli-debugger.c

@@ -430,13 +430,17 @@

static uint32_t _lookupIdentifier(struct mDebugger* debugger, const char* name, struct CLIDebugVector* dv) { struct CLIDebugger* cliDebugger = (struct CLIDebugger*) debugger; if (cliDebugger->system) { - uint32_t value = cliDebugger->system->lookupIdentifier(cliDebugger->system, name, dv); + uint32_t value = cliDebugger->system->lookupPlatformIdentifier(cliDebugger->system, name, dv); if (dv->type != CLIDV_ERROR_TYPE) { return value; } - } else { - dv->type = CLIDV_ERROR_TYPE; + dv->type = CLIDV_INT_TYPE; + value = cliDebugger->system->lookupIdentifier(cliDebugger->system, name, dv); + if (dv->type != CLIDV_ERROR_TYPE) { + return value; + } } + dv->type = CLIDV_ERROR_TYPE; return 0; }
M src/debugger/cli-debugger.hsrc/debugger/cli-debugger.h

@@ -47,6 +47,7 @@ bool (*custom)(struct CLIDebuggerSystem*);

void (*disassemble)(struct CLIDebuggerSystem*, struct CLIDebugVector* dv); uint32_t (*lookupIdentifier)(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv); + uint32_t (*lookupPlatformIdentifier)(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv); void (*printStatus)(struct CLIDebuggerSystem*); struct CLIDebuggerCommandSummary* commands;
M src/lr35902/cli-debugger.csrc/lr35902/cli-debugger.c

@@ -34,9 +34,8 @@ printf("PC: %04X SP: %04X\n", cpu->pc, cpu->sp);

_printFlags(cpu->f); } -static uint32_t _lookupIdentifier(struct mDebugger* debugger, const char* name, struct CLIDebugVector* dv) { - struct CLIDebugger* cliDebugger = (struct CLIDebugger*) debugger; - struct LR35902Core* cpu = debugger->core->cpu; +static uint32_t _lookupPlatformIdentifier(struct CLIDebuggerSystem* debugger, const char* name, struct CLIDebugVector* dv) { + struct LR35902Core* cpu = debugger->p->d.core->cpu; if (strcmp(name, "a") == 0) { return cpu->a; }

@@ -79,20 +78,14 @@ }

if (strcmp(name, "f") == 0) { return cpu->f.packed; } - if (cliDebugger->system) { - uint32_t value = cliDebugger->system->lookupIdentifier(cliDebugger->system, name, dv); - if (dv->type != CLIDV_ERROR_TYPE) { - return value; - } - } else { - dv->type = CLIDV_ERROR_TYPE; - } + dv->type = CLIDV_ERROR_TYPE; return 0; } void LR35902CLIDebuggerCreate(struct CLIDebuggerSystem* debugger) { debugger->printStatus = _printStatus; debugger->disassemble = NULL; + debugger->lookupPlatformIdentifier = _lookupPlatformIdentifier; debugger->platformName = "GB-Z80"; debugger->platformCommands = NULL; }