mirror of https://github.com/mgba-emu/mgba.git
Debugger: Fix identifier lookup
This commit is contained in:
parent
b365628aad
commit
c03f9bcc03
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue