From 043a6aa3bbb0a2b5fd618cc3e6f3e38471e11baf Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Tue, 17 Jan 2023 13:29:44 -0500 Subject: [PATCH] GP-2715: Call modifier.initialExecuteCallback only once per thread --- .../java/ghidra/pcode/emu/ModifiedPcodeThread.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/pcode/emu/ModifiedPcodeThread.java b/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/pcode/emu/ModifiedPcodeThread.java index b967904182..e08771f78e 100644 --- a/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/pcode/emu/ModifiedPcodeThread.java +++ b/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/pcode/emu/ModifiedPcodeThread.java @@ -113,7 +113,15 @@ public class ModifiedPcodeThread extends DefaultPcodeThread { } } - // Part of the glue that makes existing state modifiers work in new emulation framework + /** + * Part of the glue that makes existing state modifiers work in new emulation framework + * + *

+ * NOTE: These are instantiated one per thread, rather than sharing one across the + * machine, because some of the modifiers are stateful and assume a single-threaded model. The + * best way to mitigate that assumption is to ensure a modifier is responsible for only a single + * thread, even though a machine may have multiple threads. + */ protected final EmulateInstructionStateModifier modifier; protected final Emulate emulate; @@ -194,7 +202,8 @@ public class ModifiedPcodeThread extends DefaultPcodeThread { } @Override - protected void preExecuteInstruction() { + public void reInitialize() { + super.reInitialize(); if (modifier != null) { savedCounter = getCounter(); modifier.initialExecuteCallback(emulate, savedCounter, getContext());