diff options
author | Sebastian Valle <subv2112@gmail.com> | 2017-10-08 10:11:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-08 10:11:12 -0500 |
commit | 20e19a340ca6eb2e6e2f1e80370bcc7882d027fa (patch) | |
tree | 76c81c04f06a10d5d9375038d25afd4e7eda2a46 /src/core/gdbstub/gdbstub.cpp | |
parent | 74d4050924e63f98c76570cafb5a6ad95d2ea5b1 (diff) | |
parent | 97f262c1f5c39e51d6fe2e32429610599299db60 (diff) |
Merge pull request #2991 from Subv/getpointer
Remove more usages of GetPointer.
Diffstat (limited to 'src/core/gdbstub/gdbstub.cpp')
-rw-r--r-- | src/core/gdbstub/gdbstub.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/core/gdbstub/gdbstub.cpp b/src/core/gdbstub/gdbstub.cpp index be2b2e25f..d6be16ef6 100644 --- a/src/core/gdbstub/gdbstub.cpp +++ b/src/core/gdbstub/gdbstub.cpp @@ -644,7 +644,7 @@ static void ReadMemory() { auto start_offset = command_buffer + 1; auto addr_pos = std::find(start_offset, command_buffer + command_length, ','); - PAddr addr = HexToInt(start_offset, static_cast<u32>(addr_pos - start_offset)); + VAddr addr = HexToInt(start_offset, static_cast<u32>(addr_pos - start_offset)); start_offset = addr_pos + 1; u32 len = @@ -656,12 +656,14 @@ static void ReadMemory() { SendReply("E01"); } - const u8* data = Memory::GetPointer(addr); - if (!data) { + if (!Memory::IsValidVirtualAddress(addr)) { return SendReply("E00"); } - MemToGdbHex(reply, data, len); + std::vector<u8> data(len); + Memory::ReadBlock(addr, data.data(), len); + + MemToGdbHex(reply, data.data(), len); reply[len * 2] = '\0'; SendReply(reinterpret_cast<char*>(reply)); } @@ -670,18 +672,20 @@ static void ReadMemory() { static void WriteMemory() { auto start_offset = command_buffer + 1; auto addr_pos = std::find(start_offset, command_buffer + command_length, ','); - PAddr addr = HexToInt(start_offset, static_cast<u32>(addr_pos - start_offset)); + VAddr addr = HexToInt(start_offset, static_cast<u32>(addr_pos - start_offset)); start_offset = addr_pos + 1; auto len_pos = std::find(start_offset, command_buffer + command_length, ':'); u32 len = HexToInt(start_offset, static_cast<u32>(len_pos - start_offset)); - u8* dst = Memory::GetPointer(addr); - if (!dst) { + if (!Memory::IsValidVirtualAddress(addr)) { return SendReply("E00"); } - GdbHexToMem(dst, len_pos + 1, len); + std::vector<u8> data(len); + + GdbHexToMem(data.data(), len_pos + 1, len); + Memory::WriteBlock(addr, data.data(), len); SendReply("OK"); } |