1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/os/posix/launcher/launcher.script Thu Dec 02 05:45:54 2010 -0800 1.3 @@ -0,0 +1,208 @@ 1.4 +#!/bin/bash 1.5 + 1.6 +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 1.7 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 +# 1.9 +# This code is free software; you can redistribute it and/or modify it 1.10 +# under the terms of the GNU General Public License version 2 only, as 1.11 +# published by the Free Software Foundation. 1.12 +# 1.13 +# This code is distributed in the hope that it will be useful, but WITHOUT 1.14 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.15 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.16 +# version 2 for more details (a copy is included in the LICENSE file that 1.17 +# accompanied this code). 1.18 +# 1.19 +# You should have received a copy of the GNU General Public License version 1.20 +# 2 along with this work; if not, write to the Free Software Foundation, 1.21 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.22 +# 1.23 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.24 +# or visit www.oracle.com if you need additional information or have any 1.25 +# questions. 1.26 + 1.27 + 1.28 +# This script launches HotSpot. 1.29 +# 1.30 +# If the first parameter is either "-gdb" or "-gud", HotSpot will be 1.31 +# launched inside gdb. "-gud" means "open an Emacs window and run gdb 1.32 +# inside Emacs". 1.33 +# 1.34 +# If the first parameter is "-dbx", HotSpot will be launched inside dbx. 1.35 +# 1.36 +# If the first parameter is "-valgrind", HotSpot will be launched 1.37 +# inside Valgrind (http://valgrind.kde.org) using the Memcheck skin, 1.38 +# and with memory leak detection enabled. This currently (2005jan19) 1.39 +# requires at least Valgrind 2.3.0. -Xmx16m will also be passed as 1.40 +# the first parameter to HotSpot, since lowering HotSpot's memory 1.41 +# consumption makes execution inside of Valgrind *a lot* faster. 1.42 +# 1.43 + 1.44 + 1.45 +# 1.46 +# User changeable parameters ------------------------------------------------ 1.47 +# 1.48 + 1.49 +# This is the name of the gdb binary to use 1.50 +if [ ! "$GDB" ] 1.51 +then 1.52 + GDB=gdb 1.53 +fi 1.54 + 1.55 +# This is the name of the gdb binary to use 1.56 +if [ ! "$DBX" ] 1.57 +then 1.58 + DBX=dbx 1.59 +fi 1.60 + 1.61 +# This is the name of the Valgrind binary to use 1.62 +if [ ! "$VALGRIND" ] 1.63 +then 1.64 + VALGRIND=valgrind 1.65 +fi 1.66 + 1.67 +# This is the name of Emacs for running GUD 1.68 +EMACS=emacs 1.69 + 1.70 +# 1.71 +# End of user changeable parameters ----------------------------------------- 1.72 +# 1.73 + 1.74 +# Make sure the paths are fully specified, i.e. they must begin with /. 1.75 +SCRIPT=$(cd $(dirname $0) && pwd)/$(basename $0) 1.76 +RUNDIR=$(pwd) 1.77 + 1.78 +# Look whether the user wants to run inside gdb 1.79 +case "$1" in 1.80 + -gdb) 1.81 + MODE=gdb 1.82 + shift 1.83 + ;; 1.84 + -gud) 1.85 + MODE=gud 1.86 + shift 1.87 + ;; 1.88 + -dbx) 1.89 + MODE=dbx 1.90 + shift 1.91 + ;; 1.92 + -valgrind) 1.93 + MODE=valgrind 1.94 + shift 1.95 + ;; 1.96 + *) 1.97 + MODE=run 1.98 + ;; 1.99 +esac 1.100 + 1.101 +if [ "${ALT_JAVA_HOME}" = "" ]; then 1.102 + if [ "${JAVA_HOME}" = "" ]; then 1.103 + echo "Neither ALT_JAVA_HOME nor JAVA_HOME is set. Aborting."; 1.104 + exit 1; 1.105 + else 1.106 + JDK=${JAVA_HOME%%/jre}; 1.107 + fi 1.108 +else 1.109 + JDK=${ALT_JAVA_HOME%%/jre}; 1.110 +fi 1.111 + 1.112 +# We will set the LD_LIBRARY_PATH as follows: 1.113 +# o $JVMPATH (directory portion only) 1.114 +# o $JRE/lib/$ARCH 1.115 +# followed by the user's previous effective LD_LIBRARY_PATH, if 1.116 +# any. 1.117 +JRE=$JDK/jre 1.118 +JAVA_HOME=$JDK 1.119 +ARCH=@@LIBARCH@@ 1.120 + 1.121 +# Find out the absolute path to this script 1.122 +MYDIR=$(cd $(dirname $SCRIPT) && pwd) 1.123 + 1.124 +SBP=${MYDIR}:${JRE}/lib/${ARCH} 1.125 + 1.126 +# Set up a suitable LD_LIBRARY_PATH 1.127 + 1.128 +if [ -z "$LD_LIBRARY_PATH" ] 1.129 +then 1.130 + LD_LIBRARY_PATH="$SBP" 1.131 +else 1.132 + LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH" 1.133 +fi 1.134 + 1.135 +export LD_LIBRARY_PATH 1.136 +export JAVA_HOME 1.137 + 1.138 +JPARMS="$@ $JAVA_ARGS"; 1.139 + 1.140 +# Locate the gamma development launcher 1.141 +LAUNCHER=${MYDIR}/gamma 1.142 +if [ ! -x $LAUNCHER ] ; then 1.143 + echo Error: Cannot find the gamma development launcher \"$LAUNCHER\" 1.144 + exit 1 1.145 +fi 1.146 + 1.147 +GDBSRCDIR=$MYDIR 1.148 +BASEDIR=$(cd $MYDIR/../../.. && pwd) 1.149 + 1.150 +init_gdb() { 1.151 +# Create a gdb script in case we should run inside gdb 1.152 + GDBSCR=/tmp/hsl.$$ 1.153 + rm -f $GDBSCR 1.154 + cat >>$GDBSCR <<EOF 1.155 +cd `pwd` 1.156 +handle SIGUSR1 nostop noprint 1.157 +handle SIGUSR2 nostop noprint 1.158 +set args $JPARMS 1.159 +file $LAUNCHER 1.160 +directory $GDBSRCDIR 1.161 +# Get us to a point where we can set breakpoints in libjvm.so 1.162 +break InitializeJVM 1.163 +run 1.164 +# Stop in InitializeJVM 1.165 +delete 1 1.166 +# We can now set breakpoints wherever we like 1.167 +EOF 1.168 +} 1.169 + 1.170 + 1.171 +case "$MODE" in 1.172 + gdb) 1.173 + init_gdb 1.174 + $GDB -x $GDBSCR 1.175 + rm -f $GDBSCR 1.176 + ;; 1.177 + gud) 1.178 + init_gdb 1.179 +# First find out what emacs version we're using, so that we can 1.180 +# use the new pretty GDB mode if emacs -version >= 22.1 1.181 + case $($EMACS -version 2> /dev/null) in 1.182 + *GNU\ Emacs\ 2[23]*) 1.183 + emacs_gud_cmd="gdba" 1.184 + emacs_gud_args="--annotate=3" 1.185 + ;; 1.186 + *) 1.187 + emacs_gud_cmd="gdb" 1.188 + emacs_gud_args= 1.189 + ;; 1.190 + esac 1.191 + $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")"; 1.192 + rm -f $GDBSCR 1.193 + ;; 1.194 + dbx) 1.195 + $DBX -s $MYDIR/.dbxrc $LAUNCHER $JPARAMS 1.196 + ;; 1.197 + valgrind) 1.198 + echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap 1.199 + echo 1.200 + $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS 1.201 + ;; 1.202 + run) 1.203 + LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS 1.204 + ;; 1.205 + *) 1.206 + echo Error: Internal error, unknown launch mode \"$MODE\" 1.207 + exit 1 1.208 + ;; 1.209 +esac 1.210 +RETVAL=$? 1.211 +exit $RETVAL