author | weijun |
Mon, 08 Oct 2018 13:25:39 +0800 | |
changeset 52035 | f697ba5b18d2 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
10565 | 1 |
#!/bin/sh |
7410 | 2 |
|
33737
a1bd57411686
8139026: hotspot/make/hotspot.script cannot handle command-line arguments with spaces
iklam
parents:
32575
diff
changeset
|
3 |
# Copyright (c) 2010, 2015, 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 |
||
22734
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
52 |
# This is the name of the dbx binary to use |
7410 | 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 |
||
22734
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
71 |
OS=`uname -s` |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
72 |
|
7410 | 73 |
# 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
|
74 |
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
|
75 |
MYDIR=`cd $REL_MYDIR && pwd` |
22734
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
76 |
case "$OS" in |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
77 |
CYGWIN*) |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
78 |
MYDIR=`cygpath -m "$MYDIR"` |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
79 |
;; |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
80 |
esac |
7410 | 81 |
|
17382 | 82 |
# |
7410 | 83 |
# Look whether the user wants to run inside gdb |
84 |
case "$1" in |
|
85 |
-gdb) |
|
86 |
MODE=gdb |
|
87 |
shift |
|
88 |
;; |
|
89 |
-gud) |
|
90 |
MODE=gud |
|
91 |
shift |
|
92 |
;; |
|
93 |
-dbx) |
|
94 |
MODE=dbx |
|
95 |
shift |
|
96 |
;; |
|
97 |
-valgrind) |
|
98 |
MODE=valgrind |
|
99 |
shift |
|
100 |
;; |
|
101 |
*) |
|
102 |
MODE=run |
|
103 |
;; |
|
104 |
esac |
|
105 |
||
17382 | 106 |
if [ "${ALT_JAVA_HOME}" != "" ]; then |
107 |
JDK=${ALT_JAVA_HOME%%/jre} |
|
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
108 |
else |
17382 | 109 |
JDK=@@JDK_IMPORT_PATH@@ |
7410 | 110 |
fi |
111 |
||
22734
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
112 |
if [ "${JDK}" != "" ]; then |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
113 |
case "$OS" in |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
114 |
CYGWIN*) |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
115 |
JDK=`cygpath -m "$JDK"` |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
116 |
;; |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
117 |
esac |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
118 |
|
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
119 |
else |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
120 |
echo "Failed to find JDK." \ |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
121 |
"Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty." |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
122 |
exit 1 |
7452
b3fa838286de
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
7410
diff
changeset
|
123 |
fi |
b3fa838286de
7006354: Updates to Visual Studio project creation and development launcher
sla
parents:
7410
diff
changeset
|
124 |
|
7410 | 125 |
# We will set the LD_LIBRARY_PATH as follows: |
126 |
# o $JVMPATH (directory portion only) |
|
42633
0c23e9d8fccf
8066474: Remove the lib/ directory from Linux and Solaris images
erikj
parents:
33737
diff
changeset
|
127 |
# o $JRE/lib |
7410 | 128 |
# followed by the user's previous effective LD_LIBRARY_PATH, if |
129 |
# any. |
|
32575 | 130 |
JRE=$JDK |
7410 | 131 |
JAVA_HOME=$JDK |
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
132 |
export JAVA_HOME |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
133 |
|
42633
0c23e9d8fccf
8066474: Remove the lib/ directory from Linux and Solaris images
erikj
parents:
33737
diff
changeset
|
134 |
SBP=${MYDIR}:${JRE}/lib |
7410 | 135 |
|
136 |
||
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
137 |
# 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
|
138 |
if [ "${OS}" = "Darwin" ] |
7410 | 139 |
then |
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
140 |
if [ -z "$DYLD_LIBRARY_PATH" ] |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
141 |
then |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
142 |
DYLD_LIBRARY_PATH="$SBP" |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
143 |
else |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
144 |
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
|
145 |
fi |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
146 |
export DYLD_LIBRARY_PATH |
7410 | 147 |
else |
13514
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
148 |
# not 'Darwin' |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
149 |
if [ -z "$LD_LIBRARY_PATH" ] |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
150 |
then |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
151 |
LD_LIBRARY_PATH="$SBP" |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
152 |
else |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
153 |
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
|
154 |
fi |
1bbff39f54a2
7192916: Hotspot development launcher should use DYLD_LIBRARY_PATH on OS X
sla
parents:
10682
diff
changeset
|
155 |
export LD_LIBRARY_PATH |
7410 | 156 |
fi |
157 |
||
33737
a1bd57411686
8139026: hotspot/make/hotspot.script cannot handle command-line arguments with spaces
iklam
parents:
32575
diff
changeset
|
158 |
JPARMS="-XXaltjvm=$MYDIR -Dsun.java.launcher.is_altjvm=true"; |
7410 | 159 |
|
17382 | 160 |
# Locate the java launcher |
161 |
LAUNCHER=$JDK/bin/java |
|
7410 | 162 |
if [ ! -x $LAUNCHER ] ; then |
17382 | 163 |
echo Error: Cannot find the java launcher \"$LAUNCHER\" |
7410 | 164 |
exit 1 |
165 |
fi |
|
166 |
||
167 |
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
|
168 |
BASEDIR=`cd $MYDIR/../../.. && pwd` |
22734
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
169 |
case "$OS" in |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
170 |
CYGWIN*) |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
171 |
BASEDIR=`cygpath -m "$BASEDIR"` |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
172 |
;; |
41757c1f3946
8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
rdurbin
parents:
22234
diff
changeset
|
173 |
esac |
7410 | 174 |
|
175 |
init_gdb() { |
|
176 |
# Create a gdb script in case we should run inside gdb |
|
177 |
GDBSCR=/tmp/hsl.$$ |
|
178 |
rm -f $GDBSCR |
|
179 |
cat >>$GDBSCR <<EOF |
|
180 |
cd `pwd` |
|
181 |
handle SIGUSR1 nostop noprint |
|
182 |
handle SIGUSR2 nostop noprint |
|
183 |
directory $GDBSRCDIR |
|
184 |
# Get us to a point where we can set breakpoints in libjvm.so |
|
17382 | 185 |
set breakpoint pending on |
186 |
break JNI_CreateJavaVM |
|
7410 | 187 |
run |
17382 | 188 |
# Stop in JNI_CreateJavaVM |
7410 | 189 |
delete 1 |
190 |
# We can now set breakpoints wherever we like |
|
191 |
EOF |
|
192 |
} |
|
193 |
||
194 |
case "$MODE" in |
|
195 |
gdb) |
|
196 |
init_gdb |
|
33737
a1bd57411686
8139026: hotspot/make/hotspot.script cannot handle command-line arguments with spaces
iklam
parents:
32575
diff
changeset
|
197 |
$GDB -x $GDBSCR --args $LAUNCHER $JPARMS "$@" $JAVA_ARGS |
7410 | 198 |
rm -f $GDBSCR |
199 |
;; |
|
200 |
gud) |
|
201 |
init_gdb |
|
202 |
# First find out what emacs version we're using, so that we can |
|
203 |
# 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
|
204 |
case `$EMACS -version 2> /dev/null` in |
7410 | 205 |
*GNU\ Emacs\ 2[23]*) |
206 |
emacs_gud_cmd="gdba" |
|
207 |
emacs_gud_args="--annotate=3" |
|
208 |
;; |
|
209 |
*) |
|
210 |
emacs_gud_cmd="gdb" |
|
211 |
emacs_gud_args= |
|
212 |
;; |
|
213 |
esac |
|
214 |
$EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")"; |
|
215 |
rm -f $GDBSCR |
|
216 |
;; |
|
217 |
dbx) |
|
33737
a1bd57411686
8139026: hotspot/make/hotspot.script cannot handle command-line arguments with spaces
iklam
parents:
32575
diff
changeset
|
218 |
$DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS $@ $JAVA_ARGS; delete all" $LAUNCHER |
7410 | 219 |
;; |
220 |
valgrind) |
|
221 |
echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap |
|
222 |
echo |
|
33737
a1bd57411686
8139026: hotspot/make/hotspot.script cannot handle command-line arguments with spaces
iklam
parents:
32575
diff
changeset
|
223 |
$VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS "$@" $JAVA_ARGS |
7410 | 224 |
;; |
225 |
run) |
|
33737
a1bd57411686
8139026: hotspot/make/hotspot.script cannot handle command-line arguments with spaces
iklam
parents:
32575
diff
changeset
|
226 |
LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS "$@" $JAVA_ARGS |
7410 | 227 |
;; |
228 |
*) |
|
229 |
echo Error: Internal error, unknown launch mode \"$MODE\" |
|
230 |
exit 1 |
|
231 |
;; |
|
232 |
esac |
|
233 |
RETVAL=$? |
|
234 |
exit $RETVAL |