sla@2327: #!/bin/bash sla@2327: sla@2327: # Copyright (c) 2010, 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@2327: # 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@2327: 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@2327: 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@2327: 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 /. sla@2327: SCRIPT=$(cd $(dirname $0) && pwd)/$(basename $0) sla@2327: RUNDIR=$(pwd) sla@2327: 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: sla@2327: if [ "${ALT_JAVA_HOME}" = "" ]; then sla@2327: if [ "${JAVA_HOME}" = "" ]; then sla@2327: echo "Neither ALT_JAVA_HOME nor JAVA_HOME is set. Aborting."; sla@2327: exit 1; sla@2327: else sla@2327: JDK=${JAVA_HOME%%/jre}; sla@2327: fi sla@2327: else sla@2327: JDK=${ALT_JAVA_HOME%%/jre}; sla@2327: fi sla@2327: 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@2327: ARCH=@@LIBARCH@@ sla@2327: sla@2327: # Find out the absolute path to this script sla@2327: MYDIR=$(cd $(dirname $SCRIPT) && pwd) sla@2327: sla@2327: SBP=${MYDIR}:${JRE}/lib/${ARCH} sla@2327: sla@2327: # Set up a suitable LD_LIBRARY_PATH sla@2327: sla@2327: if [ -z "$LD_LIBRARY_PATH" ] sla@2327: then sla@2327: LD_LIBRARY_PATH="$SBP" sla@2327: else sla@2327: LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH" sla@2327: fi sla@2327: sla@2327: export LD_LIBRARY_PATH sla@2327: export JAVA_HOME sla@2327: sla@2327: JPARMS="$@ $JAVA_ARGS"; sla@2327: sla@2327: # Locate the gamma development launcher sla@2327: LAUNCHER=${MYDIR}/gamma sla@2327: if [ ! -x $LAUNCHER ] ; then sla@2327: echo Error: Cannot find the gamma development launcher \"$LAUNCHER\" sla@2327: exit 1 sla@2327: fi sla@2327: sla@2327: GDBSRCDIR=$MYDIR sla@2327: 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 sla@2327: 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) sla@2327: $DBX -s $MYDIR/.dbxrc $LAUNCHER $JPARAMS 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