summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/gdbstub/gdbstub.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp
index e7fed68f7..6c21b5998 100644
--- a/src/core/gdbstub/gdbstub.cpp
+++ b/src/core/gdbstub/gdbstub.cpp
@@ -488,17 +488,18 @@ static void ReadRegisters() {
488 memset(buffer, 0, sizeof(buffer)); 488 memset(buffer, 0, sizeof(buffer));
489 489
490 u8* bufptr = buffer; 490 u8* bufptr = buffer;
491 for (int i = 0; i <= MAX_REGISTERS; i++) { 491 for (int i = 0, reg = 0; i <= MAX_REGISTERS; i++, reg++) {
492 if (i <= R15_REGISTER) { 492 if (i <= R15_REGISTER) {
493 IntToHex(bufptr + i * 8, Core::g_app_core->GetReg(i)); 493 IntToHex(bufptr + i * 8, Core::g_app_core->GetReg(reg));
494 } else if (i == CSPR_REGISTER) { 494 } else if (i == CSPR_REGISTER) {
495 IntToHex(bufptr + i * 8, Core::g_app_core->GetCPSR()); 495 IntToHex(bufptr + i * 8, Core::g_app_core->GetCPSR());
496 } else if (i < CSPR_REGISTER) { 496 } else if (i < CSPR_REGISTER) {
497 IntToHex(bufptr + i * 8, 0); 497 IntToHex(bufptr + i * 8, 0);
498 IntToHex(bufptr + (i + 1) * 8, 0); 498 IntToHex(bufptr + (i + 1) * 8, 0);
499 i++; // These registers seem to be all 64bit instead of 32bit, so skip two instead of one 499 i++; // These registers seem to be all 64bit instead of 32bit, so skip two instead of one
500 reg++;
500 } else if (i > CSPR_REGISTER && i < MAX_REGISTERS) { 501 } else if (i > CSPR_REGISTER && i < MAX_REGISTERS) {
501 IntToHex(bufptr + i * 8, Core::g_app_core->GetVFPReg(i - CSPR_REGISTER - 1)); 502 IntToHex(bufptr + i * 8, Core::g_app_core->GetVFPReg(reg - CSPR_REGISTER - 1));
502 IntToHex(bufptr + (i + 1) * 8, 0); 503 IntToHex(bufptr + (i + 1) * 8, 0);
503 i++; 504 i++;
504 } else if (i == MAX_REGISTERS) { 505 } else if (i == MAX_REGISTERS) {
@@ -542,15 +543,17 @@ static void WriteRegisters() {
542 if (command_buffer[0] != 'G') 543 if (command_buffer[0] != 'G')
543 return SendReply("E01"); 544 return SendReply("E01");
544 545
545 for (int i = 0; i <= MAX_REGISTERS; i++) { 546 for (int i = 0, reg = 0; i <= MAX_REGISTERS; i++, reg++) {
546 if (i <= R15_REGISTER) { 547 if (i <= R15_REGISTER) {
547 Core::g_app_core->SetReg(i, HexToInt(buffer_ptr + i * 8)); 548 Core::g_app_core->SetReg(reg, HexToInt(buffer_ptr + i * 8));
548 } else if (i == CSPR_REGISTER) { 549 } else if (i == CSPR_REGISTER) {
549 Core::g_app_core->SetCPSR(HexToInt(buffer_ptr + i * 8)); 550 Core::g_app_core->SetCPSR(HexToInt(buffer_ptr + i * 8));
550 } else if (i < CSPR_REGISTER) { 551 } else if (i < CSPR_REGISTER) {
551 i++; // These registers seem to be all 64bit instead of 32bit, so skip two instead of one 552 i++; // These registers seem to be all 64bit instead of 32bit, so skip two instead of one
553 reg++;
552 } else if (i > CSPR_REGISTER && i < MAX_REGISTERS) { 554 } else if (i > CSPR_REGISTER && i < MAX_REGISTERS) {
553 Core::g_app_core->SetVFPReg(i - CSPR_REGISTER - 1, HexToInt(buffer_ptr + i * 8)); 555 Core::g_app_core->SetVFPReg(reg - CSPR_REGISTER - 1, HexToInt(buffer_ptr + i * 8));
556 i++; // Skip padding
554 } else if (i == MAX_REGISTERS) { 557 } else if (i == MAX_REGISTERS) {
555 Core::g_app_core->SetVFPSystemReg(VFP_FPSCR, HexToInt(buffer_ptr + i * 8)); 558 Core::g_app_core->SetVFPSystemReg(VFP_FPSCR, HexToInt(buffer_ptr + i * 8));
556 } 559 }