make/hotspot.script

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/make/hotspot.script	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,218 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +# Copyright (c) 2010, 2013, 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 +# This script launches HotSpot.
    1.29 +#
    1.30 +# If the first parameter is either "-gdb" or "-gud", HotSpot will be
    1.31 +# launched inside gdb. "-gud" means "open an Emacs window and run gdb
    1.32 +# inside Emacs".
    1.33 +#
    1.34 +# If the first parameter is "-dbx", HotSpot will be launched inside dbx.
    1.35 +#
    1.36 +# If the first parameter is "-valgrind", HotSpot will be launched
    1.37 +# inside Valgrind (http://valgrind.kde.org) using the Memcheck skin,
    1.38 +# and with memory leak detection enabled.  This currently (2005jan19)
    1.39 +# requires at least Valgrind 2.3.0.  -Xmx16m will also be passed as
    1.40 +# the first parameter to HotSpot, since lowering HotSpot's memory
    1.41 +# consumption makes execution inside of Valgrind *a lot* faster.
    1.42 +#
    1.43 +
    1.44 +
    1.45 +#
    1.46 +# User changeable parameters ------------------------------------------------
    1.47 +#
    1.48 +
    1.49 +# This is the name of the gdb binary to use
    1.50 +if [ ! "$GDB" ]
    1.51 +then
    1.52 +    GDB=gdb
    1.53 +fi
    1.54 +
    1.55 +# This is the name of the gdb binary to use
    1.56 +if [ ! "$DBX" ]
    1.57 +then
    1.58 +    DBX=dbx
    1.59 +fi
    1.60 +
    1.61 +# This is the name of the Valgrind binary to use
    1.62 +if [ ! "$VALGRIND" ]
    1.63 +then
    1.64 +    VALGRIND=valgrind
    1.65 +fi
    1.66 +
    1.67 +# This is the name of Emacs for running GUD
    1.68 +EMACS=emacs
    1.69 +
    1.70 +#
    1.71 +# End of user changeable parameters -----------------------------------------
    1.72 +#
    1.73 +
    1.74 +# Make sure the paths are fully specified, i.e. they must begin with /.
    1.75 +REL_MYDIR=`dirname $0`
    1.76 +MYDIR=`cd $REL_MYDIR && pwd`
    1.77 +
    1.78 +#
    1.79 +# Look whether the user wants to run inside gdb
    1.80 +case "$1" in
    1.81 +    -gdb)
    1.82 +        MODE=gdb
    1.83 +        shift
    1.84 +        ;;
    1.85 +    -gud)
    1.86 +        MODE=gud
    1.87 +        shift
    1.88 +        ;;
    1.89 +    -dbx)
    1.90 +        MODE=dbx
    1.91 +        shift
    1.92 +        ;;
    1.93 +    -valgrind)
    1.94 +        MODE=valgrind
    1.95 +        shift
    1.96 +        ;;
    1.97 +    *)
    1.98 +        MODE=run
    1.99 +        ;;
   1.100 +esac
   1.101 +
   1.102 +if [ "${ALT_JAVA_HOME}" != "" ]; then
   1.103 +    JDK=${ALT_JAVA_HOME%%/jre}
   1.104 +else
   1.105 +    JDK=@@JDK_IMPORT_PATH@@
   1.106 +fi
   1.107 +
   1.108 +if [ "${JDK}" = "" ]; then
   1.109 +    echo "Failed to find JDK.  Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty."
   1.110 +fi
   1.111 +
   1.112 +# We will set the LD_LIBRARY_PATH as follows:
   1.113 +#     o		$JVMPATH (directory portion only)
   1.114 +#     o		$JRE/lib/$ARCH
   1.115 +# followed by the user's previous effective LD_LIBRARY_PATH, if
   1.116 +# any.
   1.117 +JRE=$JDK/jre
   1.118 +JAVA_HOME=$JDK
   1.119 +export JAVA_HOME
   1.120 +
   1.121 +ARCH=@@LIBARCH@@
   1.122 +SBP=${MYDIR}:${JRE}/lib/${ARCH}
   1.123 +
   1.124 +
   1.125 +# Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
   1.126 +OS=`uname -s`
   1.127 +if [ "${OS}" = "Darwin" ]
   1.128 +then
   1.129 +    if [ -z "$DYLD_LIBRARY_PATH" ]
   1.130 +    then
   1.131 +        DYLD_LIBRARY_PATH="$SBP"
   1.132 +    else
   1.133 +        DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
   1.134 +    fi
   1.135 +    export DYLD_LIBRARY_PATH
   1.136 +else
   1.137 +    # not 'Darwin'
   1.138 +    if [ -z "$LD_LIBRARY_PATH" ]
   1.139 +    then
   1.140 +        LD_LIBRARY_PATH="$SBP"
   1.141 +    else
   1.142 +        LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
   1.143 +    fi
   1.144 +    export LD_LIBRARY_PATH
   1.145 +fi
   1.146 +
   1.147 +JPARMS="-Dsun.java.launcher=gamma -XXaltjvm=$MYDIR $@ $JAVA_ARGS";
   1.148 +
   1.149 +# Locate the java launcher
   1.150 +LAUNCHER=$JDK/bin/java
   1.151 +if [ ! -x $LAUNCHER ] ; then
   1.152 +    echo Error: Cannot find the java launcher \"$LAUNCHER\"
   1.153 +    exit 1
   1.154 +fi
   1.155 +
   1.156 +GDBSRCDIR=$MYDIR
   1.157 +BASEDIR=`cd $MYDIR/../../.. && pwd`
   1.158 +
   1.159 +init_gdb() {
   1.160 +# Create a gdb script in case we should run inside gdb
   1.161 +    GDBSCR=/tmp/hsl.$$
   1.162 +    rm -f $GDBSCR
   1.163 +    cat >>$GDBSCR <<EOF
   1.164 +cd `pwd`
   1.165 +handle SIGUSR1 nostop noprint
   1.166 +handle SIGUSR2 nostop noprint
   1.167 +set args $JPARMS
   1.168 +file $LAUNCHER
   1.169 +directory $GDBSRCDIR
   1.170 +# Get us to a point where we can set breakpoints in libjvm.so
   1.171 +set breakpoint pending on
   1.172 +break JNI_CreateJavaVM
   1.173 +run
   1.174 +# Stop in JNI_CreateJavaVM
   1.175 +delete 1
   1.176 +# We can now set breakpoints wherever we like
   1.177 +EOF
   1.178 +}
   1.179 +
   1.180 +
   1.181 +case "$MODE" in
   1.182 +    gdb)
   1.183 +	init_gdb
   1.184 +        $GDB -x $GDBSCR
   1.185 +	rm -f $GDBSCR
   1.186 +        ;;
   1.187 +    gud)
   1.188 +	init_gdb
   1.189 +# First find out what emacs version we're using, so that we can
   1.190 +# use the new pretty GDB mode if emacs -version >= 22.1
   1.191 +	case `$EMACS -version 2> /dev/null` in
   1.192 +	    *GNU\ Emacs\ 2[23]*)
   1.193 +	    emacs_gud_cmd="gdba"
   1.194 +	    emacs_gud_args="--annotate=3"
   1.195 +	    ;;
   1.196 +	    *)
   1.197 +		emacs_gud_cmd="gdb"
   1.198 +		emacs_gud_args=
   1.199 +		;;
   1.200 +	esac
   1.201 +        $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
   1.202 +	rm -f $GDBSCR
   1.203 +        ;;
   1.204 +    dbx)
   1.205 +        $DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS; delete all" $LAUNCHER
   1.206 +        ;;
   1.207 +    valgrind)
   1.208 +        echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
   1.209 +        echo
   1.210 +        $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
   1.211 +        ;;
   1.212 +    run)
   1.213 +        LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS
   1.214 +        ;;
   1.215 +    *)
   1.216 +        echo Error: Internal error, unknown launch mode \"$MODE\"
   1.217 +        exit 1
   1.218 +        ;;
   1.219 +esac
   1.220 +RETVAL=$?
   1.221 +exit $RETVAL

mercurial