Ghidra is a software reverse engineering (SRE) framework
GP-5737: Fixing bug that caused some test failures
Ryan Kurtz4257433253e5
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScript.java b/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScript.javaindex 171cca2d15..cd0ba37e1a 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScript.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/script/GhidraScript.java@@ -274,19 +274,6 @@ public abstract class GhidraScript extends FlatProgramAPI {execute(runState, new ScriptControls(runWriter, runWriter, runMonitor));}- /**- * Execute/run script with the given {@link GhidraState state} and current- * {@link ScriptControls controls} and {@link #doCleanup} afterwards.- * <p>- * NOTE: This method is not intended to be called by script writers.- *- * @param runState state object- * @throws Exception if the script excepts- */- public final void execute(GhidraState runState) throws Exception {- execute(runState, new ScriptControls(writer, errorWriter, decorateOutput, monitor));- }-/*** Execute/run script with the given {@link GhidraState state} and* {@link ScriptControls controls} and {@link #doCleanup} afterwards.@@ -587,6 +574,13 @@ public abstract class GhidraScript extends FlatProgramAPI {return state;}+ /**+ * {@return the current script controls}+ */+ public final ScriptControls getControls() {+ return new ScriptControls(writer, errorWriter, decorateOutput, monitor);+ }+/*** Set the script {@link #currentAddress}, {@link #currentLocation}, and update state object.*@@ -924,7 +918,7 @@ public abstract class GhidraScript extends FlatProgramAPI {updateStateFromVariables();}- script.execute(scriptState);+ script.execute(scriptState, getControls());if (scriptState == state) {loadVariablesFromState();diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/headless/HeadlessScript.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/headless/HeadlessScript.javaindex 35b32d85c2..1ed3f2cedc 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/headless/HeadlessScript.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/headless/HeadlessScript.java@@ -423,7 +423,7 @@ public abstract class HeadlessScript extends GhidraScript {script.setScriptArgs(scriptArguments);- script.execute(scriptState);+ script.execute(scriptState, getControls());if (scriptState == state) {loadVariablesFromState();diff --git a/Ghidra/Features/Decompiler/ghidra_scripts/ShowConstantUse.java b/Ghidra/Features/Decompiler/ghidra_scripts/ShowConstantUse.javaindex 82023094c6..94aa2adfb6 100644--- a/Ghidra/Features/Decompiler/ghidra_scripts/ShowConstantUse.java+++ b/Ghidra/Features/Decompiler/ghidra_scripts/ShowConstantUse.java@@ -330,7 +330,7 @@ public class ShowConstantUse extends GhidraScript {if (scriptSource != null) {GhidraScriptProvider provider = GhidraScriptUtil.getProvider(scriptSource);GhidraScript script = provider.getScriptInstance(scriptSource, errorWriter);- script.execute(scriptState);+ script.execute(scriptState, getControls());return;}}diff --git a/Ghidra/Features/Jython/src/main/java/ghidra/jython/JythonScript.java b/Ghidra/Features/Jython/src/main/java/ghidra/jython/JythonScript.javaindex fbf7f1e99d..b3509c1bef 100644--- a/Ghidra/Features/Jython/src/main/java/ghidra/jython/JythonScript.java+++ b/Ghidra/Features/Jython/src/main/java/ghidra/jython/JythonScript.java@@ -77,7 +77,7 @@ public class JythonScript extends GhidraScript {interpreter.execFile(jythonScript.getSourceFile(), jythonScript);}else {- ghidraScript.execute(scriptState);+ ghidraScript.execute(scriptState, getControls());}if (scriptState == state) {