src/os/posix/launcher/launcher.script

Wed, 22 Aug 2012 10:01:51 +0200

author
sla
date
Wed, 22 Aug 2012 10:01:51 +0200
changeset 4013
be82ef218872
parent 3187
3f24f946bc2d
child 4153
b9a9ed0f8eeb
permissions
-rw-r--r--

7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
Reviewed-by: dholmes, dsamersoff, nloodin

never@3156 1 #!/bin/sh
sla@2327 2
brutisso@3187 3 # Copyright (c) 2010, 2011, 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@4013 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@4013 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@4013 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@4013 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 /.
brutisso@3187 72 REL_MYDIR=`dirname $0`
brutisso@3187 73 MYDIR=`cd $REL_MYDIR && 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 JDK=
sla@2327 99 if [ "${ALT_JAVA_HOME}" = "" ]; then
brutisso@3187 100 . ${MYDIR}/jdkpath.sh
sla@4013 101 else
sla@2327 102 JDK=${ALT_JAVA_HOME%%/jre};
sla@2327 103 fi
sla@2327 104
sla@2369 105 if [ "${JDK}" = "" ]; then
sla@2369 106 echo Failed to find JDK. ALT_JAVA_HOME is not set or ./jdkpath.sh is empty or not found.
sla@2369 107 exit 1
sla@2369 108 fi
sla@2369 109
sla@2327 110 # We will set the LD_LIBRARY_PATH as follows:
sla@2327 111 # o $JVMPATH (directory portion only)
sla@2327 112 # o $JRE/lib/$ARCH
sla@2327 113 # followed by the user's previous effective LD_LIBRARY_PATH, if
sla@2327 114 # any.
sla@2327 115 JRE=$JDK/jre
sla@2327 116 JAVA_HOME=$JDK
sla@4013 117 export JAVA_HOME
sla@4013 118
sla@2327 119 ARCH=@@LIBARCH@@
sla@2327 120 SBP=${MYDIR}:${JRE}/lib/${ARCH}
sla@2327 121
sla@2327 122
sla@4013 123 # Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
sla@4013 124 OS=`uname -s`
sla@4013 125 if [ "${OS}" = "Darwin" ]
sla@2327 126 then
sla@4013 127 if [ -z "$DYLD_LIBRARY_PATH" ]
sla@4013 128 then
sla@4013 129 DYLD_LIBRARY_PATH="$SBP"
sla@4013 130 else
sla@4013 131 DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
sla@4013 132 fi
sla@4013 133 export DYLD_LIBRARY_PATH
sla@2327 134 else
sla@4013 135 # not 'Darwin'
sla@4013 136 if [ -z "$LD_LIBRARY_PATH" ]
sla@4013 137 then
sla@4013 138 LD_LIBRARY_PATH="$SBP"
sla@4013 139 else
sla@4013 140 LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
sla@4013 141 fi
sla@4013 142 export LD_LIBRARY_PATH
sla@2327 143 fi
sla@2327 144
sla@2327 145 JPARMS="$@ $JAVA_ARGS";
sla@2327 146
sla@2327 147 # Locate the gamma development launcher
sla@2327 148 LAUNCHER=${MYDIR}/gamma
sla@2327 149 if [ ! -x $LAUNCHER ] ; then
sla@2327 150 echo Error: Cannot find the gamma development launcher \"$LAUNCHER\"
sla@2327 151 exit 1
sla@2327 152 fi
sla@2327 153
sla@2327 154 GDBSRCDIR=$MYDIR
brutisso@3187 155 BASEDIR=`cd $MYDIR/../../.. && pwd`
sla@2327 156
sla@2327 157 init_gdb() {
sla@2327 158 # Create a gdb script in case we should run inside gdb
sla@2327 159 GDBSCR=/tmp/hsl.$$
sla@2327 160 rm -f $GDBSCR
sla@2327 161 cat >>$GDBSCR <<EOF
sla@2327 162 cd `pwd`
sla@2327 163 handle SIGUSR1 nostop noprint
sla@2327 164 handle SIGUSR2 nostop noprint
sla@2327 165 set args $JPARMS
sla@2327 166 file $LAUNCHER
sla@2327 167 directory $GDBSRCDIR
sla@2327 168 # Get us to a point where we can set breakpoints in libjvm.so
sla@2327 169 break InitializeJVM
sla@2327 170 run
sla@2327 171 # Stop in InitializeJVM
sla@2327 172 delete 1
sla@2327 173 # We can now set breakpoints wherever we like
sla@2327 174 EOF
sla@2327 175 }
sla@2327 176
sla@2327 177
sla@2327 178 case "$MODE" in
sla@2327 179 gdb)
sla@2327 180 init_gdb
sla@2327 181 $GDB -x $GDBSCR
sla@2327 182 rm -f $GDBSCR
sla@2327 183 ;;
sla@2327 184 gud)
sla@2327 185 init_gdb
sla@2327 186 # First find out what emacs version we're using, so that we can
sla@2327 187 # use the new pretty GDB mode if emacs -version >= 22.1
brutisso@3187 188 case `$EMACS -version 2> /dev/null` in
sla@2327 189 *GNU\ Emacs\ 2[23]*)
sla@2327 190 emacs_gud_cmd="gdba"
sla@2327 191 emacs_gud_args="--annotate=3"
sla@2327 192 ;;
sla@2327 193 *)
sla@2327 194 emacs_gud_cmd="gdb"
sla@2327 195 emacs_gud_args=
sla@2327 196 ;;
sla@2327 197 esac
sla@2327 198 $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
sla@2327 199 rm -f $GDBSCR
sla@2327 200 ;;
sla@2327 201 dbx)
sla@2327 202 $DBX -s $MYDIR/.dbxrc $LAUNCHER $JPARAMS
sla@2327 203 ;;
sla@2327 204 valgrind)
sla@2327 205 echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
sla@2327 206 echo
sla@2327 207 $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
sla@2327 208 ;;
sla@2327 209 run)
sla@2327 210 LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS
sla@2327 211 ;;
sla@2327 212 *)
sla@2327 213 echo Error: Internal error, unknown launch mode \"$MODE\"
sla@2327 214 exit 1
sla@2327 215 ;;
sla@2327 216 esac
sla@2327 217 RETVAL=$?
sla@2327 218 exit $RETVAL

mercurial