forked from btraceio/btrace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtracer
More file actions
executable file
·102 lines (96 loc) · 2.67 KB
/
btracer
File metadata and controls
executable file
·102 lines (96 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! /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"`
BTRACE_HOME=`dirname "$PRG"`/..
BTRACE_HOME=`cd "$BTRACE_HOME" && pwd`
fi
usage() {
echo "btracer <options> <compiled script> <java args>"
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 <port>\t\t\tBTrace agent server port"
echo " -statsd <host>[:<port>]\tUse this StatsD server"
echo " -o <file>\t\t\tThe path to a file the btrace agent will store its output"
echo " -d <path>\t\t\tDump modified classes to the provided location"
echo " -pd <path>\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 <cp>\t\t\tAppend to bootstrap class path"
echo " -scp <cp>\t\t\tAppend to system class path"
echo " -h\t\t\t\tThis message"
exit 0
}
if [ $# -eq 0 ]
then
usage
fi
OPTIONS=
if [ "${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 -jar ${BTRACE_HOME}/build/btrace-client.jar com.sun.btrace.Main --version
exit 0
;;
-h)
usage
;;
*)
break
;;
esac
shift
done
if [ -f "${BTRACE_HOME}/build/btrace-agent.jar" ] ; then
${JAVA_HOME}/bin/java -Xshare:off -javaagent:${BTRACE_HOME}/build/btrace-agent.jar=$OPTIONS,script="$@"
else
echo "Please set BTRACE_HOME before running this script"
fi
else
echo "Please set JAVA_HOME before running this script"
exit 1
fi