make/hotspot.script

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial