summaryrefslogtreecommitdiff
path: root/src/core/gdbstub/gdbstub.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2019-11-26 17:39:57 -0500
committerGravatar Lioncash2019-11-26 21:55:39 -0500
commite4c381b8850db96f162cfcf2cbe28b0e7c1f76f1 (patch)
tree14b95ea207543f3884558ebdf8673a511bf64dc3 /src/core/gdbstub/gdbstub.cpp
parentcore/memory: Migrate over Read{8, 16, 32, 64, Block} to the Memory class (diff)
downloadyuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.tar.gz
yuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.tar.xz
yuzu-e4c381b8850db96f162cfcf2cbe28b0e7c1f76f1.zip
core/memory: Migrate over Write{8, 16, 32, 64, Block} to the Memory class
The Write functions are used slightly less than the Read functions, which make these a bit nicer to move over. The only adjustments we really need to make here are to Dynarmic's exclusive monitor instance. We need to keep a reference to the currently active memory instance to perform exclusive read/write operations.
Diffstat (limited to 'src/core/gdbstub/gdbstub.cpp')
-rw-r--r--src/core/gdbstub/gdbstub.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp
index 1c74a44d8..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}
@@ -993,14 +994,14 @@ static void WriteMemory() {
993 const 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));
994 995
995 auto& system = Core::System::GetInstance(); 996 auto& system = Core::System::GetInstance();
996 const auto& memory = system.Memory(); 997 auto& memory = system.Memory();
997 if (!memory.IsValidVirtualAddress(addr)) { 998 if (!memory.IsValidVirtualAddress(addr)) {
998 return SendReply("E00"); 999 return SendReply("E00");
999 } 1000 }
1000 1001
1001 std::vector<u8> data(len); 1002 std::vector<u8> data(len);
1002 GdbHexToMem(data.data(), len_pos + 1, len); 1003 GdbHexToMem(data.data(), len_pos + 1, len);
1003 Memory::WriteBlock(addr, data.data(), len); 1004 memory.WriteBlock(addr, data.data(), len);
1004 system.InvalidateCpuInstructionCaches(); 1005 system.InvalidateCpuInstructionCaches();
1005 SendReply("OK"); 1006 SendReply("OK");
1006} 1007}
@@ -1058,13 +1059,14 @@ static bool CommitBreakpoint(BreakpointType type, VAddr addr, u64 len) {
1058 breakpoint.addr = addr; 1059 breakpoint.addr = addr;
1059 breakpoint.len = len; 1060 breakpoint.len = len;
1060 1061
1061 auto& memory = Core::System::GetInstance().Memory(); 1062 auto& system = Core::System::GetInstance();
1063 auto& memory = system.Memory();
1062 memory.ReadBlock(addr, breakpoint.inst.data(), breakpoint.inst.size()); 1064 memory.ReadBlock(addr, breakpoint.inst.data(), breakpoint.inst.size());
1063 1065
1064 static constexpr std::array<u8, 4> btrap{0x00, 0x7d, 0x20, 0xd4}; 1066 static constexpr std::array<u8, 4> btrap{0x00, 0x7d, 0x20, 0xd4};
1065 if (type == BreakpointType::Execute) { 1067 if (type == BreakpointType::Execute) {
1066 Memory::WriteBlock(addr, btrap.data(), btrap.size()); 1068 memory.WriteBlock(addr, btrap.data(), btrap.size());
1067 Core::System::GetInstance().InvalidateCpuInstructionCaches(); 1069 system.InvalidateCpuInstructionCaches();
1068 } 1070 }
1069 p.insert({addr, breakpoint}); 1071 p.insert({addr, breakpoint});
1070 1072