From 3ea24183b98aa7c3fbff85020277470a323b13bc Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 20 Aug 2024 04:30:57 +0300 Subject: [PATCH] Improve "write" instruction detection. --- Utilities/Thread.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 54b9bacef9..5b89868293 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1929,16 +1929,20 @@ static void signal_handler(int /*sig*/, siginfo_t* info, void* uct) noexcept #elif defined(ARCH_ARM64) const bool is_executing = uptr(info->si_addr) == uptr(RIP(context)); const u32 insn = is_executing ? 0 : *reinterpret_cast(RIP(context)); - const bool is_writing = (insn & 0xbfff0000) == 0x0c000000 - || (insn & 0xbfe00000) == 0x0c800000 - || (insn & 0xbfdf0000) == 0x0d000000 - || (insn & 0xbfc00000) == 0x0d800000 - || (insn & 0x3f400000) == 0x08000000 - || (insn & 0x3bc00000) == 0x39000000 - || (insn & 0x3fc00000) == 0x3d800000 - || (insn & 0x3bc00000) == 0x38000000 - || (insn & 0x3fe00000) == 0x3c800000 - || (insn & 0x3a400000) == 0x28000000; + const bool is_writing = + (insn & 0xbfff0000) == 0x0c000000 || // STR , [, #] (store word with immediate offset) + (insn & 0xbfe00000) == 0x0c800000 || // STP , , [, #] (store pair of registers with immediate offset) + (insn & 0xbfdf0000) == 0x0d000000 || // STR , [, ] (store word with register offset) + (insn & 0xbfc00000) == 0x0d800000 || // STP , , [, ] (store pair of registers with register offset) + (insn & 0x3f400000) == 0x08000000 || // STR , [, #] (store SIMD/FP register with immediate offset) + (insn & 0x3bc00000) == 0x39000000 || // STR , [, #] (store word with immediate offset) + (insn & 0x3fc00000) == 0x3d800000 || // STR , [, ] (store SIMD/FP register with register offset) + (insn & 0x3bc00000) == 0x38000000 || // STR , [, ] (store word with register offset) + (insn & 0x3fe00000) == 0x3c800000 || // STUR , [, #] (store unprivileged register with immediate offset) + (insn & 0x3fe00000) == 0x3ca00000 || // STR , [, #] (store SIMD/FP register with immediate offset) + (insn & 0x3a400000) == 0x28000000 || // STP , , [, #] (store pair of registers with immediate offset) + (insn & 0xad000000) == 0xad000000 || // STP , , [, #] (store SIMD/FP 128-bit register pair with immediate offset) + (insn & 0xad000000) == 0xad000000; // STP , , [, #] (store SIMD/FP 64-bit register pair with immediate offset) #else #error "signal_handler not implemented"