src/os/posix/launcher/launcher.script

Print this page
rev 2750 : 7099454: /bin/sh does not support syntax used in the src/os/posix/launcher/launcher.script shell script
Summary: Also reviewed by mikael.gerdin@oracle.com; Changed to the `` syntax instead. Also changed "source" to ".".
Reviewed-by: stefank
   1 #!/bin/sh
   2 
   3 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 #
   6 # This code is free software; you can redistribute it and/or modify it
   7 # under the terms of the GNU General Public License version 2 only, as
   8 # published by the Free Software Foundation.
   9 #
  10 # This code is distributed in the hope that it will be useful, but WITHOUT
  11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13 # version 2 for more details (a copy is included in the LICENSE file that
  14 # accompanied this code).
  15 #
  16 # You should have received a copy of the GNU General Public License version
  17 # 2 along with this work; if not, write to the Free Software Foundation,
  18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19 #
  20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21 # or visit www.oracle.com if you need additional information or have any
  22 # questions.
  23 


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


  52 # This is the name of the gdb binary to use
  53 if [ ! "$DBX" ]
  54 then 
  55     DBX=dbx
  56 fi
  57 
  58 # This is the name of the Valgrind binary to use
  59 if [ ! "$VALGRIND" ]
  60 then 
  61     VALGRIND=valgrind
  62 fi
  63 
  64 # This is the name of Emacs for running GUD
  65 EMACS=emacs
  66 
  67 #
  68 # End of user changeable parameters -----------------------------------------
  69 #
  70 
  71 # Make sure the paths are fully specified, i.e. they must begin with /.
  72 REL_MYDIR=`dirname $0`
  73 MYDIR=`cd $REL_MYDIR && pwd`
  74 
  75 # Look whether the user wants to run inside gdb
  76 case "$1" in
  77     -gdb)
  78         MODE=gdb
  79         shift
  80         ;;
  81     -gud)
  82         MODE=gud
  83         shift
  84         ;;
  85     -dbx)
  86         MODE=dbx
  87         shift
  88         ;;
  89     -valgrind)
  90         MODE=valgrind
  91         shift
  92         ;;
  93     *)
  94         MODE=run
  95         ;;
  96 esac
  97 



  98 JDK=
  99 if [ "${ALT_JAVA_HOME}" = "" ]; then
 100     . ${MYDIR}/jdkpath.sh
 101 else 
 102     JDK=${ALT_JAVA_HOME%%/jre};
 103 fi
 104 
 105 if [ "${JDK}" = "" ]; then
 106     echo Failed to find JDK. ALT_JAVA_HOME is not set or ./jdkpath.sh is empty or not found.
 107     exit 1
 108 fi
 109 
 110 # We will set the LD_LIBRARY_PATH as follows:
 111 #     o         $JVMPATH (directory portion only)
 112 #     o         $JRE/lib/$ARCH
 113 # followed by the user's previous effective LD_LIBRARY_PATH, if
 114 # any.
 115 JRE=$JDK/jre
 116 JAVA_HOME=$JDK
 117 ARCH=@@LIBARCH@@
 118 



 119 SBP=${MYDIR}:${JRE}/lib/${ARCH}
 120 
 121 # Set up a suitable LD_LIBRARY_PATH
 122 
 123 if [ -z "$LD_LIBRARY_PATH" ]
 124 then
 125     LD_LIBRARY_PATH="$SBP"
 126 else
 127     LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
 128 fi
 129 
 130 export LD_LIBRARY_PATH
 131 export JAVA_HOME
 132 
 133 JPARMS="$@ $JAVA_ARGS";
 134 
 135 # Locate the gamma development launcher
 136 LAUNCHER=${MYDIR}/gamma
 137 if [ ! -x $LAUNCHER ] ; then
 138     echo Error: Cannot find the gamma development launcher \"$LAUNCHER\"
 139     exit 1
 140 fi
 141 
 142 GDBSRCDIR=$MYDIR
 143 BASEDIR=`cd $MYDIR/../../.. && pwd`
 144 
 145 init_gdb() {
 146 # Create a gdb script in case we should run inside gdb
 147     GDBSCR=/tmp/hsl.$$
 148     rm -f $GDBSCR
 149     cat >>$GDBSCR <<EOF
 150 cd `pwd`
 151 handle SIGUSR1 nostop noprint
 152 handle SIGUSR2 nostop noprint
 153 set args $JPARMS
 154 file $LAUNCHER
 155 directory $GDBSRCDIR
 156 # Get us to a point where we can set breakpoints in libjvm.so
 157 break InitializeJVM
 158 run
 159 # Stop in InitializeJVM
 160 delete 1
 161 # We can now set breakpoints wherever we like
 162 EOF
 163 }
 164 
 165 
 166 case "$MODE" in
 167     gdb)
 168         init_gdb
 169         $GDB -x $GDBSCR
 170         rm -f $GDBSCR
 171         ;;
 172     gud)
 173         init_gdb
 174 # First find out what emacs version we're using, so that we can
 175 # use the new pretty GDB mode if emacs -version >= 22.1
 176         case `$EMACS -version 2> /dev/null` in
 177             *GNU\ Emacs\ 2[23]*)
 178             emacs_gud_cmd="gdba"
 179             emacs_gud_args="--annotate=3"
 180             ;;
 181             *)
 182                 emacs_gud_cmd="gdb"
 183                 emacs_gud_args=
 184                 ;;
 185         esac
 186         $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
 187         rm -f $GDBSCR
 188         ;;
 189     dbx)
 190         $DBX -s $MYDIR/.dbxrc $LAUNCHER $JPARAMS
 191         ;;
 192     valgrind)
 193         echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
 194         echo
 195         $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
 196         ;;