Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/com/sun/jdi/DeferredStepTest.sh
38855 views
#!/bin/sh12#3# Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.5#6# This code is free software; you can redistribute it and/or modify it7# under the terms of the GNU General Public License version 2 only, as8# published by the Free Software Foundation.9#10# This code is distributed in the hope that it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13# version 2 for more details (a copy is included in the LICENSE file that14# accompanied this code).15#16# You should have received a copy of the GNU General Public License version17# 2 along with this work; if not, write to the Free Software Foundation,18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19#20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21# or visit www.oracle.com if you need additional information or have any22# questions.23#2425# @ test26# This is a manual test. The script isn't smart enough27# to detect the correct ordering of the output since it28# is produced by multiple threads and can be interleaved29# in many different ways.30#31# @bug 462954832# @summary Deferred StepRequests are lost in multithreaded debuggee33# @author Jim Holmlund34#35# @run shell/manual DeferredStepTest.sh3637# Run this script to see the bug. See comments at the end38# of the .java file for info on what the bug looks like.3940# These are variables that can be set to control execution4142#pkg=untitled743classname=DeferredStepTest44#compileOptions=-g45#java=java_g46#mode=-Xcomp4748createJavaFile()49{50cat <<EOF > $classname.java.151public class $classname {52static class jj1 implements Runnable {53public void run() {54int count = 0;5556for ( int ii = 0; ii < 10; ii++) { // line 657int intInPotato04 = 666; // line 758++count; // line 8; @1 breakpoint59System.out.println("Thread: " + Thread.currentThread().getName()); // line 960}61}62}6364static class jj2 implements Runnable {65public void run() {66int count2 = 0;6768for (int ii = 0; ii < 10; ii++) { // line 1869String StringInPotato05 = "I am"; // line 1970++count2; // line 20; @1 breakpoint71System.out.println("Thread: " + Thread.currentThread().getName()); // line 2172}73}74}7576public static void main(String argv[]) {77System.out.println("Version = " + System.getProperty("java.version"));7879jj1 aRP = new jj1();80jj2 asRP = new jj2();81new Thread(aRP, "jj1 *").start();82new Thread(asRP, "jj2 **").start();83// new Thread(aRP, "jj3 ***").start();84// new Thread(asRP, "jj4 ****").start();85}86}8788/****************************89To see this bug, do this9091jdb DeferredStep92stop at DeferredStepTest$jj1:893stop at DeferredStepTest$jj2:2094run95next96next97:9899********/100101EOF102}103104#sleepcmd="sleep 2"105106# This is called to feed cmds to jdb.107dojdbCmds()108{109#set -x110# We can't use setBkpts because it can only set bkpts in one class :-(111#setBkpts @1112cmd stop at $classname'$jj1:8'113cmd stop at $classname'$jj2:20'114#cmd run; $sleepcmd115runToBkpt @1116cmd next; $sleepcmd117cmd next; $sleepcmd118cmd next; $sleepcmd119cmd next; $sleepcmd120cmd next; $sleepcmd121cmd next; $sleepcmd122cmd next; $sleepcmd123cmd next; $sleepcmd124cmd next; $sleepcmd125cmd next; $sleepcmd126cmd next; $sleepcmd127cmd next; $sleepcmd128cmd next; $sleepcmd129cmd next; $sleepcmd130cmd next; $sleepcmd131cmd quit132}133134mysetup()135{136if [ -z "$TESTSRC" ] ; then137TESTSRC=.138fi139140for ii in . $TESTSRC $TESTSRC/.. ; do141if [ -r "$ii/ShellScaffold.sh" ] ; then142. $ii/ShellScaffold.sh143break144fi145done146}147148149# You could replace this next line with the contents150# of ShellScaffold.sh and this script will run just the same.151mysetup152153cat <<EOF154****************************************************************155This test should be run and checked manually.156157If this works right, you should see StepEvents/Breakpoint events for lines1588, 9, 6, 7, 8, 9, 6, .... for thread jj11159and16020, 21, 18, 19, 20, 21, 18, ... for thread jj2161162Since both threads are running at the same time, these163events can be intermixed.164165The bug is that you will frequently see step events missing.166EG, you will see1678, 9, 8168or16920, 21, 20, 21170etc171172============================================================173At some point you might get the msg 'Nothing suspended'174This is bug:1754619349 Step Over fails in a multi threaded debuggee176177Kill the test and rerun it if this happens.178****************************************************************179180EOF181runit182#jdbFailIfPresent "Nothing suspended"183#pass184185186