diff options
author | Fernando S <fsahmkow27@gmail.com> | 2023-08-15 15:36:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 15:36:14 +0200 |
commit | a8c4f01f6ca040672e85faaf42a8ef12d373dd65 (patch) | |
tree | 2db0c5b56534cca4b569b5832db84fc1cebba662 /src/core | |
parent | Merge pull request #11256 from FearlessTobi/revert-10075 (diff) | |
parent | gdbstub: fixup replaced instruction bytes in memory reads (diff) | |
download | yuzu-a8c4f01f6ca040672e85faaf42a8ef12d373dd65.tar yuzu-a8c4f01f6ca040672e85faaf42a8ef12d373dd65.tar.gz yuzu-a8c4f01f6ca040672e85faaf42a8ef12d373dd65.tar.bz2 yuzu-a8c4f01f6ca040672e85faaf42a8ef12d373dd65.tar.lz yuzu-a8c4f01f6ca040672e85faaf42a8ef12d373dd65.tar.xz yuzu-a8c4f01f6ca040672e85faaf42a8ef12d373dd65.tar.zst yuzu-a8c4f01f6ca040672e85faaf42a8ef12d373dd65.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/debugger/gdbstub.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp index 0f839d5b4..e55831f27 100644 --- a/src/core/debugger/gdbstub.cpp +++ b/src/core/debugger/gdbstub.cpp @@ -263,6 +263,23 @@ void GDBStub::ExecuteCommand(std::string_view packet, std::vector<DebuggerAction std::vector<u8> mem(size); if (system.ApplicationMemory().ReadBlock(addr, mem.data(), size)) { + // Restore any bytes belonging to replaced instructions. + auto it = replaced_instructions.lower_bound(addr); + for (; it != replaced_instructions.end() && it->first < addr + size; it++) { + // Get the bytes of the instruction we previously replaced. + const u32 original_bytes = it->second; + + // Calculate where to start writing to the output buffer. + const size_t output_offset = it->first - addr; + + // Calculate how many bytes to write. + // The loop condition ensures output_offset < size. + const size_t n = std::min<size_t>(size - output_offset, sizeof(u32)); + + // Write the bytes to the output buffer. + std::memcpy(mem.data() + output_offset, &original_bytes, n); + } + SendReply(Common::HexToString(mem)); } else { SendReply(GDB_STUB_REPLY_ERR); |