Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print environment details upon stack trace #101

Merged
merged 5 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/python/jepeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def _jepeval(line):
# in the Ghidra console window
import traceback

import jeputils

traceback.print_exc()
jeputils.log_env_details(type(err))
fariss marked this conversation as resolved.
Show resolved Hide resolved

return more_input_needed
3 changes: 3 additions & 0 deletions data/python/jeprunscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ def jep_runscript(path):
# messages in the Ghidra console window
import traceback

import jeputils

traceback.print_exc()
jeputils.log_env_details(type(err))
fariss marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 22 additions & 0 deletions data/python/jeputils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys
import platform

import jep
import ghidrathon
from java.lang import System

ALLOWED_EXCEPTIONS = [RuntimeError, OSError]
fariss marked this conversation as resolved.
Show resolved Hide resolved


def log_env_details(exc_type):
if any(issubclass(exc_type, exc_class) for exc_class in ALLOWED_EXCEPTIONS):
fariss marked this conversation as resolved.
Show resolved Hide resolved
print(
f"Python={platform.python_version()}, "
f"Arch={System.getProperty('os.arch')}, "
f"OS={System.getProperty('os.name')}, "
f"Ghidra={getGhidraVersion()}, "
f"Java={System.getProperty('java.version')}, "
f"Ghidrathon={ghidrathon.GhidrathonPlugin.getVersion()}, "
f"Jep={jep.__version__}",
file=sys.stderr,
)
6 changes: 6 additions & 0 deletions src/main/java/ghidrathon/GhidrathonPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
public class GhidrathonPlugin extends ProgramPlugin
implements InterpreterConnection, OptionsChangeListener {

private static final String VERSION = "4.0.0";

private InterpreterConsole console;
private GhidrathonConsoleInputThread inputThread;
private TaskMonitor interactiveTaskMonitor;
Expand All @@ -71,6 +73,10 @@ GhidrathonScript getInteractiveScript() {
return interactiveScript;
}

public static String getVersion() {
return VERSION;
}

@Override
protected void init() {

Expand Down
Loading