annotate agent/test/jdi/runsa.sh @ 6782:5a98bf7d847b

6879063: SA should use hsdis for disassembly Summary: We should in SA to use hsdis for it like the JVM does to replace the current java based disassembler. Reviewed-by: twisti, jrose, sla Contributed-by: yumin.qi@oracle.com
author minqi
date Mon, 24 Sep 2012 12:44:00 -0700
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 #!/bin/ksh
a61af66fc99e Initial load
duke
parents:
diff changeset
2 #
6782
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 1552
diff changeset
3 # Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
5 #
a61af66fc99e Initial load
duke
parents:
diff changeset
6 # This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
7 # under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
8 # published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
9 #
a61af66fc99e Initial load
duke
parents:
diff changeset
10 # This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
13 # version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
14 # accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
15 #
a61af66fc99e Initial load
duke
parents:
diff changeset
16 # You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
17 # 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
19 #
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 # or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
22 # questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
23 #
a61af66fc99e Initial load
duke
parents:
diff changeset
24 #
a61af66fc99e Initial load
duke
parents:
diff changeset
25
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 # This jdk must be hopper or better; it must have the
a61af66fc99e Initial load
duke
parents:
diff changeset
28 # SA connectors in VirtualMachineManagerImpl.
a61af66fc99e Initial load
duke
parents:
diff changeset
29 jdk=/java/re/jdk/1.4.1/promoted/latest/binaries/solaris-sparc
a61af66fc99e Initial load
duke
parents:
diff changeset
30 #jdk=/net/mmm/export/mmm/jdk1.4fcs.sa
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 doUsage()
a61af66fc99e Initial load
duke
parents:
diff changeset
33 {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 cat <<EOF
a61af66fc99e Initial load
duke
parents:
diff changeset
35 Run sagclient.class using Serviceability Agent to talk to a corefile/pid/debugserver.
a61af66fc99e Initial load
duke
parents:
diff changeset
36 Usage: runsa.sh [-jdk <jdk-pathname>] [-jdb] [ -jdbx ] [ -d64 ] [ -remote ] [ pid | corefile | debugserver ]
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 -jdk means to use that jdk. Default is 1.4.1/latest.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 -jdbx means to run it under jdbx
a61af66fc99e Initial load
duke
parents:
diff changeset
40 -jdb means to connect using jdb instead of the sagclient program.
a61af66fc99e Initial load
duke
parents:
diff changeset
41 -remote debugserver means you want to connect to a remote debug server
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 The corefile must have been produced by the same java as is running SA.
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 EOF
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 if [ $# = 0 ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
49 doUsage
a61af66fc99e Initial load
duke
parents:
diff changeset
50 exit 1
a61af66fc99e Initial load
duke
parents:
diff changeset
51 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 # License file for development version of dbx
a61af66fc99e Initial load
duke
parents:
diff changeset
54 #LM_LICENSE_FILE=7588@extend.eng:/usr/dist/local/config/sparcworks/license.dat:7588@setlicense
a61af66fc99e Initial load
duke
parents:
diff changeset
55 #export LM_LICENSE_FILE
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 do=
a61af66fc99e Initial load
duke
parents:
diff changeset
58 args=
a61af66fc99e Initial load
duke
parents:
diff changeset
59 theClass=sagclient
a61af66fc99e Initial load
duke
parents:
diff changeset
60 javaArgs=
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 while [ $# != 0 ] ; do
a61af66fc99e Initial load
duke
parents:
diff changeset
63 case $1 in
a61af66fc99e Initial load
duke
parents:
diff changeset
64 -vv)
a61af66fc99e Initial load
duke
parents:
diff changeset
65 set -x
a61af66fc99e Initial load
duke
parents:
diff changeset
66 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 -jdk)
a61af66fc99e Initial load
duke
parents:
diff changeset
68 jdk=$2
a61af66fc99e Initial load
duke
parents:
diff changeset
69 shift
a61af66fc99e Initial load
duke
parents:
diff changeset
70 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 -jdbx)
a61af66fc99e Initial load
duke
parents:
diff changeset
72 do=jdbx
a61af66fc99e Initial load
duke
parents:
diff changeset
73 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 -jdb)
a61af66fc99e Initial load
duke
parents:
diff changeset
75 do=jdb
a61af66fc99e Initial load
duke
parents:
diff changeset
76 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 -help | help)
a61af66fc99e Initial load
duke
parents:
diff changeset
78 doUsage
a61af66fc99e Initial load
duke
parents:
diff changeset
79 exit
a61af66fc99e Initial load
duke
parents:
diff changeset
80 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 -d64)
a61af66fc99e Initial load
duke
parents:
diff changeset
82 d64=-d64
a61af66fc99e Initial load
duke
parents:
diff changeset
83 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 -remote)
a61af66fc99e Initial load
duke
parents:
diff changeset
85 shift
a61af66fc99e Initial load
duke
parents:
diff changeset
86 args="$1"
a61af66fc99e Initial load
duke
parents:
diff changeset
87 do=remote
a61af66fc99e Initial load
duke
parents:
diff changeset
88 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 -*)
a61af66fc99e Initial load
duke
parents:
diff changeset
90 javaArgs="$javaArgs $1"
a61af66fc99e Initial load
duke
parents:
diff changeset
91 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 *)
a61af66fc99e Initial load
duke
parents:
diff changeset
93 echo "$1" | grep -s '^[0-9]*$' > /dev/null
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if [ $? = 0 ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
95 # it is a pid
a61af66fc99e Initial load
duke
parents:
diff changeset
96 args="$args $1"
a61af66fc99e Initial load
duke
parents:
diff changeset
97 else
a61af66fc99e Initial load
duke
parents:
diff changeset
98 # It is a core.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 # We have to pass the name of the program that produced the
a61af66fc99e Initial load
duke
parents:
diff changeset
100 # core, and the core file itself.
a61af66fc99e Initial load
duke
parents:
diff changeset
101 args="$jdk/bin/java $1"
a61af66fc99e Initial load
duke
parents:
diff changeset
102 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
103 ;;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 esac
a61af66fc99e Initial load
duke
parents:
diff changeset
105 shift
a61af66fc99e Initial load
duke
parents:
diff changeset
106 done
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if [ -z "$jdk" ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
109 error "--Error: runsa.sh: Must specify -jdk <jdk-pathname>."
a61af66fc99e Initial load
duke
parents:
diff changeset
110 error " Do runsa.sh -help for more info"
a61af66fc99e Initial load
duke
parents:
diff changeset
111 exit 1
a61af66fc99e Initial load
duke
parents:
diff changeset
112 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 set -x
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 # If jjh makes this, then the classes are in .../build/agent.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 # if someone else does, they are in .
a61af66fc99e Initial load
duke
parents:
diff changeset
118 classesDir=../../../../../../build/agent
a61af66fc99e Initial load
duke
parents:
diff changeset
119 if [ ! -r $classesDir ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
120 classesDir=.
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if [ ! -r $classesDir ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
122 echo "-- Error: runsa.sh can't find the SA classes"
a61af66fc99e Initial load
duke
parents:
diff changeset
123 exit 1
a61af66fc99e Initial load
duke
parents:
diff changeset
124 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
125 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
126 #javacp="/net/mmm/export/mmm/ws/sabaseline/build/solaris/solaris_sparc_compiler1/generated/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir"
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 javacp="$jdk/lib/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir"
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 extraArgs="-showversion $javaArgs"
a61af66fc99e Initial load
duke
parents:
diff changeset
132 #extraArgs="-DdbxSvcAgentDSOPathName=/net/mmm/export/mmm/ws/m/b2/sa/src/os/solaris/agent/64bit/libsvc_agent_dbx.so $extraArgs"
a61af66fc99e Initial load
duke
parents:
diff changeset
133 #extraArgs="-DdbxSvcAgentDSOPathName=/net/jano.eng/export/disk05/hotspot/sa/solaris/sparcv9/lib/libsvc_agent_dbx.so $extraArgs"
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 mkdir -p workdir
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if [ sagclient.java -nt ./workdir/sagclient.class ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
137 $jdk/bin/javac -d ./workdir -classpath $javacp sagclient.java
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if [ $? != 0 ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
139 exit 1
a61af66fc99e Initial load
duke
parents:
diff changeset
140 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
141 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if [ sagdoit.java -nt ./workdir/sagdoit.class ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
143 $jdk/bin/javac -d ./workdir -classpath $javacp sagdoit.java
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if [ $? != 0 ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
145 exit 1
a61af66fc99e Initial load
duke
parents:
diff changeset
146 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
147 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 if [ "$do" = jdbx ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
150 set -x
a61af66fc99e Initial load
duke
parents:
diff changeset
151 dbx=/net/sparcworks.eng/export/set/sparcworks2/dbx_70_nightly/dev/buildbin/Derived-sparc-S2-opt/bin/dbx
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 # Have to do this export for jdbx to work. -cp and -classpath don't work.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 CLASSPATH=$javacp
a61af66fc99e Initial load
duke
parents:
diff changeset
155 export CLASSPATH
a61af66fc99e Initial load
duke
parents:
diff changeset
156 #extraArgs="-Djava.class.path=$mhs/../sa/build/agent sun.jvm.hotspot.HSDB $*"
a61af66fc99e Initial load
duke
parents:
diff changeset
157 jvm_invocation="$jdk/bin/java -Xdebug \
a61af66fc99e Initial load
duke
parents:
diff changeset
158 -Dsun.boot.class.path=$jdk/classes \
a61af66fc99e Initial load
duke
parents:
diff changeset
159 $extraArgs"
a61af66fc99e Initial load
duke
parents:
diff changeset
160 #export jvm_invocation
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 JAVASRCPATH=$mhs/../sa/src/share/vm/agent
a61af66fc99e Initial load
duke
parents:
diff changeset
163 export JAVASRCPATH
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 #operand is pathname of .class file, eg ./jj.class.
a61af66fc99e Initial load
duke
parents:
diff changeset
166 echo run $args
a61af66fc99e Initial load
duke
parents:
diff changeset
167 clss=`echo $theClass | sed -e 's@\.@/@'`
a61af66fc99e Initial load
duke
parents:
diff changeset
168 if [ -r ./workdir/$clss.class ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
169 # kludge for running sagclient
a61af66fc99e Initial load
duke
parents:
diff changeset
170 $dbx ./workdir/$clss.class
a61af66fc99e Initial load
duke
parents:
diff changeset
171 else
a61af66fc99e Initial load
duke
parents:
diff changeset
172 # kludge for running HSDB
a61af66fc99e Initial load
duke
parents:
diff changeset
173 $dbx $mhs/../sa/build/agent/$clss.class
a61af66fc99e Initial load
duke
parents:
diff changeset
174 fi
a61af66fc99e Initial load
duke
parents:
diff changeset
175 elif [ "$do" = jdb ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
176 # This hasn't been tested.
a61af66fc99e Initial load
duke
parents:
diff changeset
177 $jdk/bin/jdb -J-Xbootclasspath/a:$classesDir -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector:core=sagcore
a61af66fc99e Initial load
duke
parents:
diff changeset
178 elif [ "$do" = remote ] ; then
a61af66fc99e Initial load
duke
parents:
diff changeset
179 $jdk/bin/java $d64 -Djava.class.path=$javacp $extraArgs $theClass $args
a61af66fc99e Initial load
duke
parents:
diff changeset
180 else
a61af66fc99e Initial load
duke
parents:
diff changeset
181 $jdk/bin/java $d64 -Djava.class.path=$javacp $extraArgs $theClass $args
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 fi