From c03f9bcc039c7c3f10cfe6df28f63bacec22dbb9 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 25 Apr 2016 22:44:44 -0700 Subject: [PATCH] Debugger: Fix identifier lookup --- src/arm/cli-debugger.c | 15 ++++----------- src/debugger/cli-debugger.c | 10 +++++++--- src/debugger/cli-debugger.h | 1 + src/lr35902/cli-debugger.c | 15 ++++----------- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/arm/cli-debugger.c b/src/arm/cli-debugger.c index 9efc1fc06..a3053be49 100644 --- a/src/arm/cli-debugger.c +++ b/src/arm/cli-debugger.c @@ -179,9 +179,8 @@ static void _setBreakpointThumb(struct CLIDebugger* debugger, struct CLIDebugVec 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 @@ static uint32_t _lookupIdentifier(struct mDebugger* debugger, const char* name, 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; } diff --git a/src/debugger/cli-debugger.c b/src/debugger/cli-debugger.c index f8e4a5c5a..74f7e4fcc 100644 --- a/src/debugger/cli-debugger.c +++ b/src/debugger/cli-debugger.c @@ -430,13 +430,17 @@ static uint32_t _performOperation(enum Operation operation, uint32_t current, ui 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; + } + dv->type = CLIDV_INT_TYPE; + 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; } diff --git a/src/debugger/cli-debugger.h b/src/debugger/cli-debugger.h index fd1aa26c7..3065ad490 100644 --- a/src/debugger/cli-debugger.h +++ b/src/debugger/cli-debugger.h @@ -47,6 +47,7 @@ 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; diff --git a/src/lr35902/cli-debugger.c b/src/lr35902/cli-debugger.c index c1b2f5d0c..d6badb25f 100644 --- a/src/lr35902/cli-debugger.c +++ b/src/lr35902/cli-debugger.c @@ -34,9 +34,8 @@ static void _printStatus(struct CLIDebuggerSystem* debugger) { _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 @@ static uint32_t _lookupIdentifier(struct mDebugger* debugger, const char* name, 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; }