annotate make/hotspot.script @ 5585:0e55a181cb08

Merge
author lana
date Mon, 28 Oct 2013 12:25:44 -0700
parents bab5cbf74b5f
children 55fb97c4c58d
rev   line source
never@2721 1 #!/bin/sh
sla@1892 2
mikael@3718 3 # Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
sla@1892 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
sla@1892 5 #
sla@1892 6 # This code is free software; you can redistribute it and/or modify it
sla@1892 7 # under the terms of the GNU General Public License version 2 only, as
sla@1892 8 # published by the Free Software Foundation.
sla@1892 9 #
sla@1892 10 # This code is distributed in the hope that it will be useful, but WITHOUT
sla@1892 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sla@1892 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sla@1892 13 # version 2 for more details (a copy is included in the LICENSE file that
sla@1892 14 # accompanied this code).
sla@1892 15 #
sla@1892 16 # You should have received a copy of the GNU General Public License version
sla@1892 17 # 2 along with this work; if not, write to the Free Software Foundation,
sla@1892 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
sla@1892 19 #
sla@1892 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sla@1892 21 # or visit www.oracle.com if you need additional information or have any
sla@1892 22 # questions.
sla@1892 23
sla@1892 24
sla@1892 25 # This script launches HotSpot.
sla@1892 26 #
sla@1892 27 # If the first parameter is either "-gdb" or "-gud", HotSpot will be
sla@1892 28 # launched inside gdb. "-gud" means "open an Emacs window and run gdb
sla@1892 29 # inside Emacs".
sla@1892 30 #
sla@1892 31 # If the first parameter is "-dbx", HotSpot will be launched inside dbx.
sla@3578 32 #
sla@1892 33 # If the first parameter is "-valgrind", HotSpot will be launched
sla@1892 34 # inside Valgrind (http://valgrind.kde.org) using the Memcheck skin,
sla@1892 35 # and with memory leak detection enabled. This currently (2005jan19)
sla@1892 36 # requires at least Valgrind 2.3.0. -Xmx16m will also be passed as
sla@1892 37 # the first parameter to HotSpot, since lowering HotSpot's memory
sla@1892 38 # consumption makes execution inside of Valgrind *a lot* faster.
sla@1892 39 #
sla@1892 40
sla@1892 41
sla@1892 42 #
sla@1892 43 # User changeable parameters ------------------------------------------------
sla@1892 44 #
sla@1892 45
sla@1892 46 # This is the name of the gdb binary to use
sla@1892 47 if [ ! "$GDB" ]
sla@3578 48 then
sla@1892 49 GDB=gdb
sla@1892 50 fi
sla@1892 51
sla@1892 52 # This is the name of the gdb binary to use
sla@1892 53 if [ ! "$DBX" ]
sla@3578 54 then
sla@1892 55 DBX=dbx
sla@1892 56 fi
sla@1892 57
sla@1892 58 # This is the name of the Valgrind binary to use
sla@1892 59 if [ ! "$VALGRIND" ]
sla@3578 60 then
sla@1892 61 VALGRIND=valgrind
sla@1892 62 fi
sla@1892 63
sla@1892 64 # This is the name of Emacs for running GUD
sla@1892 65 EMACS=emacs
sla@1892 66
sla@1892 67 #
sla@1892 68 # End of user changeable parameters -----------------------------------------
sla@1892 69 #
sla@1892 70
sla@1892 71 # Make sure the paths are fully specified, i.e. they must begin with /.
brutisso@2752 72 REL_MYDIR=`dirname $0`
brutisso@2752 73 MYDIR=`cd $REL_MYDIR && pwd`
sla@1892 74
twisti@4674 75 #
sla@1892 76 # Look whether the user wants to run inside gdb
sla@1892 77 case "$1" in
sla@1892 78 -gdb)
sla@1892 79 MODE=gdb
sla@1892 80 shift
sla@1892 81 ;;
sla@1892 82 -gud)
sla@1892 83 MODE=gud
sla@1892 84 shift
sla@1892 85 ;;
sla@1892 86 -dbx)
sla@1892 87 MODE=dbx
sla@1892 88 shift
sla@1892 89 ;;
sla@1892 90 -valgrind)
sla@1892 91 MODE=valgrind
sla@1892 92 shift
sla@1892 93 ;;
sla@1892 94 *)
sla@1892 95 MODE=run
sla@1892 96 ;;
sla@1892 97 esac
sla@1892 98
twisti@4674 99 if [ "${ALT_JAVA_HOME}" != "" ]; then
twisti@4674 100 JDK=${ALT_JAVA_HOME%%/jre}
sla@3578 101 else
twisti@4674 102 JDK=@@JDK_IMPORT_PATH@@
sla@1892 103 fi
sla@1892 104
sla@1934 105 if [ "${JDK}" = "" ]; then
twisti@4674 106 echo "Failed to find JDK. Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty."
sla@1934 107 fi
sla@1934 108
sla@1892 109 # We will set the LD_LIBRARY_PATH as follows:
sla@1892 110 # o $JVMPATH (directory portion only)
sla@1892 111 # o $JRE/lib/$ARCH
sla@1892 112 # followed by the user's previous effective LD_LIBRARY_PATH, if
sla@1892 113 # any.
sla@1892 114 JRE=$JDK/jre
sla@1892 115 JAVA_HOME=$JDK
sla@3578 116 export JAVA_HOME
sla@3578 117
sla@1892 118 ARCH=@@LIBARCH@@
sla@1892 119 SBP=${MYDIR}:${JRE}/lib/${ARCH}
sla@1892 120
sla@1892 121
sla@3578 122 # Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
sla@3578 123 OS=`uname -s`
sla@3578 124 if [ "${OS}" = "Darwin" ]
sla@1892 125 then
sla@3578 126 if [ -z "$DYLD_LIBRARY_PATH" ]
sla@3578 127 then
sla@3578 128 DYLD_LIBRARY_PATH="$SBP"
sla@3578 129 else
sla@3578 130 DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
sla@3578 131 fi
sla@3578 132 export DYLD_LIBRARY_PATH
sla@1892 133 else
sla@3578 134 # not 'Darwin'
sla@3578 135 if [ -z "$LD_LIBRARY_PATH" ]
sla@3578 136 then
sla@3578 137 LD_LIBRARY_PATH="$SBP"
sla@3578 138 else
sla@3578 139 LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
sla@3578 140 fi
sla@3578 141 export LD_LIBRARY_PATH
sla@1892 142 fi
sla@1892 143
twisti@4674 144 JPARMS="-Dsun.java.launcher=gamma -XXaltjvm=$MYDIR $@ $JAVA_ARGS";
sla@1892 145
twisti@4674 146 # Locate the java launcher
twisti@4674 147 LAUNCHER=$JDK/bin/java
sla@1892 148 if [ ! -x $LAUNCHER ] ; then
twisti@4674 149 echo Error: Cannot find the java launcher \"$LAUNCHER\"
sla@1892 150 exit 1
sla@1892 151 fi
sla@1892 152
sla@1892 153 GDBSRCDIR=$MYDIR
brutisso@2752 154 BASEDIR=`cd $MYDIR/../../.. && pwd`
sla@1892 155
sla@1892 156 init_gdb() {
sla@1892 157 # Create a gdb script in case we should run inside gdb
sla@1892 158 GDBSCR=/tmp/hsl.$$
sla@1892 159 rm -f $GDBSCR
sla@1892 160 cat >>$GDBSCR <<EOF
sla@1892 161 cd `pwd`
sla@1892 162 handle SIGUSR1 nostop noprint
sla@1892 163 handle SIGUSR2 nostop noprint
sla@1892 164 set args $JPARMS
sla@1892 165 file $LAUNCHER
sla@1892 166 directory $GDBSRCDIR
sla@1892 167 # Get us to a point where we can set breakpoints in libjvm.so
twisti@4674 168 set breakpoint pending on
twisti@4674 169 break JNI_CreateJavaVM
sla@1892 170 run
twisti@4674 171 # Stop in JNI_CreateJavaVM
sla@1892 172 delete 1
sla@1892 173 # We can now set breakpoints wherever we like
sla@1892 174 EOF
sla@1892 175 }
sla@1892 176
sla@1892 177
sla@1892 178 case "$MODE" in
sla@1892 179 gdb)
sla@1892 180 init_gdb
sla@1892 181 $GDB -x $GDBSCR
sla@1892 182 rm -f $GDBSCR
sla@1892 183 ;;
sla@1892 184 gud)
sla@1892 185 init_gdb
sla@1892 186 # First find out what emacs version we're using, so that we can
sla@1892 187 # use the new pretty GDB mode if emacs -version >= 22.1
brutisso@2752 188 case `$EMACS -version 2> /dev/null` in
sla@1892 189 *GNU\ Emacs\ 2[23]*)
sla@1892 190 emacs_gud_cmd="gdba"
sla@1892 191 emacs_gud_args="--annotate=3"
sla@1892 192 ;;
sla@1892 193 *)
sla@1892 194 emacs_gud_cmd="gdb"
sla@1892 195 emacs_gud_args=
sla@1892 196 ;;
sla@1892 197 esac
sla@1892 198 $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
sla@1892 199 rm -f $GDBSCR
sla@1892 200 ;;
sla@1892 201 dbx)
twisti@4674 202 $DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS; delete all" $LAUNCHER
sla@1892 203 ;;
sla@1892 204 valgrind)
sla@1892 205 echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
sla@1892 206 echo
sla@1892 207 $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
sla@1892 208 ;;
sla@1892 209 run)
sla@1892 210 LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS
sla@1892 211 ;;
sla@1892 212 *)
sla@1892 213 echo Error: Internal error, unknown launch mode \"$MODE\"
sla@1892 214 exit 1
sla@1892 215 ;;
sla@1892 216 esac
sla@1892 217 RETVAL=$?
sla@1892 218 exit $RETVAL