aoqi@0: #!/bin/ksh aoqi@0: # aoqi@0: # Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: # aoqi@0: # This code is free software; you can redistribute it and/or modify it aoqi@0: # under the terms of the GNU General Public License version 2 only, as aoqi@0: # published by the Free Software Foundation. aoqi@0: # aoqi@0: # This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: # version 2 for more details (a copy is included in the LICENSE file that aoqi@0: # accompanied this code). aoqi@0: # aoqi@0: # You should have received a copy of the GNU General Public License version aoqi@0: # 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: # aoqi@0: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: # or visit www.oracle.com if you need additional information or have any aoqi@0: # questions. aoqi@0: # aoqi@0: # aoqi@0: aoqi@0: aoqi@0: # This jdk must be hopper or better; it must have the aoqi@0: # SA connectors in VirtualMachineManagerImpl. aoqi@0: jdk=/java/re/jdk/1.4.1/promoted/latest/binaries/solaris-sparc aoqi@0: #jdk=/net/mmm/export/mmm/jdk1.4fcs.sa aoqi@0: aoqi@0: doUsage() aoqi@0: { aoqi@0: cat <] [-jdb] [ -jdbx ] [ -d64 ] [ -remote ] [ pid | corefile | debugserver ] aoqi@0: aoqi@0: -jdk means to use that jdk. Default is 1.4.1/latest. aoqi@0: -jdbx means to run it under jdbx aoqi@0: -jdb means to connect using jdb instead of the sagclient program. aoqi@0: -remote debugserver means you want to connect to a remote debug server aoqi@0: aoqi@0: The corefile must have been produced by the same java as is running SA. aoqi@0: aoqi@0: EOF aoqi@0: } aoqi@0: aoqi@0: if [ $# = 0 ] ; then aoqi@0: doUsage aoqi@0: exit 1 aoqi@0: fi aoqi@0: aoqi@0: # License file for development version of dbx aoqi@0: #LM_LICENSE_FILE=7588@extend.eng:/usr/dist/local/config/sparcworks/license.dat:7588@setlicense aoqi@0: #export LM_LICENSE_FILE aoqi@0: aoqi@0: do= aoqi@0: args= aoqi@0: theClass=sagclient aoqi@0: javaArgs= aoqi@0: aoqi@0: while [ $# != 0 ] ; do aoqi@0: case $1 in aoqi@0: -vv) aoqi@0: set -x aoqi@0: ;; aoqi@0: -jdk) aoqi@0: jdk=$2 aoqi@0: shift aoqi@0: ;; aoqi@0: -jdbx) aoqi@0: do=jdbx aoqi@0: ;; aoqi@0: -jdb) aoqi@0: do=jdb aoqi@0: ;; aoqi@0: -help | help) aoqi@0: doUsage aoqi@0: exit aoqi@0: ;; aoqi@0: -d64) aoqi@0: d64=-d64 aoqi@0: ;; aoqi@0: -remote) aoqi@0: shift aoqi@0: args="$1" aoqi@0: do=remote aoqi@0: ;; aoqi@0: -*) aoqi@0: javaArgs="$javaArgs $1" aoqi@0: ;; aoqi@0: *) aoqi@0: echo "$1" | grep -s '^[0-9]*$' > /dev/null aoqi@0: if [ $? = 0 ] ; then aoqi@0: # it is a pid aoqi@0: args="$args $1" aoqi@0: else aoqi@0: # It is a core. aoqi@0: # We have to pass the name of the program that produced the aoqi@0: # core, and the core file itself. aoqi@0: args="$jdk/bin/java $1" aoqi@0: fi aoqi@0: ;; aoqi@0: esac aoqi@0: shift aoqi@0: done aoqi@0: aoqi@0: if [ -z "$jdk" ] ; then aoqi@0: error "--Error: runsa.sh: Must specify -jdk ." aoqi@0: error " Do runsa.sh -help for more info" aoqi@0: exit 1 aoqi@0: fi aoqi@0: aoqi@0: set -x aoqi@0: aoqi@0: # If jjh makes this, then the classes are in .../build/agent. aoqi@0: # if someone else does, they are in . aoqi@0: classesDir=../../../../../../build/agent aoqi@0: if [ ! -r $classesDir ] ; then aoqi@0: classesDir=. aoqi@0: if [ ! -r $classesDir ] ; then aoqi@0: echo "-- Error: runsa.sh can't find the SA classes" aoqi@0: exit 1 aoqi@0: fi aoqi@0: fi aoqi@0: #javacp="/net/mmm/export/mmm/ws/sabaseline/build/solaris/solaris_sparc_compiler1/generated/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir" aoqi@0: aoqi@0: javacp="$jdk/lib/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir" aoqi@0: aoqi@0: aoqi@0: extraArgs="-showversion $javaArgs" aoqi@0: #extraArgs="-DdbxSvcAgentDSOPathName=/net/mmm/export/mmm/ws/m/b2/sa/src/os/solaris/agent/64bit/libsvc_agent_dbx.so $extraArgs" aoqi@0: #extraArgs="-DdbxSvcAgentDSOPathName=/net/jano.eng/export/disk05/hotspot/sa/solaris/sparcv9/lib/libsvc_agent_dbx.so $extraArgs" aoqi@0: aoqi@0: mkdir -p workdir aoqi@0: if [ sagclient.java -nt ./workdir/sagclient.class ] ; then aoqi@0: $jdk/bin/javac -d ./workdir -classpath $javacp sagclient.java aoqi@0: if [ $? != 0 ] ; then aoqi@0: exit 1 aoqi@0: fi aoqi@0: fi aoqi@0: if [ sagdoit.java -nt ./workdir/sagdoit.class ] ; then aoqi@0: $jdk/bin/javac -d ./workdir -classpath $javacp sagdoit.java aoqi@0: if [ $? != 0 ] ; then aoqi@0: exit 1 aoqi@0: fi aoqi@0: fi aoqi@0: aoqi@0: if [ "$do" = jdbx ] ; then aoqi@0: set -x aoqi@0: dbx=/net/sparcworks.eng/export/set/sparcworks2/dbx_70_nightly/dev/buildbin/Derived-sparc-S2-opt/bin/dbx aoqi@0: aoqi@0: # Have to do this export for jdbx to work. -cp and -classpath don't work. aoqi@0: CLASSPATH=$javacp aoqi@0: export CLASSPATH aoqi@0: #extraArgs="-Djava.class.path=$mhs/../sa/build/agent sun.jvm.hotspot.HSDB $*" aoqi@0: jvm_invocation="$jdk/bin/java -Xdebug \ aoqi@0: -Dsun.boot.class.path=$jdk/classes \ aoqi@0: $extraArgs" aoqi@0: #export jvm_invocation aoqi@0: aoqi@0: JAVASRCPATH=$mhs/../sa/src/share/vm/agent aoqi@0: export JAVASRCPATH aoqi@0: aoqi@0: #operand is pathname of .class file, eg ./jj.class. aoqi@0: echo run $args aoqi@0: clss=`echo $theClass | sed -e 's@\.@/@'` aoqi@0: if [ -r ./workdir/$clss.class ] ; then aoqi@0: # kludge for running sagclient aoqi@0: $dbx ./workdir/$clss.class aoqi@0: else aoqi@0: # kludge for running HSDB aoqi@0: $dbx $mhs/../sa/build/agent/$clss.class aoqi@0: fi aoqi@0: elif [ "$do" = jdb ] ; then aoqi@0: # This hasn't been tested. aoqi@0: $jdk/bin/jdb -J-Xbootclasspath/a:$classesDir -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector:core=sagcore aoqi@0: elif [ "$do" = remote ] ; then aoqi@0: $jdk/bin/java $d64 -Djava.class.path=$javacp $extraArgs $theClass $args aoqi@0: else aoqi@0: $jdk/bin/java $d64 -Djava.class.path=$javacp $extraArgs $theClass $args aoqi@0: aoqi@0: fi