From 8a08bb46eedbd24315e0835e64cee94f20c6cca1 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Mon, 25 May 2026 08:31:31 -0700 Subject: [PATCH] cpu_patches: Log full instruction on JIT patch failure. (#4477) --- src/core/cpu_patches.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/cpu_patches.cpp b/src/core/cpu_patches.cpp index f6a4f7620..d31985775 100644 --- a/src/core/cpu_patches.cpp +++ b/src/core/cpu_patches.cpp @@ -788,10 +788,16 @@ static bool PatchesIllegalInstructionHandler(void* context) { ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT]; const auto status = Common::Decoder::Instance()->decodeInstruction(instruction, operands, code_address); - LOG_ERROR(Core, "Failed to patch address {:x} -- mnemonic: {}", - reinterpret_cast(code_address), - ZYAN_SUCCESS(status) ? ZydisMnemonicGetString(instruction.mnemonic) - : "Failed to decode"); + if (ZYAN_SUCCESS(status)) { + const auto disassembled = Common::Decoder::Instance()->disassembleInst( + instruction, operands, std::bit_cast(code_address)); + LOG_ERROR(Core, "Failed to patch address {:x} -- mnemonic: {}, instruction: {}", + reinterpret_cast(code_address), + ZydisMnemonicGetString(instruction.mnemonic), disassembled); + } else { + LOG_ERROR(Core, "Failed to patch address {:x} -- mnemonic: (failed to decode)", + reinterpret_cast(code_address)); + } return false; } }