all repos — mgba @ 73f4fad5c39f4e4d2ae52be7753bc3b88ee89146

mGBA Game Boy Advance Emulator

Debugger: Fix GDB writing to PC
Jeffrey Pfau jeffrey@endrift.com
Sun, 07 Aug 2016 11:07:54 -0700
commit

73f4fad5c39f4e4d2ae52be7753bc3b88ee89146

parent

a967f9aac433c817fbca981c5e254e5107457f47

1 files changed, 17 insertions(+), 2 deletions(-)

jump to
M src/debugger/gdb-stub.csrc/debugger/gdb-stub.c

@@ -5,6 +5,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "gdb-stub.h" +#include "arm/isa-inlines.h" #include "core/core.h" #include "gba/memory.h"

@@ -295,9 +296,15 @@ struct ARMCore* cpu = stub->d.core->cpu;

const char* readAddress = message; int r; - for (r = 0; r < ARM_PC; ++r) { + for (r = 0; r <= ARM_PC; ++r) { cpu->gprs[r] = _hex2int(readAddress, 8); readAddress += 8; + } + int32_t currentCycles = 0; + if (cpu->executionMode == MODE_ARM) { + ARM_WRITE_PC; + } else { + THUMB_WRITE_PC; } strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);

@@ -336,8 +343,16 @@ #else

value = __builtin_bswap32(value); #endif - if (reg < 0x10) { + if (reg <= ARM_PC) { cpu->gprs[reg] = value; + if (reg == ARM_PC) { + int32_t currentCycles = 0; + if (cpu->executionMode == MODE_ARM) { + ARM_WRITE_PC; + } else { + THUMB_WRITE_PC; + } + } } else if (reg == 0x19) { cpu->cpsr.packed = value; } else {