all repos — mgba @ 27c4308ef57581d75326bc0abb78c77288e560a5

mGBA Game Boy Advance Emulator

Debugger: Add CLI function for writing a register
Jeffrey Pfau jeffrey@endrift.com
Sun, 22 Feb 2015 17:33:35 -0800
commit

27c4308ef57581d75326bc0abb78c77288e560a5

parent

c1261a5b7489c20ec5178012137f41df1fadc2ff

2 files changed, 20 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -25,6 +25,7 @@ - Drag and drop game loading

- Cheat code support - Debugger: Add CLI functions for examining memory regions - Runtime configurable audio driver + - Debugger: Add CLI function for writing a register Bugfixes: - ARM7: Extend prefetch by one stage - GBA Audio: Support 16-bit writes to FIFO audio
M src/debugger/cli-debugger.csrc/debugger/cli-debugger.c

@@ -42,6 +42,7 @@ static void _setWatchpoint(struct CLIDebugger*, struct CLIDebugVector*);

static void _writeByte(struct CLIDebugger*, struct CLIDebugVector*); static void _writeHalfword(struct CLIDebugger*, struct CLIDebugVector*); static void _writeWord(struct CLIDebugger*, struct CLIDebugVector*); +static void _writeRegister(struct CLIDebugger*, struct CLIDebugVector*); static void _dumpByte(struct CLIDebugger*, struct CLIDebugVector*); static void _dumpHalfword(struct CLIDebugger*, struct CLIDebugVector*); static void _dumpWord(struct CLIDebugger*, struct CLIDebugVector*);

@@ -92,6 +93,7 @@ { "watch", _setWatchpoint, CLIDVParse, "Set a watchpoint" },

{ "w/1", _writeByte, CLIDVParse, "Write a byte at a specified offset" }, { "w/2", _writeHalfword, CLIDVParse, "Write a halfword at a specified offset" }, { "w/4", _writeWord, CLIDVParse, "Write a word at a specified offset" }, + { "w/r", _writeRegister, CLIDVParse, "Write a register" }, { "x/1", _dumpByte, CLIDVParse, "Examine bytes at a specified offset" }, { "x/2", _dumpHalfword, CLIDVParse, "Examine halfwords at a specified offset" }, { "x/4", _dumpWord, CLIDVParse, "Examine words at a specified offset" },

@@ -392,6 +394,23 @@ }

uint32_t address = dv->intValue; uint32_t value = dv->next->intValue; debugger->d.cpu->memory.store32(debugger->d.cpu, address, value, 0); +} + +static void _writeRegister(struct CLIDebugger* debugger, struct CLIDebugVector* dv) { + if (!dv || dv->type != CLIDV_INT_TYPE) { + printf("%s\n", ERROR_MISSING_ARGS); + return; + } + if (!dv->next || dv->next->type != CLIDV_INT_TYPE) { + printf("%s\n", ERROR_MISSING_ARGS); + return; + } + uint32_t regid = dv->intValue; + uint32_t value = dv->next->intValue; + if (regid >= ARM_PC) { + return; + } + debugger->d.cpu->gprs[regid] = value; } static void _dumpByte(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {