src/os/posix/launcher/launcher.script

Thu, 04 Apr 2013 12:18:46 -0700

author
kvn
date
Thu, 04 Apr 2013 12:18:46 -0700
changeset 4879
bab5cbf74b5f
parent 4153
b9a9ed0f8eeb
permissions
-rw-r--r--

8011198: LP64 setting is not preserved on Solaris after 8006965
Summary: Fixed incremental build makefiles generated by buildtree.make. Consolidated unix build.sh.
Reviewed-by: twisti

     1 #!/bin/sh
     3 # Copyright (c) 2010, 2012, 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.
    25 # This script launches HotSpot.
    26 #
    27 # If the first parameter is either "-gdb" or "-gud", HotSpot will be
    28 # launched inside gdb. "-gud" means "open an Emacs window and run gdb
    29 # inside Emacs".
    30 #
    31 # If the first parameter is "-dbx", HotSpot will be launched inside dbx.
    32 #
    33 # If the first parameter is "-valgrind", HotSpot will be launched
    34 # inside Valgrind (http://valgrind.kde.org) using the Memcheck skin,
    35 # and with memory leak detection enabled.  This currently (2005jan19)
    36 # requires at least Valgrind 2.3.0.  -Xmx16m will also be passed as
    37 # the first parameter to HotSpot, since lowering HotSpot's memory
    38 # consumption makes execution inside of Valgrind *a lot* faster.
    39 #
    42 #
    43 # User changeable parameters ------------------------------------------------
    44 #
    46 # This is the name of the gdb binary to use
    47 if [ ! "$GDB" ]
    48 then
    49     GDB=gdb
    50 fi
    52 # This is the name of the gdb binary to use
    53 if [ ! "$DBX" ]
    54 then
    55     DBX=dbx
    56 fi
    58 # This is the name of the Valgrind binary to use
    59 if [ ! "$VALGRIND" ]
    60 then
    61     VALGRIND=valgrind
    62 fi
    64 # This is the name of Emacs for running GUD
    65 EMACS=emacs
    67 #
    68 # End of user changeable parameters -----------------------------------------
    69 #
    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`
    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
    98 JDK=
    99 if [ "${ALT_JAVA_HOME}" = "" ]; then
   100     . ${MYDIR}/jdkpath.sh
   101 else
   102     JDK=${ALT_JAVA_HOME%%/jre};
   103 fi
   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
   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 export JAVA_HOME
   119 ARCH=@@LIBARCH@@
   120 SBP=${MYDIR}:${JRE}/lib/${ARCH}
   123 # Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
   124 OS=`uname -s`
   125 if [ "${OS}" = "Darwin" ]
   126 then
   127     if [ -z "$DYLD_LIBRARY_PATH" ]
   128     then
   129         DYLD_LIBRARY_PATH="$SBP"
   130     else
   131         DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
   132     fi
   133     export DYLD_LIBRARY_PATH
   134 else
   135     # not 'Darwin'
   136     if [ -z "$LD_LIBRARY_PATH" ]
   137     then
   138         LD_LIBRARY_PATH="$SBP"
   139     else
   140         LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
   141     fi
   142     export LD_LIBRARY_PATH
   143 fi
   145 JPARMS="$@ $JAVA_ARGS";
   147 # Locate the gamma development launcher
   148 LAUNCHER=${MYDIR}/gamma
   149 if [ ! -x $LAUNCHER ] ; then
   150     echo Error: Cannot find the gamma development launcher \"$LAUNCHER\"
   151     exit 1
   152 fi
   154 GDBSRCDIR=$MYDIR
   155 BASEDIR=`cd $MYDIR/../../.. && pwd`
   157 init_gdb() {
   158 # Create a gdb script in case we should run inside gdb
   159     GDBSCR=/tmp/hsl.$$
   160     rm -f $GDBSCR
   161     cat >>$GDBSCR <<EOF
   162 cd `pwd`
   163 handle SIGUSR1 nostop noprint
   164 handle SIGUSR2 nostop noprint
   165 set args $JPARMS
   166 file $LAUNCHER
   167 directory $GDBSRCDIR
   168 # Get us to a point where we can set breakpoints in libjvm.so
   169 break InitializeJVM
   170 run
   171 # Stop in InitializeJVM
   172 delete 1
   173 # We can now set breakpoints wherever we like
   174 EOF
   175 }
   178 case "$MODE" in
   179     gdb)
   180 	init_gdb
   181         $GDB -x $GDBSCR
   182 	rm -f $GDBSCR
   183         ;;
   184     gud)
   185 	init_gdb
   186 # First find out what emacs version we're using, so that we can
   187 # use the new pretty GDB mode if emacs -version >= 22.1
   188 	case `$EMACS -version 2> /dev/null` in
   189 	    *GNU\ Emacs\ 2[23]*)
   190 	    emacs_gud_cmd="gdba"
   191 	    emacs_gud_args="--annotate=3"
   192 	    ;;
   193 	    *)
   194 		emacs_gud_cmd="gdb"
   195 		emacs_gud_args=
   196 		;;
   197 	esac
   198         $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
   199 	rm -f $GDBSCR
   200         ;;
   201     dbx)
   202         $DBX -s $HOME/.dbxrc $LAUNCHER $JPARMS
   203         ;;
   204     valgrind)
   205         echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
   206         echo
   207         $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
   208         ;;
   209     run)
   210         LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS
   211         ;;
   212     *)
   213         echo Error: Internal error, unknown launch mode \"$MODE\"
   214         exit 1
   215         ;;
   216 esac
   217 RETVAL=$?
   218 exit $RETVAL

mercurial