All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bin.btracer Maven / Gradle / Ivy

There is a newer version: 2.2.5
Show newest version
#! /bin/sh

if [ -z "$BTRACE_HOME" ] || [ ! -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

usage() {
  echo "btracer   "
  echo "Options:"
  echo "    --version\t\t\tShow BTrace version"
  echo "    -v\t\t\t\tRun in verbose mode"
  echo "    -u\t\t\t\tRun in unsafe mode"
  echo "    -p \t\t\tBTrace agent server port"
  echo "    -statsd [:]\tUse this StatsD server"
  echo "    -o \t\t\tThe path to a file the btrace agent will store its output"
  echo "    -d \t\t\tDump modified classes to the provided location"
  echo "    -pd \t\t\tSearch for the probe XML descriptors here"
  echo "    --noserver\t\t\tDon't start the socket server"
  echo "    --stdout\t\t\tRedirect the btrace output to stdout instead of writing it to an arbitrary file"
  echo "    -bcp \t\t\tAppend to bootstrap class path"
  echo "    -scp \t\t\tAppend to system class path"
  echo "    -h\t\t\t\tThis message"
  exit 0
}

if [ $# -eq 0 ]; then
  usage
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

OPTIONS=

if [ -d "${JAVA_HOME}" ]; then
  while [ true ]; do
    case $1 in
    -v)
      OPTIONS="debug=true,$OPTIONS"
      ;;
    -u)
      OPTIONS="unsafe=true,$OPTIONS"
      ;;
    -p)
      OPTIONS="port=$2,$OPTIONS"
      shift
      ;;
    -d)
      OPTIONS="dumpClasses=true,dumpDir=$2,$OPTIONS"
      shift
      ;;
    -o)
      OPTIONS="scriptOutputFile=$2,$OPTIONS"
      shift
      ;;
    -pd)
      OPTIONS="probeDescPath=$2,$OPTIONS"
      shift
      ;;
    -bcp)
      OPTIONS="bootClassPath=$2,$OPTIONS"
      shift
      ;;
    -scp)
      OPTIONS="systemClassPath=$2,$OPTIONS"
      shift
      ;;
    -statsd)
      OPTIONS="statsd=$2,$OPTIONS"
      ;;
    --noserver)
      OPTIONS="noServer=true,$OPTIONS"
      ;;
    --stdout)
      OPTIONS="stdout=true,$OPTIONS"
      ;;
    --version)
      $JAVA_HOME/bin/java ${JAVA_ARGS} -cp ${BTRACE_HOME}/libs/btrace-client.jar org.openjdk.btrace.client.Main --version
      exit 0
      ;;
    -h)
      usage
      ;;
    *)
      break
      ;;
    esac
    shift
  done

  if [ -f "${BTRACE_HOME}/libs/btrace-agent.jar" ]; then
    ${JAVA_HOME}/bin/java -Xshare:off ${JAVA_ARGS} -javaagent:${BTRACE_HOME}/libs/btrace-agent.jar=$OPTIONS,script="$@"
  else
    echo "Please set BTRACE_HOME before running this script"
  fi
else
  echo "Please set a valid JAVA_HOME before running this script"
  exit 1
fi




© 2015 - 2024 Weber Informatics LLC | Privacy Policy