author | mikejwre |
Thu, 25 Mar 2010 15:05:15 -0700 | |
changeset 5074 | 9c9bfe8f3a47 |
parent 4325 | 38a035021ba1 |
child 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2 | 1 |
#!/bin/sh |
2 |
||
3 |
# |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
4 |
# Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved. |
2 | 5 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6 |
# |
|
7 |
# This code is free software; you can redistribute it and/or modify it |
|
8 |
# under the terms of the GNU General Public License version 2 only, as |
|
9 |
# published by the Free Software Foundation. |
|
10 |
# |
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
# accompanied this code). |
|
16 |
# |
|
17 |
# You should have received a copy of the GNU General Public License version |
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
# |
|
21 |
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
# CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
# have any questions. |
|
24 |
# |
|
25 |
||
26 |
# |
|
27 |
# |
|
28 |
# jtreg runs this in a scratch dir. |
|
29 |
# It (and runregress -no) sets these env vars: |
|
30 |
# TESTSRC: The dir that contains this file |
|
31 |
# TESTCLASSES: Where .class files are compiled to |
|
32 |
# TESTJAVA: The jdk to run |
|
33 |
# |
|
34 |
# This is a 'library' script that is included by |
|
35 |
# shell script test cases that want to run a .java file as the debuggee |
|
36 |
# and use jdb as the debugger. This file contains |
|
37 |
# several functions that support such a test. |
|
38 |
||
39 |
# The caller script can also set these shell vars before |
|
40 |
# including this file: |
|
41 |
# pkg=<package name> To use a package, define it here and put |
|
42 |
# package $pkg |
|
43 |
# in your java file |
|
44 |
# classname=<classnam> Omit this to use the default class name, 'shtest'. |
|
45 |
||
46 |
# compileOptions=<string> compile options for at least the first compile, |
|
47 |
# eg, compileOptions=-g |
|
48 |
# compileOptions2=<string> Options for the 2nd, ..., compile. compileOptions1 |
|
49 |
# is used if this is not set. To use no compile |
|
50 |
# options for the 2nd ... compiles, do |
|
51 |
# compileOptions2=none |
|
52 |
# |
|
53 |
# mode=-Xcomp or mode=-Xint to run in these modes. These should not |
|
54 |
# really be used since the tests are normally |
|
55 |
# run in both modes. |
|
56 |
# javacCmd=path-to-javac to use a non-standard javac for compiling |
|
57 |
# compileOptions=<string> Options to pass to javac |
|
58 |
# |
|
59 |
# See RedefineException.sh as an example of a caller script. |
|
60 |
# |
|
61 |
# To do RedefineClasses operations, embed @1 tags in the .java |
|
62 |
# file to tell this script how to modify it to produce the 2nd |
|
63 |
# version of the .class file to be used in the redefine operation. |
|
64 |
# Here are examples of each editting tag and what change |
|
65 |
# it causes in the new file. Note that blanks are not preserved |
|
66 |
# in these editing operations. |
|
67 |
# |
|
68 |
# @1 uncomment |
|
69 |
# orig: // @1 uncomment gus = 89; |
|
70 |
# new: gus = 89; |
|
71 |
# |
|
72 |
# @1 commentout |
|
73 |
# orig: gus = 89 // @1 commentout |
|
74 |
# new: // gus = 89 // @1 commentout |
|
75 |
# |
|
76 |
# @1 delete |
|
77 |
# orig: gus = 89 // @1 delete |
|
78 |
# new: entire line deleted |
|
79 |
# |
|
80 |
# @1 newline |
|
81 |
# orig: gus = 89; // @1 newline gus++; |
|
82 |
# new: gus = 89; // |
|
83 |
# gus++; |
|
84 |
# |
|
85 |
# @1 replace |
|
86 |
# orig: gus = 89; // @1 replace gus = 90; |
|
87 |
# new: gus = 90; |
|
88 |
# |
|
89 |
# The only other tag supported is @1 breakpoint. The setbkpts function |
|
90 |
# sets bkpts at all lines that contain this string. |
|
91 |
# |
|
92 |
# Currently, all these tags are start with @1. It is envisioned that this script |
|
93 |
# could be ehanced to allow multiple cycles of redefines by allowing |
|
94 |
# @2, @3, ... tags. IE, processing the @i tags in the ith version of |
|
95 |
# the file will produce the i+1th version of the file. |
|
96 |
# |
|
97 |
# There are problem with jtreg leaving behind orphan java and jdb processes |
|
98 |
# when this script is run. Sometimes, on some platforms, it just doesn't |
|
99 |
# get them all killed properly. |
|
100 |
# The solution is to put a magic word in the cmd lines of background java |
|
101 |
# and jdb processes this script launches. We can then do the right kind |
|
102 |
# of ps cmds to find all these processes and kill them. We do this by |
|
103 |
# trapping the completion of this script. |
|
104 |
# |
|
105 |
# An associated problem is that our trap handler (cleanup) doesn't |
|
106 |
# always get called when jtreg terminates a test. This can leave tests |
|
107 |
# hanging but following tests should run ok because each test uses |
|
108 |
# unique names for the port and temp files (based on the PID returned |
|
109 |
# by $$). |
|
110 |
# |
|
111 |
# mks 6.2a on win 98 presents two problems: |
|
112 |
# $! returns the PID as a negative number whereas ps returns |
|
113 |
# it in the form 0xFFF.... This means our trick of |
|
114 |
# of using $! to get the PIDs of the jdb and debuggee processes |
|
115 |
# doesn't work. This will cause some error cases to fail |
|
116 |
# with a jtreg timeout instead of failing more gracefully. |
|
117 |
# |
|
118 |
# There is no form of the ps command that will show the whole |
|
119 |
# cmd line. Thus, the magic keyword trick doesn't work. We |
|
120 |
# resort to just killing java.exe and jdb.exes |
|
121 |
# |
|
122 |
# pid usage: |
|
123 |
# debuggeepid: used in jdb process to detect if debuggee has died. |
|
124 |
# - waitForDebuggeeMsg: fail if debuggee is gone |
|
125 |
# |
|
126 |
# jdbpid: dofail: used to detect if in main process or jdb process |
|
127 |
# waitforfinish: quit if the jdb process is gone |
|
128 |
||
129 |
#killcmd=/bin/kill |
|
130 |
killcmd=kill |
|
131 |
||
132 |
# This can be increased if timing seems to be an issue. |
|
133 |
sleep_seconds=1 |
|
134 |
||
135 |
echo "ShellScaffold.sh: Version" >& 2 |
|
136 |
topPid=$$ |
|
137 |
||
138 |
# Be careful to echo to >& in these general functions. |
|
139 |
# If they are called from the functions that are sending |
|
140 |
# cmds to jdb, then stdout is redirected to jdb. |
|
141 |
cleanup() |
|
142 |
{ |
|
143 |
if [ -r "$failFile" ] ; then |
|
144 |
cat $failFile >& 2 |
|
145 |
fi |
|
146 |
||
147 |
# Kill all processes that have our special |
|
148 |
# keyword in their cmd line. |
|
149 |
killOrphans cleanup $jdbKeyword |
|
150 |
killOrphans cleanup $debuggeeKeyword |
|
151 |
} |
|
152 |
||
153 |
# Kill all processes with $2 in their cmd lines |
|
154 |
# Print a msg about this using $1 as the prefix |
|
155 |
killOrphans() |
|
156 |
{ |
|
157 |
str=$2 |
|
158 |
||
159 |
if [ -z "$isCygwin" ] ; then |
|
160 |
toBeKilled=`$psCmd | $grep -v grep | $grep -i $str | awk '{print $1}' | tr '\n\r' ' '` |
|
161 |
else |
|
162 |
# The cygwin ps command doesn't show the options passed to a cmd. |
|
163 |
# We will use jps to get the win PID of the command, and |
|
164 |
# then use ps to find the cygwin pid to be killed. |
|
165 |
# The form of a ps output line is |
|
166 |
# ^ ddddd dddd dddd dddd.* |
|
167 |
# where the 4th digits are the win pid and the first |
|
168 |
# are the cygwin pid. |
|
169 |
if [ -r "$jdk/bin/$jstack" ] ; then |
|
170 |
winPid=`$jdk/bin/jps -v | $grep -i $str | sed -e 's@ .*@@'` |
|
171 |
if [ ! -z "$winPid" ] ; then |
|
172 |
# Here is a way to kill using a win cmd and the win PID. |
|
173 |
#echo "$1: taskkill /F $winPid" >& 2 |
|
174 |
#taskkill /F /PID $winPid |
|
175 |
||
176 |
toBeKilled=`$psCmd | $grep -v grep | \ |
|
177 |
$grep '^ +[0-9]+ +[0-9]+ +[0-9]+ +'"$winPid" |\ |
|
178 |
awk '{print $1}' | tr '\n\r' ' '` |
|
179 |
fi |
|
180 |
else |
|
181 |
# Well, too bad - we can't find what to kill. |
|
182 |
toBeKilled= |
|
183 |
fi |
|
184 |
fi |
|
185 |
||
186 |
if [ ! -z "$toBeKilled" ] ; then |
|
187 |
echo "$1: kill -9 $toBeKilled" >& 2 |
|
188 |
kill -9 $toBeKilled |
|
189 |
fi |
|
190 |
} |
|
191 |
||
192 |
findPid() |
|
193 |
{ |
|
194 |
# Return 0 if $1 is the pid of a running process. |
|
195 |
if [ -z "$isWin98" ] ; then |
|
3954
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
196 |
if [ "$osname" = SunOS ] ; then |
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
197 |
# Solaris and OpenSolaris use pgrep and not ps in psCmd |
3954
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
198 |
findPidCmd="$psCmd" |
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
199 |
else |
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
200 |
# Never use plain 'ps', which requires a "controlling terminal" |
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
201 |
# and will fail with a "ps: no controlling terminal" error. |
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
202 |
# Running under 'rsh' will cause this ps error. |
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
203 |
# cygwin ps puts an I in column 1 for some reason. |
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
204 |
findPidCmd="$psCmd -e" |
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
205 |
fi |
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
206 |
$findPidCmd | $grep '^I* *'"$1 " > $devnull 2>&1 |
2 | 207 |
return $? |
208 |
fi |
|
209 |
||
210 |
# mks 6.2a on win98 has $! getting a negative |
|
211 |
# number and in ps, it shows up as 0x... |
|
212 |
# Thus, we can't search in ps output for |
|
213 |
# PIDs gotten via $! |
|
214 |
# We don't know if it is running or not - assume it is. |
|
215 |
# We don't really care about win98 anymore. |
|
216 |
return 0 |
|
217 |
} |
|
218 |
||
219 |
setup() |
|
220 |
{ |
|
221 |
failed= |
|
222 |
# This is used to tag each java and jdb cmd we issue so |
|
223 |
# we can kill them at the end of the run. |
|
224 |
||
225 |
orphanKeyword=HANGINGJAVA-$$ |
|
226 |
debuggeeKeyword=${orphanKeyword}_DEB |
|
227 |
jdbKeyword=${orphanKeyword}_JDB |
|
228 |
baseArgs=-D${debuggeeKeyword} |
|
229 |
if [ -z "$TESTCLASSES" ] ; then |
|
230 |
echo "--Warning: TESTCLASSES is not defined; using TESTCLASSES=." |
|
231 |
echo " You should run: " |
|
232 |
echo " runregress $0 -no" |
|
233 |
echo " or" |
|
234 |
echo " (setenv TESTCLASSES .; $0 $*)" |
|
235 |
TESTCLASSES=. |
|
236 |
fi |
|
237 |
if [ ! -z "$TESTJAVA" ] ; then |
|
238 |
jdk="$TESTJAVA" |
|
239 |
else |
|
240 |
echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test." |
|
241 |
exit 1 |
|
242 |
fi |
|
243 |
||
244 |
ulimitCmd= |
|
245 |
osname=`uname -s` |
|
246 |
isWin98= |
|
247 |
isCygwin= |
|
248 |
case "$osname" in |
|
249 |
Windows* | CYGWIN*) |
|
250 |
if [ "$osname" = Windows_98 -o "$osname" = Windows_ME ]; then |
|
251 |
isWin98=1 |
|
252 |
debuggeeKeyword='we_cant_kill_debuggees_on_win98' |
|
253 |
jdbKeyword='jdb\.exe' |
|
254 |
fi |
|
255 |
||
256 |
case "$osname" in |
|
257 |
CYGWIN*) |
|
258 |
isCygwin=1 |
|
259 |
;; |
|
260 |
esac |
|
261 |
||
262 |
if [ -r $jdk/bin/dt_shmem.dll -o -r $jdk/jre/bin/dt_shmem.dll ] ; then |
|
263 |
transport=dt_shmem |
|
264 |
address=kkkk.$$ |
|
265 |
else |
|
266 |
transport=dt_socket |
|
267 |
address= |
|
268 |
fi |
|
269 |
devnull=NUL |
|
270 |
baseArgs="$baseArgs -XX:-ShowMessageBoxOnError" |
|
271 |
# jtreg puts \\s in TESTCLASSES and some uses, eg. echo |
|
272 |
# treat them as control chars on mks (eg \t is tab) |
|
273 |
# Oops; windows mks really seems to want this cat line |
|
274 |
# to start in column 1 |
|
275 |
if [ -w "$SystemRoot" ] ; then |
|
276 |
tmpFile=$SystemRoot/tmp.$$ |
|
277 |
elif [ -w "$SYSTEMROOT" ] ; then |
|
278 |
tmpFile=$SYSTEMROOT/tmp.$$ |
|
279 |
else |
|
280 |
tmpFile=tmp.$$ |
|
281 |
fi |
|
282 |
cat <<EOF >$tmpFile |
|
283 |
$TESTCLASSES |
|
284 |
EOF |
|
285 |
TESTCLASSES=`cat $tmpFile | sed -e 's@\\\\@/@g'` |
|
286 |
rm -f $tmpFile |
|
287 |
# on mks |
|
288 |
grep=egrep |
|
289 |
psCmd=ps |
|
290 |
jstack=jstack.exe |
|
291 |
;; |
|
292 |
SunOS | Linux) |
|
293 |
transport=dt_socket |
|
294 |
address= |
|
295 |
devnull=/dev/null |
|
296 |
grep=egrep |
|
297 |
jstack=jstack |
|
298 |
# On linux, core files take a long time, and can leave |
|
299 |
# zombie processes |
|
300 |
if [ "$osname" = SunOS ] ; then |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
301 |
# Experiments show Solaris '/usr/ucb/ps -axwww' and |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
302 |
# '/usr/bin/pgrep -f -l' provide the same small amount of the |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
303 |
# argv string (PRARGSZ=80 in /usr/include/sys/procfs.h) |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
304 |
# 1) This seems to have been working OK in ShellScaffold. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
305 |
# 2) OpenSolaris does not provide /usr/ucb/ps, so use pgrep |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
306 |
# instead |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
307 |
# The alternative would be to use /usr/bin/pargs [pid] to get |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
308 |
# all the args for a process, splice them back into one |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
309 |
# long string, then grep. |
4153
c019b5df1bf5
6893426: ShellScaffold.sh fails on Solaris 10 update releases: /usr/bin/id: illegal option -- u
tbell
parents:
3954
diff
changeset
|
310 |
UU=`/usr/xpg4/bin/id -u -n` |
3954
19ed60dbd0b7
6787605: OpenSolaris doesn't have /usr/ucb/ps so ShellScaffold fails
tbell
parents:
2
diff
changeset
|
311 |
psCmd="pgrep -f -l -U $UU" |
2 | 312 |
else |
313 |
ulimit -c 0 |
|
314 |
# See bug 6238593. |
|
315 |
psCmd="ps axwww" |
|
316 |
fi |
|
317 |
;; |
|
318 |
*) |
|
319 |
echo "--Error: Unknown result from 'uname -s': $osname" |
|
320 |
exit 1 |
|
321 |
;; |
|
322 |
esac |
|
323 |
||
324 |
||
325 |
tmpFileDir=$TESTCLASSES/aa$$ |
|
326 |
TESTCLASSES=$tmpFileDir |
|
327 |
||
328 |
mkdir -p $tmpFileDir |
|
329 |
||
330 |
# This must not contain 'jdb' or it shows up |
|
331 |
# in grep of ps output for some platforms |
|
332 |
jdbOutFile=$tmpFileDir/jxdbOutput.txt |
|
333 |
rm -f $jdbOutFile |
|
334 |
touch $jdbOutFile |
|
335 |
||
336 |
debuggeeOutFile=$tmpFileDir/debuggeeOutput.txt |
|
337 |
failFile=$tmpFileDir/testFailed |
|
338 |
debuggeepidFile=$tmpFileDir/debuggeepid |
|
339 |
rm -f $failFile $debuggeepidFile |
|
340 |
||
341 |
if [ -z "$pkg" ] ; then |
|
342 |
pkgSlash= |
|
343 |
pkgDot= |
|
344 |
redefineSubdir=. |
|
345 |
else |
|
346 |
pkgSlash=$pkg/ |
|
347 |
pkgDot=$pkg. |
|
348 |
redefineSubdir=$pkgSlash |
|
349 |
fi |
|
350 |
if [ -z "$classname" ] ; then |
|
351 |
classname=shtest |
|
352 |
fi |
|
353 |
||
354 |
if [ -z "$java" ] ; then |
|
355 |
java=java |
|
356 |
fi |
|
357 |
||
358 |
if [ -z "$jdb" ] ; then |
|
359 |
jdb=$jdk/bin/jdb |
|
360 |
fi |
|
361 |
||
362 |
####################################################3 |
|
363 |
####################################################3 |
|
364 |
####################################################3 |
|
365 |
####################################################3 |
|
366 |
# sol: this gets all processes killed but |
|
367 |
# no jstack |
|
368 |
# linux same as above |
|
369 |
# win mks: No dice; processes still running |
|
370 |
trap "cleanup" 0 1 2 3 4 6 9 10 15 |
|
371 |
||
372 |
jdbOptions="$jdbOptions -J-D${jdbKeyword}" |
|
373 |
} |
|
374 |
||
375 |
docompile() |
|
376 |
{ |
|
377 |
if [ "$compile" = 0 ] ; then |
|
378 |
return |
|
379 |
fi |
|
380 |
saveDir=`pwd` |
|
381 |
cd $tmpFileDir |
|
382 |
rm -f *.java |
|
383 |
createJavaFile $classname |
|
384 |
||
385 |
# Compile two versions of the file, the original and with the |
|
386 |
# indicated lines modified. |
|
387 |
cp $classname.java.1 $classname.java |
|
388 |
echo "--Compiling first version of `pwd`/$classname.java with options: $compileOptions" |
|
389 |
# Result is in $pkgSlash$classname.class |
|
390 |
||
391 |
if [ -z "$javacCmd" ] ; then |
|
392 |
javacCmd=$jdk/bin/javac |
|
393 |
fi |
|
394 |
||
395 |
echo "compiling " `ls *.java` |
|
396 |
$javacCmd $compileOptions -d . *.java |
|
397 |
if [ $? != 0 ] ; then |
|
398 |
dofail "First compile failed" |
|
399 |
fi |
|
400 |
if [ -r vers1 ] ; then |
|
401 |
rm -rf vers1 |
|
402 |
fi |
|
403 |
mkdir -p vers1 |
|
404 |
mv *.class vers1 |
|
405 |
if [ ! -z "$compileOptions2" ] ; then |
|
406 |
if [ "$compileOptions2" = none ] ; then |
|
407 |
compileOptions= |
|
408 |
else |
|
409 |
compileOptions=$compileOptions2 |
|
410 |
fi |
|
411 |
fi |
|
412 |
||
413 |
while [ 1 = 1 ] ; do |
|
414 |
# Not really a loop; just a way to avoid goto |
|
415 |
# by using breaks |
|
416 |
sed -e '/@1 *delete/ d' \ |
|
417 |
-e 's! *// *@1 *uncomment! !' \ |
|
418 |
-e 's!\(.*@1 *commentout\)!//\1!' \ |
|
419 |
-e 's/@1 *newline/\ |
|
420 |
/' \ |
|
421 |
-e 's/.*@1 *replace//' \ |
|
422 |
$classname.java.1 >$classname.java |
|
423 |
||
424 |
cmp -s $classname.java.1 $classname.java |
|
425 |
if [ $? = 0 ] ; then |
|
426 |
break |
|
427 |
fi |
|
428 |
echo |
|
429 |
echo "--Compiling second version of `pwd`/$classname.java with $compileOptions" |
|
430 |
$javacCmd $compileOptions -d . $classname.java |
|
431 |
if [ $? != 0 ] ; then |
|
432 |
dofail "Second compile failed" |
|
433 |
fi |
|
434 |
if [ -r vers2 ] ; then |
|
435 |
rm -rf vers2 |
|
436 |
fi |
|
437 |
mkdir -p vers2 |
|
438 |
mv *.class vers2 |
|
439 |
mv $classname.java $classname.java.2 |
|
440 |
cp $classname.java.1 $classname.java |
|
441 |
||
442 |
###### Do the same for @2, and @3 allowing 3 redefines to occur. |
|
443 |
###### If I had more time to write sed cmds, I would do |
|
444 |
###### this in a loop. But, I don't think we will ever need |
|
445 |
###### more than 3 redefines. |
|
446 |
sed -e '/@2 *delete/ d' \ |
|
447 |
-e 's! *// *@2 *uncomment! !' \ |
|
448 |
-e 's!\(.*@2 *commentout\)!//\1!' \ |
|
449 |
-e 's/@2 *newline/\ |
|
450 |
/' \ |
|
451 |
-e 's/.*@2 *replace//' \ |
|
452 |
$classname.java.2 >$classname.java |
|
453 |
cmp -s $classname.java.2 $classname.java |
|
454 |
if [ $? = 0 ] ; then |
|
455 |
break |
|
456 |
fi |
|
457 |
echo |
|
458 |
echo "--Compiling third version of `pwd`/$classname.java with $compileOptions" |
|
459 |
$javacCmd $compileOptions -d . $classname.java |
|
460 |
if [ $? != 0 ] ; then |
|
461 |
dofail "Third compile failed" |
|
462 |
fi |
|
463 |
if [ -r vers3 ] ; then |
|
464 |
rm -rf vers3 |
|
465 |
fi |
|
466 |
mkdir -p vers3 |
|
467 |
mv *.class vers3 |
|
468 |
mv $classname.java $classname.java.3 |
|
469 |
cp $classname.java.1 $classname.java |
|
470 |
||
471 |
######## |
|
472 |
sed -e '/@3 *delete/ d' \ |
|
473 |
-e 's! *// *@3 *uncomment! !' \ |
|
474 |
-e 's!\(.*@3 *commentout\)!//\1!' \ |
|
475 |
-e 's/@3 *newline/\ |
|
476 |
/' \ |
|
477 |
-e 's/.*@3 *replace//' \ |
|
478 |
$classname.java.3 >$classname.java |
|
479 |
cmp -s $classname.java.3 $classname.java |
|
480 |
if [ $? = 0 ] ; then |
|
481 |
break |
|
482 |
fi |
|
483 |
echo |
|
484 |
echo "--Compiling fourth version of `pwd`/$classname.java with $compileOptions" |
|
485 |
$javacCmd $compileOptions -d . $classname.java |
|
486 |
if [ $? != 0 ] ; then |
|
487 |
dofail "fourth compile failed" |
|
488 |
fi |
|
489 |
if [ -r vers4 ] ; then |
|
490 |
rm -rf vers4 |
|
491 |
fi |
|
492 |
mkdir -p vers4 |
|
493 |
mv *.class vers4 |
|
494 |
mv $classname.java $classname.java.4 |
|
495 |
cp $classname.java.1 $classname.java |
|
496 |
break |
|
497 |
fgrep @4 $classname.java |
|
498 |
if [ $? = 0 ] ; then |
|
499 |
echo "--Error: @4 and above are not yet allowed" |
|
500 |
exit 1 |
|
501 |
fi |
|
502 |
done |
|
503 |
||
504 |
cp vers1/* $redefineSubdir |
|
505 |
cd $saveDir |
|
506 |
} |
|
507 |
||
508 |
# Send a cmd to jdb and wait for the jdb prompt to appear. |
|
509 |
# We don't want to allow > as a prompt because if the debuggee |
|
510 |
# runs for awhile after a command, jdb will show this prompt |
|
511 |
# but is not really ready to accept another command for the |
|
512 |
# debuggee - ie, a cont in this state will be ignored. |
|
513 |
# If it ever becomes necessary to send a jdb command before |
|
514 |
# a main[10] form of prompt appears, then this |
|
515 |
# code will have to be modified. |
|
516 |
cmd() |
|
517 |
{ |
|
518 |
if [ $1 = quit -o -r "$failFile" ] ; then |
|
519 |
# if jdb got a cont cmd that caused the debuggee |
|
520 |
# to run to completion, jdb can be gone before |
|
521 |
# we get here. |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
522 |
echo "--Sending cmd: quit" >& 2 |
2 | 523 |
echo quit |
524 |
# See 6562090. Maybe there is a way that the exit |
|
525 |
# can cause jdb to not get the quit. |
|
526 |
sleep 5 |
|
527 |
exit 1 |
|
528 |
fi |
|
529 |
||
530 |
# $jdbOutFile always exists here and is non empty |
|
531 |
# because after starting jdb, we waited |
|
532 |
# for the prompt. |
|
533 |
fileSize=`wc -c $jdbOutFile | awk '{ print $1 }'` |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
534 |
echo "--Sending cmd: " $* >&2 |
2 | 535 |
|
536 |
# jjh: We have a few intermittent failures here. |
|
537 |
# It is as if every so often, jdb doesn't |
|
538 |
# get the first cmd that is sent to it here. |
|
539 |
# (actually, I have seen it get the first cmd ok, |
|
540 |
# but then not get some subsequent cmd). |
|
541 |
# It seems like jdb really doesn't get the cmd; jdb's response |
|
542 |
# does not appear in the jxdboutput file. It contains: |
|
543 |
# main[1] |
|
544 |
# The application has been disconnected |
|
545 |
||
546 |
# Is it possible |
|
547 |
# that jdb got the cmd ok, but its response didn't make |
|
548 |
# it to the jxdboutput file? If so, why did 'The application |
|
549 |
# has been disconnected' make it? |
|
550 |
||
551 |
# This causes the following loop to timeout and the test to fail. |
|
552 |
# The above echo works because the cmd (stop at ...) |
|
553 |
# is in the System.err shown in the .jtr file. |
|
554 |
# Also, the cmd is shown in the 'jdb never responded ...' |
|
555 |
# msg output below after the timeout. |
|
556 |
# And, we know jdb is started because the main[1] output is in the .jtr |
|
557 |
# file. And, we wouldn't have gotten here if mydojdbcmds hadn't |
|
558 |
# seen the ]. |
|
559 |
echo $* |
|
560 |
||
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
561 |
# Now we have to wait for the next jdb prompt. We wait for a pattern |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
562 |
# to appear in the last line of jdb output. Normally, the prompt is |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
563 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
564 |
# 1) ^main[89] @ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
565 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
566 |
# where ^ means start of line, and @ means end of file with no end of line |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
567 |
# and 89 is the current command counter. But we have complications e.g., |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
568 |
# the following jdb output can appear: |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
569 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
570 |
# 2) a[89] = 10 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
571 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
572 |
# The above form is an array assignment and not a prompt. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
573 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
574 |
# 3) ^main[89] main[89] ... |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
575 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
576 |
# This occurs if the next cmd is one that causes no jdb output, e.g., |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
577 |
# 'trace methods'. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
578 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
579 |
# 4) ^main[89] [main[89]] .... > @ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
580 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
581 |
# jdb prints a > as a prompt after something like a cont. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
582 |
# Thus, even though the above is the last 'line' in the file, it |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
583 |
# isn't the next prompt we are waiting for after the cont completes. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
584 |
# HOWEVER, sometimes we see this for a cont command: |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
585 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
586 |
# ^main[89] $ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
587 |
# <lines output for hitting a bkpt> |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
588 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
589 |
# 5) ^main[89] > @ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
590 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
591 |
# i.e., the > prompt comes out AFTER the prompt we we need to wait for. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
592 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
593 |
# So, how do we know when the next prompt has appeared?? |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
594 |
# 1. Search for |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
595 |
# main[89] $ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
596 |
# This will handle cases 1, 2, 3 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
597 |
# 2. This leaves cases 4 and 5. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
598 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
599 |
# What if we wait for 4 more chars to appear and then search for |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
600 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
601 |
# main[89] [>]$ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
602 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
603 |
# on the last line? |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
604 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
605 |
# a. if we are currently at |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
606 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
607 |
# ^main[89] main[89] @ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
608 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
609 |
# and a 'trace methods comes in, we will wait until at least |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
610 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
611 |
# ^main[89] main[89] main@ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
612 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
613 |
# and then the search will find the new prompt when it completes. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
614 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
615 |
# b. if we are currently at |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
616 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
617 |
# ^main[89] main[89] @ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
618 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
619 |
# and the first form of cont comes in, then we will see |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
620 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
621 |
# ^main[89] main[89] > $ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
622 |
# ^x@ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
623 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
624 |
# where x is the first char of the msg output when the bkpt is hit |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
625 |
# and we will start our search, which will find the prompt |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
626 |
# when it comes out after the bkpt output, with or without the |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
627 |
# trailing > |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
628 |
# |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
629 |
|
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
630 |
# wait for 4 new chars to appear in the jdb output |
2 | 631 |
count=0 |
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
632 |
desiredFileSize=`expr $fileSize + 4` |
2 | 633 |
msg1=`echo At start: cmd/size/waiting : $* / $fileSize / \`date\`` |
634 |
while [ 1 = 1 ] ; do |
|
635 |
newFileSize=`wc -c $jdbOutFile | awk '{ print $1 } '` |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
636 |
#echo jj: desired = $desiredFileSize, new = $newFileSize >& 2 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
637 |
|
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
638 |
done=`expr $newFileSize \>= $desiredFileSize` |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
639 |
if [ $done = 1 ] ; then |
2 | 640 |
break |
641 |
fi |
|
642 |
sleep ${sleep_seconds} |
|
643 |
count=`expr $count + 1` |
|
644 |
if [ $count = 30 -o $count = 60 ] ; then |
|
645 |
# record some debug info. |
|
646 |
echo "--DEBUG: jdb $$ didn't responded to command in $count secs: $*" >& 2 |
|
647 |
echo "--DEBUG:" $msg1 >& 2 |
|
648 |
echo "--DEBUG: "done size/waiting : / $newFileSize / `date` >& 2 |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
649 |
echo "-- $jdbOutFile follows-------------------------------" >& 2 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
650 |
cat $jdbOutFile >& 2 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
651 |
echo "------------------------------------------" >& 2 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
652 |
dojstack |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
653 |
#$psCmd | sed -e '/com.sun.javatest/d' -e '/nsk/d' >& 2 |
2 | 654 |
if [ $count = 60 ] ; then |
655 |
dofail "jdb never responded to command: $*" |
|
656 |
fi |
|
657 |
fi |
|
658 |
done |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
659 |
# Note that this assumes just these chars in thread names. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
660 |
waitForJdbMsg '[a-zA-Z0-9_-][a-zA-Z0-9_-]*\[[1-9][0-9]*\] [ >]*$' \ |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
661 |
1 allowExit |
2 | 662 |
} |
663 |
||
664 |
setBkpts() |
|
665 |
{ |
|
666 |
# Can set multiple bkpts, but only in one class. |
|
667 |
# $1 is the bkpt name, eg, @1 |
|
668 |
allLines=`$grep -n "$1 *breakpoint" $tmpFileDir/$classname.java.1 | sed -e 's@^\([0-9]*\).*@\1@g'` |
|
669 |
for ii in $allLines ; do |
|
670 |
cmd stop at $pkgDot$classname:$ii |
|
671 |
done |
|
672 |
} |
|
673 |
||
674 |
runToBkpt() |
|
675 |
{ |
|
676 |
cmd run |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
677 |
# Don't need to do this - the above waits for the next prompt which comes out |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
678 |
# AFTER the Breakpoint hit message. |
2 | 679 |
# Wait for jdb to hit the bkpt |
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
680 |
#waitForJdbMsg "Breakpoint hit" 5 |
2 | 681 |
} |
682 |
||
683 |
contToBkpt() |
|
684 |
{ |
|
685 |
cmd cont |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
686 |
# Don't need to do this - the above waits for the next prompt which comes out |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
687 |
# AFTER the Breakpoint hit message. |
2 | 688 |
# Wait for jdb to hit the bkpt |
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
689 |
#waitForJdbMsg "Breakpoint hit" 5 |
2 | 690 |
} |
691 |
||
692 |
||
693 |
# Wait until string $1 appears in the output file, within the last $2 lines |
|
694 |
# If $3 is allowExit, then don't fail if jdb exits before |
|
695 |
# the desired string appears. |
|
696 |
waitForJdbMsg() |
|
697 |
{ |
|
698 |
# This can be called from the jdb thread which doesn't |
|
699 |
# have access to $debuggeepid, so we have to read it from the file. |
|
700 |
nlines=$2 |
|
701 |
allowExit="$3" |
|
702 |
myCount=0 |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
703 |
timeLimit=40 # wait a max of this many secs for a response from a jdb command |
2 | 704 |
while [ 1 = 1 ] ; do |
705 |
if [ -r $jdbOutFile ] ; then |
|
706 |
# Something here causes jdb to complain about Unrecognized cmd on x86. |
|
707 |
tail -$nlines $jdbOutFile | $grep -s "$1" > $devnull 2>&1 |
|
708 |
if [ $? = 0 ] ; then |
|
709 |
# Found desired string |
|
710 |
break |
|
711 |
fi |
|
712 |
fi |
|
713 |
tail -2 $jdbOutFile | $grep -s "The application exited" > $devnull 2>&1 |
|
714 |
if [ $? = 0 ] ; then |
|
715 |
# Found 'The application exited' |
|
716 |
if [ ! -z "$allowExit" ] ; then |
|
717 |
break |
|
718 |
fi |
|
719 |
# Otherwise, it is an error if we don't find $1 |
|
720 |
if [ -r $jdbOutFile ] ; then |
|
721 |
tail -$nlines $jdbOutFile | $grep -s "$1" > $devnull 2>&1 |
|
722 |
if [ $? = 0 ] ; then |
|
723 |
break |
|
724 |
fi |
|
725 |
fi |
|
726 |
dofail "Waited for jdb msg $1, but it never appeared" |
|
727 |
fi |
|
728 |
||
729 |
sleep ${sleep_seconds} |
|
730 |
findPid $topPid |
|
731 |
if [ $? != 0 ] ; then |
|
732 |
# Top process is dead. We better die too |
|
733 |
dojstack |
|
734 |
exit 1 |
|
735 |
fi |
|
736 |
||
737 |
myCount=`expr $myCount + ${sleep_seconds}` |
|
738 |
if [ $myCount -gt $timeLimit ] ; then |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
739 |
echo "--Fail: waitForJdbMsg timed out after $timeLimit seconds, looking for /$1/, in $nlines lines; exitting" >> $failFile |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
740 |
echo "vv jdbOutFile vvvvvvvvvvvvvvvvvvvvvvvvvvvv" >& 2 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
741 |
cat $jdbOutFile >& 2 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
742 |
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" >& 2 |
2 | 743 |
dojstack |
744 |
exit 1 |
|
745 |
fi |
|
746 |
done |
|
747 |
||
748 |
} |
|
749 |
||
750 |
# $1 is the string to print. If $2 exists, |
|
751 |
# it is the name of a file to print, ie, the name |
|
752 |
# of the file that contains the $1 string. |
|
753 |
dofail() |
|
754 |
{ |
|
755 |
if [ ! -z "$jdbpid" ] ; then |
|
756 |
# we are in the main process instead of the jdb process |
|
757 |
echo " " >> $failFile |
|
758 |
echo "--Fail: main: $*" >> $failFile |
|
759 |
else |
|
760 |
# Kill the debuggee ; it could be hung so |
|
761 |
# we want to get rid of it as soon as possible. |
|
762 |
killOrphans "killing debuggee" $debuggeeKeyword |
|
763 |
||
764 |
echo " " >>$failFile |
|
765 |
echo "--Fail: $*" >> $failFile |
|
766 |
echo quit |
|
767 |
fi |
|
768 |
if [ ! -z "$2" ] ; then |
|
769 |
echo "---- contents of $2 follows -------" >> $failFile |
|
770 |
cat "$2" >> $failFile |
|
771 |
echo "---------------" >>$failFile |
|
772 |
fi |
|
773 |
exit 1 |
|
774 |
} |
|
775 |
||
776 |
||
777 |
redefineClass() |
|
778 |
{ |
|
779 |
if [ -z "$1" ] ; then |
|
780 |
vers=2 |
|
781 |
else |
|
782 |
vers=`echo $1 | sed -e 's/@//'` |
|
783 |
vers=`expr $vers + 1` |
|
784 |
fi |
|
785 |
||
786 |
cmd redefine $pkgDot$classname $tmpFileDir/vers$vers/$classname.class |
|
787 |
||
788 |
cp $tmpFileDir/$classname.java.$vers \ |
|
789 |
$tmpFileDir/$classname.java |
|
790 |
} |
|
791 |
||
792 |
mydojdbCmds() |
|
793 |
{ |
|
794 |
# Wait for jdb to start before we start sending cmds |
|
795 |
waitForJdbMsg ']' 1 |
|
796 |
dojdbCmds |
|
797 |
cmd quit |
|
798 |
} |
|
799 |
||
800 |
startJdb() |
|
801 |
{ |
|
802 |
if [ ! -r "$jdb" -a ! -r "$jdb.exe" ] ; then |
|
803 |
dofail "$jdb does not exist" |
|
804 |
fi |
|
805 |
echo |
|
806 |
echo "--Starting jdb, address=$address" |
|
807 |
if [ -z "$address" ] ; then |
|
808 |
# Let jdb choose the port and write it to stdout |
|
809 |
mydojdbCmds | $jdb $jdbOptions -listenany | tee $jdbOutFile & |
|
810 |
||
811 |
while [ 1 ] ; do |
|
812 |
lastLine=`$grep 'Listening at address' $jdbOutFile` |
|
813 |
if [ ! -z "$lastLine" ] ; then |
|
814 |
break |
|
815 |
fi |
|
816 |
sleep 1 |
|
817 |
done |
|
818 |
# jjh: we got the address ok, and seemed to start the debuggee |
|
819 |
address=`echo $lastLine | sed -e 's@.*: *@@'` |
|
820 |
else |
|
821 |
mydojdbCmds | $jdb $jdbOptions -listen $address | tee $jdbOutFile & |
|
822 |
fi |
|
823 |
#echo address = $address |
|
824 |
||
825 |
||
826 |
# this gets the pid of tee, at least it does on solaris |
|
827 |
jdbpid=$! |
|
828 |
||
829 |
# This fails on linux because there is an entry for each thread in jdb |
|
830 |
# so we get a list of numbers in jdbpid |
|
831 |
# jdbpid=`$psCmd | $grep -v grep | $grep ${orphanKeyword}_JDB | awk '{print $1}' | tr '\n\r' ' '` |
|
832 |
} |
|
833 |
||
834 |
startDebuggee() |
|
835 |
{ |
|
836 |
args= |
|
837 |
# Note that @debuggeeVMOptions is unique to a test run instead of |
|
838 |
# a test in a run. It is not modified during a test run. |
|
839 |
if [ -r $TESTCLASSES/../@debuggeeVMOptions ] ; then |
|
840 |
args=`cat $TESTCLASSES/../@debuggeeVMOptions` |
|
841 |
fi |
|
842 |
||
843 |
if [ ! -z "$args" ] ; then |
|
844 |
echo "--Starting debuggee with args from @debuggeeVMOptions: $args" |
|
845 |
else |
|
846 |
echo "--Starting debuggee" |
|
847 |
fi |
|
848 |
||
849 |
debuggeepid= |
|
850 |
waitForJdbMsg Listening 4 |
|
851 |
||
852 |
beOption="-agentlib:jdwp=transport=$transport,address=$address,server=n,suspend=y" |
|
853 |
# beOption="-Xdebug -Xrunjdwp:transport=$transport,address=$address,server=n,suspend=y" |
|
854 |
||
855 |
thecmd="$jdk/bin/$java $mode -classpath $tmpFileDir $baseArgs $args \ |
|
856 |
-Djtreg.classDir=$TESTCLASSES \ |
|
857 |
-showversion \ |
|
858 |
$beOption \ |
|
859 |
$pkgDot$classname" |
|
860 |
echo "Cmd: $thecmd" |
|
861 |
||
862 |
sh -c "$thecmd | tee $debuggeeOutFile" & |
|
863 |
||
864 |
# Note that the java cmd and the tee cmd will be children of |
|
865 |
# the sh process. We can use that to find them to kill them. |
|
866 |
debuggeepid=$! |
|
867 |
||
868 |
# Save this in a place where the jdb process can find it. |
|
869 |
# Note that it is possible for the java cmd to abort during startup |
|
870 |
# due to a bad classpath or whatever. |
|
871 |
echo $debuggeepid > $debuggeepidFile |
|
872 |
} |
|
873 |
||
874 |
dojstack() |
|
875 |
{ |
|
876 |
if [ -r "$jdk/bin/$jstack" ] ; then |
|
877 |
# If jstack exists, so will jps |
|
878 |
# Show stack traces of jdb and debuggee as a possible debugging aid. |
|
879 |
jdbCmd=`$jdk/bin/jps -v | $grep $jdbKeyword` |
|
880 |
realJdbPid=`echo "$jdbCmd" | sed -e 's@ TTY.*@@'` |
|
881 |
if [ ! -z "$realJdbPid" ] ; then |
|
882 |
echo "-- jdb process info ----------------------" >&2 |
|
883 |
echo " $jdbCmd" >&2 |
|
884 |
echo "-- jdb threads: jstack $realJdbPid" >&2 |
|
885 |
$jdk/bin/$jstack $realJdbPid >&2 |
|
886 |
echo "------------------------------------------" >&2 |
|
887 |
echo >&2 |
|
888 |
fi |
|
889 |
debuggeeCmd=`$jdk/bin/jps -v | $grep $debuggeeKeyword` |
|
890 |
realDebuggeePid=`echo "$debuggeeCmd" | sed -e 's@ .*@@'` |
|
891 |
if [ ! -z "$realDebuggeePid" ] ; then |
|
892 |
if [ -r "$jdk/lib/sa-jdi.jar" ] ; then |
|
893 |
# disableVersionCheck can be removed after 6475822 |
|
894 |
# is fixed. |
|
895 |
moption="-m -J-Dsun.jvm.hotspot.runtime.VM.disableVersionCheck" |
|
896 |
else |
|
897 |
moption= |
|
898 |
fi |
|
899 |
||
900 |
echo "-- debuggee process info ----------------------" >&2 |
|
901 |
echo " $debuggeeCmd" >&2 |
|
902 |
echo "-- debuggee threads: jstack $moption $realDebuggeePid" >&2 |
|
903 |
$jdk/bin/$jstack $moption $realDebuggeePid >&2 |
|
904 |
echo "=============================================" >&2 |
|
905 |
echo >&2 |
|
906 |
fi |
|
907 |
fi |
|
908 |
} |
|
909 |
||
910 |
waitForFinish() |
|
911 |
{ |
|
912 |
# This is the main process |
|
913 |
# Wait for the jdb process to finish, or some error to occur |
|
914 |
||
915 |
while [ 1 = 1 ] ; do |
|
916 |
findPid $jdbpid |
|
917 |
if [ $? != 0 ] ; then |
|
918 |
break |
|
919 |
fi |
|
920 |
if [ ! -z "$isWin98" ] ; then |
|
921 |
$psCmd | $grep -i 'JDB\.EXE' >$devnull 2>&1 |
|
922 |
if [ $? != 0 ] ; then |
|
923 |
break; |
|
924 |
fi |
|
925 |
fi |
|
926 |
$grep -s 'Input stream closed' $jdbOutFile > $devnull 2>&1 |
|
927 |
if [ $? = 0 ] ; then |
|
928 |
#something went wrong |
|
929 |
dofail "jdb input stream closed prematurely" |
|
930 |
fi |
|
931 |
||
932 |
# If a failure has occured, quit |
|
933 |
if [ -r "$failFile" ] ; then |
|
934 |
break |
|
935 |
fi |
|
936 |
||
937 |
sleep ${sleep_seconds} |
|
938 |
done |
|
939 |
||
940 |
if [ -r "$failFile" ] ; then |
|
941 |
exit 1 |
|
942 |
fi |
|
943 |
} |
|
944 |
||
945 |
# $1 is the filename, $2 is the string to look for, |
|
946 |
# $3 is the number of lines to search (from the end) |
|
947 |
grepForString() |
|
948 |
{ |
|
949 |
# See bug 6220903. Sometimes the jdb '> ' prompt chars |
|
950 |
# get inserted into the string we are searching for |
|
951 |
# so ignore those chars. |
|
952 |
if [ -z "$3" ] ; then |
|
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
953 |
theCmd=cat |
2 | 954 |
else |
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
955 |
theCmd="tail -$3" |
2 | 956 |
fi |
4325
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
957 |
case "$2" in |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
958 |
*\>*) |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
959 |
# Target string contains a > so we better |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
960 |
# not ignore it |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
961 |
$theCmd $1 | $grep -s "$2" > $devnull 2>&1 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
962 |
return $? |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
963 |
;; |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
964 |
esac |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
965 |
# Target string does not contain a >. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
966 |
# Ignore > and '> ' in the file. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
967 |
# NOTE: if $1 does not end with a new line, piping it to sed doesn't include the |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
968 |
# chars on the last line. Detect this case, and add a new line. |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
969 |
cp $1 $1.tmp |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
970 |
if [ `tail -1 $1.tmp | wc -l | sed -e 's@ @@g'` = 0 ] ; then |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
971 |
echo >> $1.tmp |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
972 |
fi |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
973 |
$theCmd $1.tmp | sed -e 's@> @@g' -e 's@>@@g' | $grep -s "$2" > $devnull 2>&1 |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
974 |
stat=$? |
38a035021ba1
6903102: 3/3 fixes in nightly testing version of ShellScaffold.sh need to be committed
dcubed
parents:
4153
diff
changeset
|
975 |
rm -f $1.tmp |
2 | 976 |
return $stat |
977 |
} |
|
978 |
||
979 |
# $1 is the filename, $2 is the string to look for, |
|
980 |
# $3 is the number of lines to search (from the end) |
|
981 |
failIfPresent() |
|
982 |
{ |
|
983 |
if [ -r "$1" ] ; then |
|
984 |
grepForString "$1" "$2" "$3" |
|
985 |
if [ $? = 0 ] ; then |
|
986 |
dofail "Error output found: \"$2\" in $1" $1 |
|
987 |
fi |
|
988 |
fi |
|
989 |
} |
|
990 |
||
991 |
# $1 is the filename, $2 is the string to look for |
|
992 |
# $3 is the number of lines to search (from the end) |
|
993 |
failIfNotPresent() |
|
994 |
{ |
|
995 |
if [ ! -r "$1" ] ; then |
|
996 |
dofail "Required output \"$2\" not found in $1" |
|
997 |
fi |
|
998 |
grepForString "$1" "$2" "$3" |
|
999 |
if [ $? != 0 ] ; then |
|
1000 |
dofail "Required output \"$2\" not found in $1" $1 |
|
1001 |
fi |
|
1002 |
||
1003 |
} |
|
1004 |
||
1005 |
# fail if $1 is not in the jdb output |
|
1006 |
# $2 is the number of lines to search (from the end) |
|
1007 |
jdbFailIfNotPresent() |
|
1008 |
{ |
|
1009 |
failIfNotPresent $jdbOutFile "$1" $2 |
|
1010 |
} |
|
1011 |
||
1012 |
# fail if $1 is not in the debuggee output |
|
1013 |
# $2 is the number of lines to search (from the end) |
|
1014 |
debuggeeFailIfNotPresent() |
|
1015 |
{ |
|
1016 |
failIfNotPresent $debuggeeOutFile "$1" $2 |
|
1017 |
} |
|
1018 |
||
1019 |
# fail if $1 is in the jdb output |
|
1020 |
# $2 is the number of lines to search (from the end) |
|
1021 |
jdbFailIfPresent() |
|
1022 |
{ |
|
1023 |
failIfPresent $jdbOutFile "$1" $2 |
|
1024 |
} |
|
1025 |
||
1026 |
# fail if $1 is in the debuggee output |
|
1027 |
# $2 is the number of lines to search (from the end) |
|
1028 |
debuggeeFailIfPresent() |
|
1029 |
{ |
|
1030 |
failIfPresent $debuggeeOutFile "$1" $2 |
|
1031 |
} |
|
1032 |
||
1033 |
# This should really be named 'done' instead of pass. |
|
1034 |
pass() |
|
1035 |
{ |
|
1036 |
if [ ! -r "$failFile" ] ; then |
|
1037 |
echo |
|
1038 |
echo "--Done: test passed" |
|
1039 |
exit 0 |
|
1040 |
fi |
|
1041 |
} |
|
1042 |
||
1043 |
runit() |
|
1044 |
{ |
|
1045 |
setup |
|
1046 |
runitAfterSetup |
|
1047 |
} |
|
1048 |
||
1049 |
runitAfterSetup() |
|
1050 |
{ |
|
1051 |
docompile |
|
1052 |
startJdb |
|
1053 |
startDebuggee |
|
1054 |
waitForFinish |
|
1055 |
||
1056 |
# in hs_err file from 1.3.1 |
|
1057 |
debuggeeFailIfPresent "Virtual Machine Error" |
|
1058 |
||
1059 |
# in hs_err file from 1.4.2, 1.5: An unexpected error |
|
1060 |
debuggeeFailIfPresent "An unexpected error" |
|
1061 |
||
1062 |
# in hs_err file from 1.4.2, 1.5: Internal error |
|
1063 |
debuggeeFailIfPresent "Internal error" |
|
1064 |
||
1065 |
||
1066 |
# Don't know how this arises |
|
1067 |
debuggeeFailIfPresent "An unexpected exception" |
|
1068 |
||
1069 |
# Don't know how this arises |
|
1070 |
debuggeeFailIfPresent "Internal exception" |
|
1071 |
} |
|
1072 |
||
1073 |