bin.btracep Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of btrace-boot Show documentation
Show all versions of btrace-boot Show documentation
BTrace: A safe, dynamic tracing tool for the Java platform
#! /bin/sh
if [ -z "$BTRACE_HOME" -o ! -d "$BTRACE_HOME" ]; then
# resolve links - $0 could be a link to btrace's home
PRG="$0"
progname=$(basename "$0")
PRG=$(readlink "$PRG")
if [ -z "$PRG" ]; then
PRG=$0
fi
BTRACE_HOME=$(dirname "$PRG")/..
BTRACE_HOME=$(cd "$BTRACE_HOME" && pwd)
fi
JAVA_ARGS="-XX:+IgnoreUnrecognizedVMOptions"
if [ -d "${JAVA_HOME}/jmods" ]; then
JAVA_ARGS="$JAVA_ARGS -XX:+AllowRedefinitionToAddDeleteMethods"
JAVA_ARGS="$JAVA_ARGS --add-exports jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED"
fi
if [ -f "${BTRACE_HOME}/libs/btrace-client.jar" ]; then
if [ -d "${JAVA_HOME}" ]; then
if [ "$1" = "--version" ]; then
${JAVA_HOME}/bin/java ${JAVA_ARGS} -cp ${BTRACE_HOME}/libs/btrace-client.jar org.openjdk.btrace.client.Main --version
exit 0
fi
TOOLS_JAR="$JAVA_HOME/lib/tools.jar"
if [ ! -f "$TOOLS_JAR" ]; then
# probably running on JRE - try to localize JDK
TOOLS_JAR="$JAVA_HOME/../lib/tools.jar"
fi
if [ ! -f "${TOOLS_JAR}" ] && [ ! -d "${JAVA_HOME}/jmods" ]; then
# old Java versions on MacOS don't have tools.jar at all
case "$(uname)" in
Darwin*)
if [ -f /System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Classes/classes.jar ]; then
TOOLS_JAR="/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Classes/classes.jar"
else
TOOLS_JAR="${JAVA_HOME}/lib/tools.jar"
fi
;;
*)
TOOLS_JAR="${JAVA_HOME}/lib/tools.jar"
;;
esac
fi
if [ ! -f "${TOOLS_JAR}" ] && [ ! -d "${JAVA_HOME}/jmods" ]; then
# in non-jigsaw world TOOLS_JAR must point to a valid file
echo "Unable to locate tools.jar. Please, make sure JAVA_HOME points to a valid JDK installation"
exit 1
fi
${JAVA_HOME}/bin/java ${JAVA_ARGS} -cp ${BTRACE_HOME}/libs/btrace-client.jar:${TOOLS_JAR} org.openjdk.btrace.client.ProbePrinter $*
else
echo "Please set a valid JAVA_HOME before running this script"
exit 1
fi
else
echo "Please set BTRACE_HOME before running this script"
exit 1
fi