author | ant |
Wed, 12 Jun 2013 16:18:04 +0400 | |
changeset 18128 | 3492cc60d273 |
parent 17382 | bba473b81ec0 |
child 22234 | da823d78ad65 |
permissions | -rw-r--r-- |
10565 | 1 |
#!/bin/sh |
7410 | 2 |
|
13963
e5b53c306fb5
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
13514
diff
changeset
|
3 |
# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
7410 | 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 |
||
24 |
||
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. |
|
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
32 |
# |
7410 | 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 |
# |
|
40 |
||
41 |
||
42 |
# |
|
43 |
# User changeable parameters ------------------------------------------------ |
|
44 |
# |
|
45 |
||
46 |
# This is the name of the gdb binary to use |
|
47 |
if [ ! "$GDB" ] |
|
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
48 |
then |
7410 | 49 |
GDB=gdb |
50 |
fi |
|
51 |
||
52 |
# This is the name of the gdb binary to use |
|
53 |
if [ ! "$DBX" ] |
|
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
54 |
then |
7410 | 55 |
DBX=dbx |
56 |
fi |
|
57 |
||
58 |
# This is the name of the Valgrind binary to use |
|
59 |
if [ ! "$VALGRIND" ] |
|
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
60 |
then |
7410 | 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 /. |
|
10682
b511a318cd44
7099454: /bin/sh does not support syntax used in the src/os/posix/launcher/launcher.script shell script
brutisso
parents:
10565
diff
changeset
|
72 |
REL_MYDIR=`dirname $0` |
b511a318cd44
7099454: /bin/sh does not support syntax used in the src/os/posix/launcher/launcher.script shell script
brutisso
parents:
10565
diff
changeset
|
73 |
MYDIR=`cd $REL_MYDIR && pwd` |
7410 | 74 |
|
17382 | 75 |
# |
7410 | 76 |
# Look whether the user wants to run inside gdb |
77 |
case "$1" in |
|
78 |
-gdb) |
|
79 |
MODE=gdb |
|
80 |
shift |
|
81 |
;; |
|
82 |
-gud) |
|
83 |
MODE=gud |
|
84 |
shift |
|
85 |
;; |
|
86 |
-dbx) |
|
87 |
MODE=dbx |
|
88 |
shift |
|
89 |
;; |
|
90 |
-valgrind) |
|
91 |
MODE=valgrind |
|
92 |
shift |
|
93 |
;; |
|
94 |
*) |
|
95 |
MODE=run |
|
96 |
;; |
|
97 |
esac |
|
98 |
||
17382 | 99 |
if [ "${ALT_JAVA_HOME}" != "" ]; then |
100 |
JDK=${ALT_JAVA_HOME%%/jre} |
|
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
101 |
else |
17382 | 102 |
JDK=@@JDK_IMPORT_PATH@@ |
7410 | 103 |
fi |
104 |
||
7452
b3fa838286de
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
7410
diff
changeset
|
105 |
if [ "${JDK}" = "" ]; then |
17382 | 106 |
echo "Failed to find JDK. Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty." |
7452
b3fa838286de
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
7410
diff
changeset
|
107 |
fi |
b3fa838286de
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
7410
diff
changeset
|
108 |
|
7410 | 109 |
# We will set the LD_LIBRARY_PATH as follows: |
110 |
# o $JVMPATH (directory portion only) |
|
111 |
# o $JRE/lib/$ARCH |
|
112 |
# followed by the user's previous effective LD_LIBRARY_PATH, if |
|
113 |
# any. |
|
114 |
JRE=$JDK/jre |
|
115 |
JAVA_HOME=$JDK |
|
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
116 |
export JAVA_HOME |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
117 |
|
7410 | 118 |
ARCH=@@LIBARCH@@ |
119 |
SBP=${MYDIR}:${JRE}/lib/${ARCH} |
|
120 |
||
121 |
||
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
122 |
# Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
123 |
OS=`uname -s` |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
124 |
if [ "${OS}" = "Darwin" ] |
7410 | 125 |
then |
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
126 |
if [ -z "$DYLD_LIBRARY_PATH" ] |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
127 |
then |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
128 |
DYLD_LIBRARY_PATH="$SBP" |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
129 |
else |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
130 |
DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH" |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
131 |
fi |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
132 |
export DYLD_LIBRARY_PATH |
7410 | 133 |
else |
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
134 |
# not 'Darwin' |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
135 |
if [ -z "$LD_LIBRARY_PATH" ] |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
136 |
then |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
137 |
LD_LIBRARY_PATH="$SBP" |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
138 |
else |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
139 |
LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH" |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
140 |
fi |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
141 |
export LD_LIBRARY_PATH |
7410 | 142 |
fi |
143 |
||
17382 | 144 |
JPARMS="-Dsun.java.launcher=gamma -XXaltjvm=$MYDIR $@ $JAVA_ARGS"; |
7410 | 145 |
|
17382 | 146 |
# Locate the java launcher |
147 |
LAUNCHER=$JDK/bin/java |
|
7410 | 148 |
if [ ! -x $LAUNCHER ] ; then |
17382 | 149 |
echo Error: Cannot find the java launcher \"$LAUNCHER\" |
7410 | 150 |
exit 1 |
151 |
fi |
|
152 |
||
153 |
GDBSRCDIR=$MYDIR |
|
10682
b511a318cd44
7099454: /bin/sh does not support syntax used in the src/os/posix/launcher/launcher.script shell script
brutisso
parents:
10565
diff
changeset
|
154 |
BASEDIR=`cd $MYDIR/../../.. && pwd` |
7410 | 155 |
|
156 |
init_gdb() { |
|
157 |
# Create a gdb script in case we should run inside gdb |
|
158 |
GDBSCR=/tmp/hsl.$$ |
|
159 |
rm -f $GDBSCR |
|
160 |
cat >>$GDBSCR <<EOF |
|
161 |
cd `pwd` |
|
162 |
handle SIGUSR1 nostop noprint |
|
163 |
handle SIGUSR2 nostop noprint |
|
164 |
set args $JPARMS |
|
165 |
file $LAUNCHER |
|
166 |
directory $GDBSRCDIR |
|
167 |
# Get us to a point where we can set breakpoints in libjvm.so |
|
17382 | 168 |
set breakpoint pending on |
169 |
break JNI_CreateJavaVM |
|
7410 | 170 |
run |
17382 | 171 |
# Stop in JNI_CreateJavaVM |
7410 | 172 |
delete 1 |
173 |
# We can now set breakpoints wherever we like |
|
174 |
EOF |
|
175 |
} |
|
176 |
||
177 |
||
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 |
|
10682
b511a318cd44
7099454: /bin/sh does not support syntax used in the src/os/posix/launcher/launcher.script shell script
brutisso
parents:
10565
diff
changeset
|
188 |
case `$EMACS -version 2> /dev/null` in |
7410 | 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) |
|
17382 | 202 |
$DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS; delete all" $LAUNCHER |
7410 | 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 |