test/com/sun/jdi/ProcessAttachTest.sh

Print this page

        

*** 52,84 **** JAVA="${TESTJAVA}/bin/java" OS=`uname -s` case "$OS" in ! Windows* | CYGWIN_NT*) PS=";" OS="Windows" ;; * ) PS=":" ;; esac startDebuggee() { OUTPUTFILE=${TESTCLASSES}/Debuggee.out ${JAVA} "$@" > ${OUTPUTFILE} & ! pid="$!" # MKS creates an intermediate shell to launch ${JAVA} so ! # ${pid} is not the actual pid. We have put in a small sleep # to give the intermediate shell process time to launch the # "java" process. if [ "$OS" = "Windows" ]; then sleep 2 ! realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6` ! pid=${realpid} fi echo "Waiting for Debuggee to initialize..." attempts=0 while true; do --- 52,95 ---- JAVA="${TESTJAVA}/bin/java" OS=`uname -s` case "$OS" in ! Windows*) PS=";" OS="Windows" ;; + CYGWIN*) + PS=";" + OS="CYGWIN" + ;; * ) PS=":" ;; esac startDebuggee() { OUTPUTFILE=${TESTCLASSES}/Debuggee.out ${JAVA} "$@" > ${OUTPUTFILE} & ! startpid="$!" ! pid="${startpid}" + # CYGWIN startpid is not the native windows PID we want, get the WINPID + if [ "${OS}" = "CYGWIN" ]; then + sleep 2 + ps -l -p ${startpid} + pid=`ps -l -p ${startpid} | tail -1 | awk '{print $4;}'` + fi + # MKS creates an intermediate shell to launch ${JAVA} so ! # ${startpid} is not the actual pid. We have put in a small sleep # to give the intermediate shell process time to launch the # "java" process. if [ "$OS" = "Windows" ]; then sleep 2 ! pid=`ps -o pid,ppid,comm|grep ${startpid}|grep "java"|cut -c1-6` fi echo "Waiting for Debuggee to initialize..." attempts=0 while true; do
*** 89,108 **** fi attempts=`expr $attempts + 1` echo "Waiting $attempts second(s) ..." done ! echo "Debuggee is process $pid" } stopDebuggee() { $JAVA -classpath "${TESTCLASSES}" ShutdownDebuggee $1 if [ $? != 0 ] ; then echo "Error: ShutdownDebuggee failed" failures=`expr $failures + 1` ! kill -9 $pid fi } failures=0 --- 100,119 ---- fi attempts=`expr $attempts + 1` echo "Waiting $attempts second(s) ..." done ! echo "Debuggee is process $pid (startpid=${startpid})" } stopDebuggee() { $JAVA -classpath "${TESTCLASSES}" ShutdownDebuggee $1 if [ $? != 0 ] ; then echo "Error: ShutdownDebuggee failed" failures=`expr $failures + 1` ! kill -9 ${startpid} fi } failures=0
*** 121,131 **** startDebuggee \ $DEBUGGEEFLAGS \ -agentlib:jdwp=transport=dt_socket,server=y,suspend=n \ -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" ! $JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \ ProcessAttachDebugger $pid 2>&1 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi # Note that when the debugger disconnects, the debuggee picks another # port and outputs another 'Listening for transport ... ' msg. --- 132,142 ---- startDebuggee \ $DEBUGGEEFLAGS \ -agentlib:jdwp=transport=dt_socket,server=y,suspend=n \ -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" ! $JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ ProcessAttachDebugger $pid 2>&1 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi # Note that when the debugger disconnects, the debuggee picks another # port and outputs another 'Listening for transport ... ' msg.
*** 139,149 **** startDebuggee \ $DEBUGGEEFLAGS \ -agentlib:jdwp=transport=dt_socket,server=y,suspend=y \ -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" ! $JAVA -classpath ${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar \ ProcessAttachDebugger $pid 2>&1 # The debuggee is suspended and doesn't run until the debugger # disconnects. We have to give it time to write the port number # to ${PORTFILE} --- 150,160 ---- startDebuggee \ $DEBUGGEEFLAGS \ -agentlib:jdwp=transport=dt_socket,server=y,suspend=y \ -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" ! $JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ ProcessAttachDebugger $pid 2>&1 # The debuggee is suspended and doesn't run until the debugger # disconnects. We have to give it time to write the port number # to ${PORTFILE}