agent/test/jdi/runjpda.sh

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/agent/test/jdi/runjpda.sh	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,133 @@
     1.4 +#!/bin/ksh
     1.5 +#
     1.6 +# Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
     1.7 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8 +#
     1.9 +# This code is free software; you can redistribute it and/or modify it
    1.10 +# under the terms of the GNU General Public License version 2 only, as
    1.11 +# published by the Free Software Foundation.
    1.12 +#
    1.13 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.14 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.15 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.16 +# version 2 for more details (a copy is included in the LICENSE file that
    1.17 +# accompanied this code).
    1.18 +#
    1.19 +# You should have received a copy of the GNU General Public License version
    1.20 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.21 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.22 +#
    1.23 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.24 +# or visit www.oracle.com if you need additional information or have any
    1.25 +# questions.
    1.26 +#  
    1.27 +#
    1.28 +
    1.29 +# This script runs the test program, sagtest.java, with the regular
    1.30 +# JPDA jdi.
    1.31 +# It then starts up the debuggee part of the test, sagtarg.java,
    1.32 +# and calls gcore to create file sagcore for use in running
    1.33 +# the SA JDI client.
    1.34 +
    1.35 +set -x
    1.36 +# jdk is a jdk with the vm from the sa workspace
    1.37 +while [ $# != 0 ] ; do
    1.38 +    case $1 in
    1.39 +      -vv)
    1.40 +        set -x
    1.41 +        ;;
    1.42 +      -gui)
    1.43 +        theClass=sun.jvm.hotspot.HSDB
    1.44 +        ;;
    1.45 +     -jdk)
    1.46 +        jdk=$2
    1.47 +        shift
    1.48 +        ;;
    1.49 +     -jdbx)
    1.50 +        do=jdbx
    1.51 +        ;;
    1.52 +     -jdb)
    1.53 +        do=jdb
    1.54 +        ;;
    1.55 +     -help | help)
    1.56 +        doUsage
    1.57 +        exit
    1.58 +        ;;
    1.59 +     -dontkill)
    1.60 +        dontkill=true
    1.61 +        ;;
    1.62 +     -d64)
    1.63 +        d64=-d64
    1.64 +        ;;
    1.65 +     -*)
    1.66 +        javaArgs="$javaArgs $1"
    1.67 +        ;;
    1.68 +     *)
    1.69 +        echo "$1" | grep -s '^[0-9]*$' > /dev/null
    1.70 +        if [ $? = 0 ] ; then
    1.71 +            # it is a pid
    1.72 +            args="$args $1"
    1.73 +        else
    1.74 +            # It is a core.        
    1.75 +            # We have to pass the name of the program that produced the
    1.76 +            # core, and the core file itself.
    1.77 +            args="$jdk/bin/java $1"
    1.78 +        fi
    1.79 +        ;;
    1.80 +   esac
    1.81 +   shift
    1.82 +done
    1.83 +
    1.84 +# First, run the sagtest.java with the regular JPDA jdi
    1.85 +workdir=./workdir
    1.86 +mkdir -p $workdir
    1.87 +CLASSPATH=$jdk/classes:$jdk/lib/tools.jar:$workdir
    1.88 +export CLASSPATH
    1.89 +
    1.90 +$jdk/bin/javac -g  -source 1.5 -classpath $jdk/classes:$jdk/lib/tools.jar:$workdir -J-Xms40m -d $workdir \
    1.91 +    TestScaffold.java \
    1.92 +    VMConnection.java \
    1.93 +    TargetListener.java \
    1.94 +    TargetAdapter.java \
    1.95 +    sagdoit.java \
    1.96 +    sagtarg.java \
    1.97 +    sagtest.java
    1.98 +
    1.99 +if [ $? != 0 ] ; then
   1.100 +    exit 1
   1.101 +fi
   1.102 +
   1.103 +$jdk/bin/java $javaArgs -Dtest.classes=$workdir sagtest
   1.104 +
   1.105 +# Now run create a core file for use in running sa-jdi
   1.106 +
   1.107 +if [ ! core.satest -nt sagtarg.class ] ; then
   1.108 +    tmp=/tmp/sagsetup
   1.109 +    rm -f $tmp
   1.110 +    $jdk/bin/java $d64 sagtarg > $tmp &
   1.111 +    pid=$!
   1.112 +    while [ ! -s $tmp ] ; do
   1.113 +        # Kludge alert!
   1.114 +        sleep 2
   1.115 +    done
   1.116 +    #rm -f $tmp
   1.117 +
   1.118 +    # force core dump of the debuggee
   1.119 +    OS=`uname`
   1.120 +    if [ "$OS" = "Linux" ]; then
   1.121 +        # Linux does not have gcore command. Instead, we use 'gdb's
   1.122 +        # gcore command. Note that only some versions of gdb support
   1.123 +        # gdb command.
   1.124 +        echo "gcore" > gdbscript
   1.125 +        gdb -batch -p $pid -x gdbscript
   1.126 +        rm -f gdbscript
   1.127 +    else
   1.128 +        gcore  $* $pid
   1.129 +    fi
   1.130 +    mv core.$pid sagcore
   1.131 +
   1.132 +    if [ "$dontkill" != "true" ]; then
   1.133 +       kill -9 $pid
   1.134 +    fi
   1.135 +fi
   1.136 +

mercurial