53 54 OS=`uname -s` 55 56 case "$OS" in 57 Windows*) 58 PS=";" 59 OS="Windows" 60 ;; 61 CYGWIN*) 62 PS=";" 63 OS="CYGWIN" 64 ;; 65 * ) 66 PS=":" 67 ;; 68 esac 69 70 startDebuggee() 71 { 72 OUTPUTFILE=${TESTCLASSES}/Debuggee.out 73 ${JAVA} "$@" > ${OUTPUTFILE} & 74 startpid="$!" 75 pid="${startpid}" 76 77 # CYGWIN startpid is not the native windows PID we want, get the WINPID 78 if [ "${OS}" = "CYGWIN" ]; then 79 sleep 2 80 ps -l -p ${startpid} 81 pid=`ps -l -p ${startpid} | tail -1 | awk '{print $4;}'` 82 fi 83 84 # MKS creates an intermediate shell to launch ${JAVA} so 85 # ${startpid} is not the actual pid. We have put in a small sleep 86 # to give the intermediate shell process time to launch the 87 # "java" process. 88 if [ "$OS" = "Windows" ]; then 89 sleep 2 90 pid=`ps -o pid,ppid,comm|grep ${startpid}|grep "java"|cut -c1-6` 91 fi 92 93 echo "Waiting for Debuggee to initialize..." 94 attempts=0 95 while true; do 96 sleep 1 97 out=`tail -1 ${OUTPUTFILE}` 98 if [ ! -z "$out" ]; then 99 break 100 fi 101 attempts=`expr $attempts + 1` 102 echo "Waiting $attempts second(s) ..." 103 done 104 105 echo "Debuggee is process $pid (startpid=${startpid})" 106 } 107 108 stopDebuggee() 109 { 110 $JAVA -classpath "${TESTCLASSES}" ShutdownDebuggee $1 111 if [ $? != 0 ] ; then 112 echo "Error: ShutdownDebuggee failed" 113 failures=`expr $failures + 1` 114 kill -9 ${startpid} 115 fi 116 } 117 118 failures=0 119 120 ######################################################### 121 echo "Test 1: Debuggee start with suspend=n" 122 123 PORTFILE="${TESTCLASSES}"/shutdown1.port 124 125 DEBUGGEEFLAGS= 126 if [ -r $TESTCLASSES/@debuggeeVMOptions ] ; then 127 DEBUGGEEFLAGS=`cat $TESTCLASSES/@debuggeeVMOptions` 128 elif [ -r $TESTCLASSES/../@debuggeeVMOptions ] ; then 129 DEBUGGEEFLAGS=`cat $TESTCLASSES/../@debuggeeVMOptions` 130 fi 131 132 startDebuggee \ 133 $DEBUGGEEFLAGS \ 134 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n \ 135 -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" 136 137 $JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ 138 ProcessAttachDebugger $pid 2>&1 139 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 140 141 # Note that when the debugger disconnects, the debuggee picks another 142 # port and outputs another 'Listening for transport ... ' msg. 143 144 stopDebuggee "${PORTFILE}" 145 146 ######################################################### 147 echo "\nTest 2: Debuggee start with suspend=y" 148 149 PORTFILE="${TESTCLASSES}"/shutdown2.port 150 startDebuggee \ 151 $DEBUGGEEFLAGS \ 152 -agentlib:jdwp=transport=dt_socket,server=y,suspend=y \ 153 -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" 154 155 $JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ 156 ProcessAttachDebugger $pid 2>&1 157 158 # The debuggee is suspended and doesn't run until the debugger 159 # disconnects. We have to give it time to write the port number 160 # to ${PORTFILE} 161 162 echo "Waiting for port file to be written..." 163 attempts=0 164 while true; do 165 sleep 1 166 attempts=`expr $attempts + 1` 167 if [ -f ${PORTFILE} ]; then 168 break 169 fi 170 echo "Waiting $attempts second(s) ..." 171 done 172 173 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 174 stopDebuggee "${PORTFILE}" 175 | 53 54 OS=`uname -s` 55 56 case "$OS" in 57 Windows*) 58 PS=";" 59 OS="Windows" 60 ;; 61 CYGWIN*) 62 PS=";" 63 OS="CYGWIN" 64 ;; 65 * ) 66 PS=":" 67 ;; 68 esac 69 70 startDebuggee() 71 { 72 OUTPUTFILE=${TESTCLASSES}/Debuggee.out 73 ${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} "$@" > ${OUTPUTFILE} & 74 startpid="$!" 75 pid="${startpid}" 76 77 # CYGWIN startpid is not the native windows PID we want, get the WINPID 78 if [ "${OS}" = "CYGWIN" ]; then 79 sleep 2 80 ps -l -p ${startpid} 81 pid=`ps -l -p ${startpid} | tail -1 | awk '{print $4;}'` 82 fi 83 84 # MKS creates an intermediate shell to launch ${JAVA} so 85 # ${startpid} is not the actual pid. We have put in a small sleep 86 # to give the intermediate shell process time to launch the 87 # "java" process. 88 if [ "$OS" = "Windows" ]; then 89 sleep 2 90 pid=`ps -o pid,ppid,comm|grep ${startpid}|grep "java"|cut -c1-6` 91 fi 92 93 echo "Waiting for Debuggee to initialize..." 94 attempts=0 95 while true; do 96 sleep 1 97 out=`tail -1 ${OUTPUTFILE}` 98 if [ ! -z "$out" ]; then 99 break 100 fi 101 attempts=`expr $attempts + 1` 102 echo "Waiting $attempts second(s) ..." 103 done 104 105 echo "Debuggee is process $pid (startpid=${startpid})" 106 } 107 108 stopDebuggee() 109 { 110 $JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath "${TESTCLASSES}" ShutdownDebuggee $1 111 if [ $? != 0 ] ; then 112 echo "Error: ShutdownDebuggee failed" 113 failures=`expr $failures + 1` 114 kill -9 ${startpid} 115 fi 116 } 117 118 failures=0 119 120 ######################################################### 121 echo "Test 1: Debuggee start with suspend=n" 122 123 PORTFILE="${TESTCLASSES}"/shutdown1.port 124 125 DEBUGGEEFLAGS= 126 if [ -r $TESTCLASSES/@debuggeeVMOptions ] ; then 127 DEBUGGEEFLAGS=`cat $TESTCLASSES/@debuggeeVMOptions` 128 elif [ -r $TESTCLASSES/../@debuggeeVMOptions ] ; then 129 DEBUGGEEFLAGS=`cat $TESTCLASSES/../@debuggeeVMOptions` 130 fi 131 132 startDebuggee \ 133 $DEBUGGEEFLAGS \ 134 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n \ 135 -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" 136 137 $JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ 138 ProcessAttachDebugger $pid 2>&1 139 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 140 141 # Note that when the debugger disconnects, the debuggee picks another 142 # port and outputs another 'Listening for transport ... ' msg. 143 144 stopDebuggee "${PORTFILE}" 145 146 ######################################################### 147 echo "\nTest 2: Debuggee start with suspend=y" 148 149 PORTFILE="${TESTCLASSES}"/shutdown2.port 150 startDebuggee \ 151 $DEBUGGEEFLAGS \ 152 -agentlib:jdwp=transport=dt_socket,server=y,suspend=y \ 153 -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" 154 155 $JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ 156 ProcessAttachDebugger $pid 2>&1 157 158 # The debuggee is suspended and doesn't run until the debugger 159 # disconnects. We have to give it time to write the port number 160 # to ${PORTFILE} 161 162 echo "Waiting for port file to be written..." 163 attempts=0 164 while true; do 165 sleep 1 166 attempts=`expr $attempts + 1` 167 if [ -f ${PORTFILE} ]; then 168 break 169 fi 170 echo "Waiting $attempts second(s) ..." 171 done 172 173 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi 174 stopDebuggee "${PORTFILE}" 175 |