never@3156: #!/bin/sh sla@2327: mikael@6198: # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. sla@2327: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sla@2327: # sla@2327: # This code is free software; you can redistribute it and/or modify it sla@2327: # under the terms of the GNU General Public License version 2 only, as sla@2327: # published by the Free Software Foundation. sla@2327: # sla@2327: # This code is distributed in the hope that it will be useful, but WITHOUT sla@2327: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sla@2327: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sla@2327: # version 2 for more details (a copy is included in the LICENSE file that sla@2327: # accompanied this code). sla@2327: # sla@2327: # You should have received a copy of the GNU General Public License version sla@2327: # 2 along with this work; if not, write to the Free Software Foundation, sla@2327: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sla@2327: # sla@2327: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sla@2327: # or visit www.oracle.com if you need additional information or have any sla@2327: # questions. sla@2327: sla@2327: sla@2327: # This script launches HotSpot. sla@2327: # sla@2327: # If the first parameter is either "-gdb" or "-gud", HotSpot will be sla@2327: # launched inside gdb. "-gud" means "open an Emacs window and run gdb sla@2327: # inside Emacs". sla@2327: # sla@2327: # If the first parameter is "-dbx", HotSpot will be launched inside dbx. sla@4013: # sla@2327: # If the first parameter is "-valgrind", HotSpot will be launched sla@2327: # inside Valgrind (http://valgrind.kde.org) using the Memcheck skin, sla@2327: # and with memory leak detection enabled. This currently (2005jan19) sla@2327: # requires at least Valgrind 2.3.0. -Xmx16m will also be passed as sla@2327: # the first parameter to HotSpot, since lowering HotSpot's memory sla@2327: # consumption makes execution inside of Valgrind *a lot* faster. sla@2327: # sla@2327: sla@2327: sla@2327: # sla@2327: # User changeable parameters ------------------------------------------------ sla@2327: # sla@2327: sla@2327: # This is the name of the gdb binary to use sla@2327: if [ ! "$GDB" ] sla@4013: then sla@2327: GDB=gdb sla@2327: fi sla@2327: sla@2327: # This is the name of the gdb binary to use sla@2327: if [ ! "$DBX" ] sla@4013: then sla@2327: DBX=dbx sla@2327: fi sla@2327: sla@2327: # This is the name of the Valgrind binary to use sla@2327: if [ ! "$VALGRIND" ] sla@4013: then sla@2327: VALGRIND=valgrind sla@2327: fi sla@2327: sla@2327: # This is the name of Emacs for running GUD sla@2327: EMACS=emacs sla@2327: sla@2327: # sla@2327: # End of user changeable parameters ----------------------------------------- sla@2327: # sla@2327: sla@2327: # Make sure the paths are fully specified, i.e. they must begin with /. brutisso@3187: REL_MYDIR=`dirname $0` brutisso@3187: MYDIR=`cd $REL_MYDIR && pwd` sla@2327: twisti@5109: # sla@2327: # Look whether the user wants to run inside gdb sla@2327: case "$1" in sla@2327: -gdb) sla@2327: MODE=gdb sla@2327: shift sla@2327: ;; sla@2327: -gud) sla@2327: MODE=gud sla@2327: shift sla@2327: ;; sla@2327: -dbx) sla@2327: MODE=dbx sla@2327: shift sla@2327: ;; sla@2327: -valgrind) sla@2327: MODE=valgrind sla@2327: shift sla@2327: ;; sla@2327: *) sla@2327: MODE=run sla@2327: ;; sla@2327: esac sla@2327: twisti@5109: if [ "${ALT_JAVA_HOME}" != "" ]; then twisti@5109: JDK=${ALT_JAVA_HOME%%/jre} sla@4013: else twisti@5109: JDK=@@JDK_IMPORT_PATH@@ sla@2327: fi sla@2327: sla@2369: if [ "${JDK}" = "" ]; then twisti@5109: echo "Failed to find JDK. Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty." sla@2369: fi sla@2369: sla@2327: # We will set the LD_LIBRARY_PATH as follows: sla@2327: # o $JVMPATH (directory portion only) sla@2327: # o $JRE/lib/$ARCH sla@2327: # followed by the user's previous effective LD_LIBRARY_PATH, if sla@2327: # any. sla@2327: JRE=$JDK/jre sla@2327: JAVA_HOME=$JDK sla@4013: export JAVA_HOME sla@4013: sla@2327: ARCH=@@LIBARCH@@ sla@2327: SBP=${MYDIR}:${JRE}/lib/${ARCH} sla@2327: sla@2327: sla@4013: # Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH sla@4013: OS=`uname -s` sla@4013: if [ "${OS}" = "Darwin" ] sla@2327: then sla@4013: if [ -z "$DYLD_LIBRARY_PATH" ] sla@4013: then sla@4013: DYLD_LIBRARY_PATH="$SBP" sla@4013: else sla@4013: DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH" sla@4013: fi sla@4013: export DYLD_LIBRARY_PATH sla@2327: else sla@4013: # not 'Darwin' sla@4013: if [ -z "$LD_LIBRARY_PATH" ] sla@4013: then sla@4013: LD_LIBRARY_PATH="$SBP" sla@4013: else sla@4013: LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH" sla@4013: fi sla@4013: export LD_LIBRARY_PATH sla@2327: fi sla@2327: twisti@5109: JPARMS="-Dsun.java.launcher=gamma -XXaltjvm=$MYDIR $@ $JAVA_ARGS"; sla@2327: twisti@5109: # Locate the java launcher twisti@5109: LAUNCHER=$JDK/bin/java sla@2327: if [ ! -x $LAUNCHER ] ; then twisti@5109: echo Error: Cannot find the java launcher \"$LAUNCHER\" sla@2327: exit 1 sla@2327: fi sla@2327: sla@2327: GDBSRCDIR=$MYDIR brutisso@3187: BASEDIR=`cd $MYDIR/../../.. && pwd` sla@2327: sla@2327: init_gdb() { sla@2327: # Create a gdb script in case we should run inside gdb sla@2327: GDBSCR=/tmp/hsl.$$ sla@2327: rm -f $GDBSCR sla@2327: cat >>$GDBSCR <= 22.1 brutisso@3187: case `$EMACS -version 2> /dev/null` in sla@2327: *GNU\ Emacs\ 2[23]*) sla@2327: emacs_gud_cmd="gdba" sla@2327: emacs_gud_args="--annotate=3" sla@2327: ;; sla@2327: *) sla@2327: emacs_gud_cmd="gdb" sla@2327: emacs_gud_args= sla@2327: ;; sla@2327: esac sla@2327: $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")"; sla@2327: rm -f $GDBSCR sla@2327: ;; sla@2327: dbx) twisti@5109: $DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS; delete all" $LAUNCHER sla@2327: ;; sla@2327: valgrind) sla@2327: echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap sla@2327: echo sla@2327: $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS sla@2327: ;; sla@2327: run) sla@2327: LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS sla@2327: ;; sla@2327: *) sla@2327: echo Error: Internal error, unknown launch mode \"$MODE\" sla@2327: exit 1 sla@2327: ;; sla@2327: esac sla@2327: RETVAL=$? sla@2327: exit $RETVAL