GP-6350: You can now set Ghidra Java options via an assortment of environment variables

This commit is contained in:
Ryan Kurtz
2026-01-22 11:22:02 -05:00
parent 28762369cd
commit b1768c6622
13 changed files with 77 additions and 42 deletions
@@ -16,6 +16,14 @@ MAXMEM_DEFAULT=2G
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_HEADLESS_MAXMEM=${GHIDRA_HEADLESS_MAXMEM:=${GHIDRA_MAXMEM}}
# Limit the # of garbage collection and JIT compiler threads in case many headless
# instances are run in parallel. By default, Java will assign one thread per core
# which does not scale well on servers with many cores.
VMARG_LIST="-XX:ParallelGCThreads=2 -XX:CICompilerCount=2 -Djava.awt.headless=true"
# Apply Java options from externally set environment variables
VMARG_LIST="${VMARG_LIST} ${GHIDRA_JAVA_OPTIONS} ${GHIDRA_HEADLESS_JAVA_OPTIONS}"
# Launch mode can be changed to one of the following: fg, debug, debug-suspend
LAUNCH_MODE=fg
@@ -23,11 +31,6 @@ LAUNCH_MODE=fg
# NOTE: This variable is ignored if not launching in a debugging mode.
DEBUG_ADDRESS=127.0.0.1:13002
# Limit the # of garbage collection and JIT compiler threads in case many headless
# instances are run in parallel. By default, Java will assign one thread per core
# which does not scale well on servers with many cores.
VMARG_LIST="-XX:ParallelGCThreads=2 -XX:CICompilerCount=2 -Djava.awt.headless=true "
# Resolve symbolic link if present and get the directory this script lives in.
# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the
+6 -2
View File
@@ -13,11 +13,15 @@ MAXMEM_DEFAULT=
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_BSIM_MAXMEM=${GHIDRA_BSIM_MAXMEM:=${GHIDRA_MAXMEM}}
# Force Java headless mode
VMARG_LIST="-Djava.awt.headless=true"
# Apply Java options from externally set environment variables
VMARG_LIST="${VMARG_LIST} ${GHIDRA_JAVA_OPTIONS} ${GHIDRA_BSIM_JAVA_OPTIONS}"
# launch mode (fg, bg, debug, debug-suspend)
LAUNCH_MODE=fg
VMARG_LIST="-Djava.awt.headless=true "
# Resolve symbolic link if present and get the directory this script lives in.
# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the
@@ -15,6 +15,9 @@ MAXMEM_DEFAULT=
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_GUI_MAXMEM=${GHIDRA_GUI_MAXMEM:=${GHIDRA_MAXMEM}}
# Apply Java options from externally set environment variables
VMARG_LIST="${GHIDRA_JAVA_OPTIONS} ${GHIDRA_GUI_JAVA_OPTIONS} "
# Debug launch mode can be changed to one of the following: debug, debug-suspend
LAUNCH_MODE=debug
@@ -31,4 +34,4 @@ SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Ghidra in debug mode
# DEBUG_ADDRESS set via environment for launch.sh
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${GHIDRA_GUI_MAXMEM}" "" ghidra.GhidraRun "$@"
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${GHIDRA_GUI_MAXMEM}" "${VMARG_LIST}" ghidra.GhidraRun "$@"
@@ -15,6 +15,9 @@ MAXMEM_DEFAULT=
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_JSHELL_MAXMEM=${GHIDRA_JSHELL_MAXMEM:=${GHIDRA_MAXMEM}}
# Apply Java options from externally set environment variables
VMARG_LIST="${GHIDRA_JAVA_OPTIONS} ${GHIDRA_JSHELL_JAVA_OPTIONS} "
# Resolve symbolic link if present and get the directory this script lives in.
# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the
@@ -23,4 +26,4 @@ SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo
SCRIPT_DIR="${SCRIPT_FILE%/*}"
# Launch Ghidra
"${SCRIPT_DIR}"/launch.sh fg jdk Ghidra-JShell "${GHIDRA_JSHELL_MAXMEM}" "" ghidra.JShellRun "$@"
"${SCRIPT_DIR}"/launch.sh fg jdk Ghidra-JShell "${GHIDRA_JSHELL_MAXMEM}" "${VMARG_LIST}" ghidra.JShellRun "$@"
@@ -15,6 +15,14 @@ MAXMEM_DEFAULT=
GHIDRA_MAXMEM=${GHIDRA_MAXMEM:=${MAXMEM_DEFAULT}}
GHIDRA_JYTHON_MAXMEM=${GHIDRA_JYTHON_MAXMEM:=${GHIDRA_MAXMEM}}
# Limit the # of garbage collection and JIT compiler threads in case many python
# instances are run in parallel. By default, Java will assign one thread per core
# which does not scale well on servers with many cores.
VMARG_LIST="-XX:ParallelGCThreads=2 -XX:CICompilerCount=2 -Djava.awt.headless=true"
# Apply Java options from externally set environment variables
VMARG_LIST="${VMARG_LIST} ${GHIDRA_JAVA_OPTIONS} ${GHIDRA_JYTHON_JAVA_OPTIONS}"
# Launch mode can be changed to one of the following: fg, debug, debug-suspend
LAUNCH_MODE=fg
@@ -22,15 +30,6 @@ LAUNCH_MODE=fg
# NOTE: This variable is ignored if not launching in a debugging mode.
DEBUG_ADDRESS=127.0.0.1:13002
# Limit the # of garbage collection and JIT compiler threads in case many python
# instances are run in parallel. By default, Java will assign one thread per core
# which does not scale well on servers with many cores.
VMARG_LIST="-XX:ParallelGCThreads=2 "
VMARG_LIST+="-XX:CICompilerCount=2 "
# Prevent the shell losing focus when Ghidra initializes
VMARG_LIST+="-Djava.awt.headless=true "
# Resolve symbolic link if present and get the directory this script lives in.
# NOTE: "readlink -f" is best but works on Linux only, "readlink" will only work if your PWD
# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the