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