summaryrefslogtreecommitdiff
path: root/src/core/gdbstub/gdbstub.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2019-11-28 11:43:17 -0500
committerGravatar GitHub2019-11-28 11:43:17 -0500
commite3ee017e91ef4d713f1af8cb60c5157e40d43f18 (patch)
treee0a5b47cac1d548599b8ceba7f71b40746fe6b48 /src/core/gdbstub/gdbstub.cpp
parentMerge pull request #3171 from lioncash/internal-link (diff)
parentcore/memory; Migrate over SetCurrentPageTable() to the Memory class (diff)
downloadyuzu-e3ee017e91ef4d713f1af8cb60c5157e40d43f18.tar.gz
yuzu-e3ee017e91ef4d713f1af8cb60c5157e40d43f18.tar.xz
yuzu-e3ee017e91ef4d713f1af8cb60c5157e40d43f18.zip
Merge pull request #3169 from lioncash/memory
core/memory: Deglobalize memory management code
Diffstat (limited to 'src/core/gdbstub/gdbstub.cpp')
-rw-r--r--src/core/gdbstub/gdbstub.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp
index 54ed680db..37cb28848 100644
--- a/src/core/gdbstub/gdbstub.cpp
+++ b/src/core/gdbstub/gdbstub.cpp
@@ -508,8 +508,9 @@ static void RemoveBreakpoint(BreakpointType type, VAddr addr) {
508 bp->second.len, bp->second.addr, static_cast<int>(type)); 508 bp->second.len, bp->second.addr, static_cast<int>(type));
509 509
510 if (type == BreakpointType::Execute) { 510 if (type == BreakpointType::Execute) {
511 Memory::WriteBlock(bp->second.addr, bp->second.inst.data(), bp->second.inst.size()); 511 auto& system = Core::System::GetInstance();
512 Core::System::GetInstance().InvalidateCpuInstructionCaches(); 512 system.Memory().WriteBlock(bp->second.addr, bp->second.inst.data(), bp->second.inst.size());
513 system.InvalidateCpuInstructionCaches();
513 } 514 }
514 p.erase(addr); 515 p.erase(addr);
515} 516}
@@ -969,12 +970,13 @@ static void ReadMemory() {
969 SendReply("E01"); 970 SendReply("E01");
970 } 971 }
971 972
972 if (!Memory::IsValidVirtualAddress(addr)) { 973 auto& memory = Core::System::GetInstance().Memory();
974 if (!memory.IsValidVirtualAddress(addr)) {
973 return SendReply("E00"); 975 return SendReply("E00");
974 } 976 }
975 977
976 std::vector<u8> data(len); 978 std::vector<u8> data(len);
977 Memory::ReadBlock(addr, data.data(), len); 979 memory.ReadBlock(addr, data.data(), len);
978 980
979 MemToGdbHex(reply, data.data(), len); 981 MemToGdbHex(reply, data.data(), len);
980 reply[len * 2] = '\0'; 982 reply[len * 2] = '\0';
@@ -984,22 +986,23 @@ static void ReadMemory() {
984/// Modify location in memory with data received from the gdb client. 986/// Modify location in memory with data received from the gdb client.
985static void WriteMemory() { 987static void WriteMemory() {
986 auto start_offset = command_buffer + 1; 988 auto start_offset = command_buffer + 1;
987 auto addr_pos = std::find(start_offset, command_buffer + command_length, ','); 989 const auto addr_pos = std::find(start_offset, command_buffer + command_length, ',');
988 VAddr addr = HexToLong(start_offset, static_cast<u64>(addr_pos - start_offset)); 990 const VAddr addr = HexToLong(start_offset, static_cast<u64>(addr_pos - start_offset));
989 991
990 start_offset = addr_pos + 1; 992 start_offset = addr_pos + 1;
991 auto len_pos = std::find(start_offset, command_buffer + command_length, ':'); 993 const auto len_pos = std::find(start_offset, command_buffer + command_length, ':');
992 u64 len = HexToLong(start_offset, static_cast<u64>(len_pos - start_offset)); 994 const u64 len = HexToLong(start_offset, static_cast<u64>(len_pos - start_offset));
993 995
994 if (!Memory::IsValidVirtualAddress(addr)) { 996 auto& system = Core::System::GetInstance();
997 auto& memory = system.Memory();
998 if (!memory.IsValidVirtualAddress(addr)) {
995 return SendReply("E00"); 999 return SendReply("E00");
996 } 1000 }
997 1001
998 std::vector<u8> data(len); 1002 std::vector<u8> data(len);
999
1000 GdbHexToMem(data.data(), len_pos + 1, len); 1003 GdbHexToMem(data.data(), len_pos + 1, len);
1001 Memory::WriteBlock(addr, data.data(), len); 1004 memory.WriteBlock(addr, data.data(), len);
1002 Core::System::GetInstance().InvalidateCpuInstructionCaches(); 1005 system.InvalidateCpuInstructionCaches();
1003 SendReply("OK"); 1006 SendReply("OK");
1004} 1007}
1005 1008
@@ -1055,12 +1058,15 @@ static bool CommitBreakpoint(BreakpointType type, VAddr addr, u64 len) {
1055 breakpoint.active = true; 1058 breakpoint.active = true;
1056 breakpoint.addr = addr; 1059 breakpoint.addr = addr;
1057 breakpoint.len = len; 1060 breakpoint.len = len;
1058 Memory::ReadBlock(addr, breakpoint.inst.data(), breakpoint.inst.size()); 1061
1062 auto& system = Core::System::GetInstance();
1063 auto& memory = system.Memory();
1064 memory.ReadBlock(addr, breakpoint.inst.data(), breakpoint.inst.size());
1059 1065
1060 static constexpr std::array<u8, 4> btrap{0x00, 0x7d, 0x20, 0xd4}; 1066 static constexpr std::array<u8, 4> btrap{0x00, 0x7d, 0x20, 0xd4};
1061 if (type == BreakpointType::Execute) { 1067 if (type == BreakpointType::Execute) {
1062 Memory::WriteBlock(addr, btrap.data(), btrap.size()); 1068 memory.WriteBlock(addr, btrap.data(), btrap.size());
1063 Core::System::GetInstance().InvalidateCpuInstructionCaches(); 1069 system.InvalidateCpuInstructionCaches();
1064 } 1070 }
1065 p.insert({addr, breakpoint}); 1071 p.insert({addr, breakpoint});
1066 1072