diff options
| author | 2019-11-26 13:46:41 -0500 | |
|---|---|---|
| committer | 2019-11-26 21:53:34 -0500 | |
| commit | e58748fd802dc069e90928d12d4db9ff994a869d (patch) | |
| tree | 152c306a9a51f0ba49e2a34d1dc0db9eb2923013 /src/core/gdbstub/gdbstub.cpp | |
| parent | core/memory: Migrate over memory mapping functions to the new Memory class (diff) | |
| download | yuzu-e58748fd802dc069e90928d12d4db9ff994a869d.tar.gz yuzu-e58748fd802dc069e90928d12d4db9ff994a869d.tar.xz yuzu-e58748fd802dc069e90928d12d4db9ff994a869d.zip | |
core/memory: Migrate over address checking functions to the new Memory class
A fairly straightforward migration. These member functions can just be
mostly moved verbatim with minor changes. We already have the necessary
plumbing in places that they're used.
IsKernelVirtualAddress() can remain a non-member function, since it
doesn't rely on class state in any form.
Diffstat (limited to 'src/core/gdbstub/gdbstub.cpp')
| -rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index 54ed680db..78e44f3bd 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp | |||
| @@ -969,7 +969,8 @@ static void ReadMemory() { | |||
| 969 | SendReply("E01"); | 969 | SendReply("E01"); |
| 970 | } | 970 | } |
| 971 | 971 | ||
| 972 | if (!Memory::IsValidVirtualAddress(addr)) { | 972 | const auto& memory = Core::System::GetInstance().Memory(); |
| 973 | if (!memory.IsValidVirtualAddress(addr)) { | ||
| 973 | return SendReply("E00"); | 974 | return SendReply("E00"); |
| 974 | } | 975 | } |
| 975 | 976 | ||
| @@ -984,22 +985,23 @@ static void ReadMemory() { | |||
| 984 | /// Modify location in memory with data received from the gdb client. | 985 | /// Modify location in memory with data received from the gdb client. |
| 985 | static void WriteMemory() { | 986 | static void WriteMemory() { |
| 986 | auto start_offset = command_buffer + 1; | 987 | auto start_offset = command_buffer + 1; |
| 987 | auto addr_pos = std::find(start_offset, command_buffer + command_length, ','); | 988 | 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)); | 989 | const VAddr addr = HexToLong(start_offset, static_cast<u64>(addr_pos - start_offset)); |
| 989 | 990 | ||
| 990 | start_offset = addr_pos + 1; | 991 | start_offset = addr_pos + 1; |
| 991 | auto len_pos = std::find(start_offset, command_buffer + command_length, ':'); | 992 | 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)); | 993 | const u64 len = HexToLong(start_offset, static_cast<u64>(len_pos - start_offset)); |
| 993 | 994 | ||
| 994 | if (!Memory::IsValidVirtualAddress(addr)) { | 995 | auto& system = Core::System::GetInstance(); |
| 996 | const auto& memory = system.Memory(); | ||
| 997 | if (!memory.IsValidVirtualAddress(addr)) { | ||
| 995 | return SendReply("E00"); | 998 | return SendReply("E00"); |
| 996 | } | 999 | } |
| 997 | 1000 | ||
| 998 | std::vector<u8> data(len); | 1001 | std::vector<u8> data(len); |
| 999 | |||
| 1000 | GdbHexToMem(data.data(), len_pos + 1, len); | 1002 | GdbHexToMem(data.data(), len_pos + 1, len); |
| 1001 | Memory::WriteBlock(addr, data.data(), len); | 1003 | Memory::WriteBlock(addr, data.data(), len); |
| 1002 | Core::System::GetInstance().InvalidateCpuInstructionCaches(); | 1004 | system.InvalidateCpuInstructionCaches(); |
| 1003 | SendReply("OK"); | 1005 | SendReply("OK"); |
| 1004 | } | 1006 | } |
| 1005 | 1007 | ||