Skip to content

Commit 56866ad

Browse files
farissSoufiane Fariss
and
Soufiane Fariss
authored
print environment details upon stack trace (#101)
* print environment details upon stack trace * Add Ghidrathon plugin version number * Move exception handling and whitelisting to utils.py * Renamed jeputils & reformatted env details string This commit: - renames utils.py to jeputils.py avoid confusion. - reformats environment details string as a format string - enables getVersion method to be called statically * refactor: pass exception object to log_env_details --------- Co-authored-by: Soufiane Fariss <[email protected]>
1 parent a3deefd commit 56866ad

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

Diff for: data/python/jepeval.py

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def _jepeval(line):
7979
# in the Ghidra console window
8080
import traceback
8181

82+
import jeputils
83+
8284
traceback.print_exc()
85+
jeputils.log_env_details(err)
8386

8487
return more_input_needed

Diff for: data/python/jeprunscript.py

+3
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ def jep_runscript(path):
3636
# messages in the Ghidra console window
3737
import traceback
3838

39+
import jeputils
40+
3941
traceback.print_exc()
42+
jeputils.log_env_details(err)

Diff for: data/python/jeputils.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
import platform
3+
4+
import jep
5+
import ghidrathon
6+
from java.lang import System
7+
8+
ALLOWED_EXCEPTIONS = (RuntimeError, OSError)
9+
10+
11+
def log_env_details(exc):
12+
exc_type = type(exc)
13+
if issubclass(exc_type, ALLOWED_EXCEPTIONS):
14+
print(
15+
f"Python={platform.python_version()}, "
16+
f"Arch={System.getProperty('os.arch')}, "
17+
f"OS={System.getProperty('os.name')}, "
18+
f"Ghidra={getGhidraVersion()}, "
19+
f"Java={System.getProperty('java.version')}, "
20+
f"Ghidrathon={ghidrathon.GhidrathonPlugin.getVersion()}, "
21+
f"Jep={jep.__version__}",
22+
file=sys.stderr,
23+
)

Diff for: src/main/java/ghidrathon/GhidrathonPlugin.java

+6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
public class GhidrathonPlugin extends ProgramPlugin
4747
implements InterpreterConnection, OptionsChangeListener {
4848

49+
private static final String VERSION = "4.0.0";
50+
4951
private InterpreterConsole console;
5052
private GhidrathonConsoleInputThread inputThread;
5153
private TaskMonitor interactiveTaskMonitor;
@@ -71,6 +73,10 @@ GhidrathonScript getInteractiveScript() {
7173
return interactiveScript;
7274
}
7375

76+
public static String getVersion() {
77+
return VERSION;
78+
}
79+
7480
@Override
7581
protected void init() {
7682

0 commit comments

Comments
 (0)