Ghidra is a software reverse engineering (SRE) framework
GP-1035: Python interpreter code completion now works prior to executing any python statements
Ryan Kurtz21d8d1813437
diff --git a/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java b/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.javaindex fd734d00ce..5584e61a86 100644--- a/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java+++ b/Ghidra/Features/Python/src/main/java/ghidra/python/GhidraPythonInterpreter.java@@ -332,7 +332,7 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {** @param script The script whose class hierarchy is to be used for injection.*/- private void injectScriptHierarchy(PythonScript script) {+ void injectScriptHierarchy(PythonScript script) {if (script == null) {return;diff --git a/Ghidra/Features/Python/src/main/java/ghidra/python/PythonPlugin.java b/Ghidra/Features/Python/src/main/java/ghidra/python/PythonPlugin.javaindex c0da0b8734..723fa34452 100644--- a/Ghidra/Features/Python/src/main/java/ghidra/python/PythonPlugin.java+++ b/Ghidra/Features/Python/src/main/java/ghidra/python/PythonPlugin.java@@ -226,8 +226,14 @@ public class PythonPlugin extends ProgramPlugin// Setup the PythonScript describing the state of the interactive prompt.// This allows things like currentProgram and currentAddress to dynamically reflect- // what's happening in the listing.+ // what's happening in the listing. Injecting the script hierarchy early here allows+ // code completion to work before commands are entered.interactiveScript = new PythonScript();+ interactiveScript.set(+ new GhidraState(tool, tool.getProject(), getCurrentProgram(), getProgramLocation(),+ getProgramSelection(), getProgramHighlight()),+ interactiveTaskMonitor, new PrintWriter(getConsole().getStdOut()));+ interpreter.injectScriptHierarchy(interactiveScript);interactiveTaskMonitor = new PythonInteractiveTaskMonitor(console.getStdOut());// Start the input thread that receives python commands to execute.