From 9925ce03752d24d9c1129009e1d8cfbeb394271f Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Tue, 15 Aug 2023 17:19:06 +0200 Subject: [PATCH] early-access version 3810 --- README.md | 2 +- src/core/debugger/gdbstub.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 163f4996e..d23a9e986 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3809. +This is the source code for early-access 3810. ## Legal Notice diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp index 16e1e9075..865ed809c 100755 --- 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 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 - 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);