src/os/posix/launcher/launcher.script

Sun, 25 Sep 2011 16:03:29 -0700

author
never
date
Sun, 25 Sep 2011 16:03:29 -0700
changeset 3156
f08d439fab8c
parent 2369
aa6e219afbf1
child 3187
3f24f946bc2d
permissions
-rw-r--r--

7089790: integrate bsd-port changes
Reviewed-by: kvn, twisti, jrose
Contributed-by: Kurt Miller <kurt@intricatesoftware.com>, Greg Lewis <glewis@eyesbeyond.com>, Jung-uk Kim <jkim@freebsd.org>, Christos Zoulas <christos@zoulas.com>, Landon Fuller <landonf@plausible.coop>, The FreeBSD Foundation <board@freebsdfoundation.org>, Michael Franz <mvfranz@gmail.com>, Roger Hoover <rhoover@apple.com>, Alexander Strange <astrange@apple.com>

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

mercurial