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