duke@435: #!/bin/ksh duke@435: # duke@435: # Copyright 2002-2004 Sun Microsystems, Inc. All Rights Reserved. duke@435: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: # duke@435: # This code is free software; you can redistribute it and/or modify it duke@435: # under the terms of the GNU General Public License version 2 only, as duke@435: # published by the Free Software Foundation. duke@435: # duke@435: # This code is distributed in the hope that it will be useful, but WITHOUT duke@435: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: # version 2 for more details (a copy is included in the LICENSE file that duke@435: # accompanied this code). duke@435: # duke@435: # You should have received a copy of the GNU General Public License version duke@435: # 2 along with this work; if not, write to the Free Software Foundation, duke@435: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: # duke@435: # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: # CA 95054 USA or visit www.sun.com if you need additional information or duke@435: # have any questions. duke@435: # duke@435: # duke@435: duke@435: # This script runs the test program, sagtest.java, with the regular duke@435: # JPDA jdi. duke@435: # It then starts up the debuggee part of the test, sagtarg.java, duke@435: # and calls gcore to create file sagcore for use in running duke@435: # the SA JDI client. duke@435: duke@435: set -x duke@435: # jdk is a jdk with the vm from the sa workspace duke@435: while [ $# != 0 ] ; do duke@435: case $1 in duke@435: -vv) duke@435: set -x duke@435: ;; duke@435: -gui) duke@435: theClass=sun.jvm.hotspot.HSDB duke@435: ;; duke@435: -jdk) duke@435: jdk=$2 duke@435: shift duke@435: ;; duke@435: -jdbx) duke@435: do=jdbx duke@435: ;; duke@435: -jdb) duke@435: do=jdb duke@435: ;; duke@435: -help | help) duke@435: doUsage duke@435: exit duke@435: ;; duke@435: -dontkill) duke@435: dontkill=true duke@435: ;; duke@435: -d64) duke@435: d64=-d64 duke@435: ;; duke@435: -*) duke@435: javaArgs="$javaArgs $1" duke@435: ;; duke@435: *) duke@435: echo "$1" | grep -s '^[0-9]*$' > /dev/null duke@435: if [ $? = 0 ] ; then duke@435: # it is a pid duke@435: args="$args $1" duke@435: else duke@435: # It is a core. duke@435: # We have to pass the name of the program that produced the duke@435: # core, and the core file itself. duke@435: args="$jdk/bin/java $1" duke@435: fi duke@435: ;; duke@435: esac duke@435: shift duke@435: done duke@435: duke@435: # First, run the sagtest.java with the regular JPDA jdi duke@435: workdir=./workdir duke@435: mkdir -p $workdir duke@435: CLASSPATH=$jdk/classes:$jdk/lib/tools.jar:$workdir duke@435: export CLASSPATH duke@435: duke@435: $jdk/bin/javac -g -source 1.5 -classpath $jdk/classes:$jdk/lib/tools.jar:$workdir -J-Xms40m -d $workdir \ duke@435: TestScaffold.java \ duke@435: VMConnection.java \ duke@435: TargetListener.java \ duke@435: TargetAdapter.java \ duke@435: sagdoit.java \ duke@435: sagtarg.java \ duke@435: sagtest.java duke@435: duke@435: if [ $? != 0 ] ; then duke@435: exit 1 duke@435: fi duke@435: duke@435: $jdk/bin/java $javaArgs -Dtest.classes=$workdir sagtest duke@435: duke@435: # Now run create a core file for use in running sa-jdi duke@435: duke@435: if [ ! core.satest -nt sagtarg.class ] ; then duke@435: tmp=/tmp/sagsetup duke@435: rm -f $tmp duke@435: $jdk/bin/java $d64 sagtarg > $tmp & duke@435: pid=$! duke@435: while [ ! -s $tmp ] ; do duke@435: # Kludge alert! duke@435: sleep 2 duke@435: done duke@435: #rm -f $tmp duke@435: duke@435: # force core dump of the debuggee duke@435: OS=`uname` duke@435: if [ "$OS" = "Linux" ]; then duke@435: # Linux does not have gcore command. Instead, we use 'gdb's duke@435: # gcore command. Note that only some versions of gdb support duke@435: # gdb command. duke@435: echo "gcore" > gdbscript duke@435: gdb -batch -p $pid -x gdbscript duke@435: rm -f gdbscript duke@435: else duke@435: gcore $* $pid duke@435: fi duke@435: mv core.$pid sagcore duke@435: duke@435: if [ "$dontkill" != "true" ]; then duke@435: kill -9 $pid duke@435: fi duke@435: fi duke@435: