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