summaryrefslogtreecommitdiff
path: root/src/core/gdbstub/gdbstub.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/gdbstub/gdbstub.cpp')
-rw-r--r--src/core/gdbstub/gdbstub.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp
index 7d8e9e3fb..e7fed68f7 100644
--- a/src/core/gdbstub/gdbstub.cpp
+++ b/src/core/gdbstub/gdbstub.cpp
@@ -57,6 +57,7 @@ const u32 R0_REGISTER = 0;
57const u32 R15_REGISTER = 15; 57const u32 R15_REGISTER = 15;
58const u32 CSPR_REGISTER = 25; 58const u32 CSPR_REGISTER = 25;
59const u32 FPSCR_REGISTER = 58; 59const u32 FPSCR_REGISTER = 58;
60const u32 MAX_REGISTERS = 90;
60 61
61namespace GDBStub { 62namespace GDBStub {
62 63
@@ -487,7 +488,7 @@ static void ReadRegisters() {
487 memset(buffer, 0, sizeof(buffer)); 488 memset(buffer, 0, sizeof(buffer));
488 489
489 u8* bufptr = buffer; 490 u8* bufptr = buffer;
490 for (int i = 0; i <= FPSCR_REGISTER; i++) { 491 for (int i = 0; i <= MAX_REGISTERS; i++) {
491 if (i <= R15_REGISTER) { 492 if (i <= R15_REGISTER) {
492 IntToHex(bufptr + i * 8, Core::g_app_core->GetReg(i)); 493 IntToHex(bufptr + i * 8, Core::g_app_core->GetReg(i));
493 } else if (i == CSPR_REGISTER) { 494 } else if (i == CSPR_REGISTER) {
@@ -496,11 +497,11 @@ static void ReadRegisters() {
496 IntToHex(bufptr + i * 8, 0); 497 IntToHex(bufptr + i * 8, 0);
497 IntToHex(bufptr + (i + 1) * 8, 0); 498 IntToHex(bufptr + (i + 1) * 8, 0);
498 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
499 } else if (i > CSPR_REGISTER && i < FPSCR_REGISTER) { 500 } else if (i > CSPR_REGISTER && i < MAX_REGISTERS) {
500 IntToHex(bufptr + i * 8, Core::g_app_core->GetVFPReg(i - CSPR_REGISTER - 1)); 501 IntToHex(bufptr + i * 8, Core::g_app_core->GetVFPReg(i - CSPR_REGISTER - 1));
501 IntToHex(bufptr + (i + 1) * 8, 0); 502 IntToHex(bufptr + (i + 1) * 8, 0);
502 i++; 503 i++;
503 } else if (i == FPSCR_REGISTER) { 504 } else if (i == MAX_REGISTERS) {
504 IntToHex(bufptr + i * 8, Core::g_app_core->GetVFPSystemReg(VFP_FPSCR)); 505 IntToHex(bufptr + i * 8, Core::g_app_core->GetVFPSystemReg(VFP_FPSCR));
505 } 506 }
506 } 507 }
@@ -541,16 +542,16 @@ static void WriteRegisters() {
541 if (command_buffer[0] != 'G') 542 if (command_buffer[0] != 'G')
542 return SendReply("E01"); 543 return SendReply("E01");
543 544
544 for (int i = 0; i <= FPSCR_REGISTER; i++) { 545 for (int i = 0; i <= MAX_REGISTERS; i++) {
545 if (i <= R15_REGISTER) { 546 if (i <= R15_REGISTER) {
546 Core::g_app_core->SetReg(i, HexToInt(buffer_ptr + i * 8)); 547 Core::g_app_core->SetReg(i, HexToInt(buffer_ptr + i * 8));
547 } else if (i == CSPR_REGISTER) { 548 } else if (i == CSPR_REGISTER) {
548 Core::g_app_core->SetCPSR(HexToInt(buffer_ptr + i * 8)); 549 Core::g_app_core->SetCPSR(HexToInt(buffer_ptr + i * 8));
549 } else if (i < CSPR_REGISTER) { 550 } else if (i < CSPR_REGISTER) {
550 i++; // These registers seem to be all 64bit instead of 32bit, so skip two instead of one 551 i++; // These registers seem to be all 64bit instead of 32bit, so skip two instead of one
551 } else if (i > CSPR_REGISTER && i < FPSCR_REGISTER) { 552 } else if (i > CSPR_REGISTER && i < MAX_REGISTERS) {
552 Core::g_app_core->SetVFPReg(i - CSPR_REGISTER - 1, HexToInt(buffer_ptr + i * 8)); 553 Core::g_app_core->SetVFPReg(i - CSPR_REGISTER - 1, HexToInt(buffer_ptr + i * 8));
553 } else if (i == FPSCR_REGISTER) { 554 } else if (i == MAX_REGISTERS) {
554 Core::g_app_core->SetVFPSystemReg(VFP_FPSCR, HexToInt(buffer_ptr + i * 8)); 555 Core::g_app_core->SetVFPSystemReg(VFP_FPSCR, HexToInt(buffer_ptr + i * 8));
555 } 556 }
556 } 557 }