I'll need a sponsor for the patch attached.
On 8/6/18, 7:16 AM, Gary Adams wrote:
On 8/3/18, 6:38 PM, Chris Plummer wrote:
Hi Gary,
Overall it looks good.
Is the EventHandler.isDisconnected() check needed?
This just follows the pattern used in other calls to setValue.
No point in attempting the operation, if you know the
connection was lost. An exception at this point could
be misleading, if some other error has already occurred.
In resume008a.java you removed a lot of empty lines. In some places
it's fine, but the lines at 132 and 134 should have remained. Also,
for the ones that were ok to remove, I don't see you doing the same
thing in the other files. I think probably it's best to be
consistent, and for this webrev probably best not to do them since it
distracts too much from the important changes.
The original bug was reported against resume008, so more time was
spent in that
particular test, including some line wrapping changes. I will restore
the blank lines
you mentioned before producing a final patch. The other tests had
observed failures
also during testing. Applying the same change fixed those failures as
well.
Seems like there is a lot of abstraction that could have been done
with these tests to share a lot of code, but since so far that hasn't
been done, probably not a good idea to start doing that with this
fix. Do you think it's worth filing an enhancement request for?
Reformatting or refactoring these older tests would be at best a P5.
I don't think it's worth filing a bug, but as we fix bugs in these
test it's
worth some minimal amount of cleanup while we are in the code.
thanks,
Chris
On 8/3/18 11:04 AM, Gary Adams wrote:
Here is an updated webrev with the alternate solution implemented for
resume 1 to 10. The debugger sets testCase variable in the debuggee
when each test case completes in the debugger. By having the debuggee
wait for the debugger to complete with test case 0, it avoids the
interference
that occurs by proceeding to the breakpoint set in
MethodForCommunication
before the debugger has compared expected suspend counts.
Webrev:
http://cr.openjdk.java.net/~gadams/8170089/webrev.01/index.html
On 7/17/18, 11:33 AM, Gary Adams wrote:
A race condition exists between the debugger and the debuggee.
The first test thread is started with SUSPEND_NONE policy set.
While processing the thread start event the debugger captures
an initial set of thread suspend counts and resumes the
debuggee vm. If the debuggee advances quickly it reaches
the breakpoint set for methodForCommunication. Since the breakpoint
carries with it SUSPEND_ALL policy, when the debugger captures a
second
set of suspend counts, it will not match the expected counts for
a SUSPEND_NONE scenario.
The proposed fix introduces a yield in the debuggee test thread run
method
to allow the debugger to get the expected sampled values.
Issue: https://bugs.openjdk.java.net/browse/JDK-8170089
Webrev: http://cr.openjdk.java.net/~gadams/8170089/webrev.00/
test/hotspot/jtreg/vmTestbase/nsk/share/jdi/TestDebuggerType1.java:
...
186 private void setCommunicationBreakpoint(ReferenceType
refType, String methodName) {
187 Method method = debuggee.methodByName(refType,
methodName);
188 Location location = null;
189 try {
190 location = method.allLineLocations().get(0);
191 } catch (AbsentInformationException e) {
192 throw new Failure(e);
193 }
194 bpRequest = debuggee.makeBreakpoint(location);
195
196 bpRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
197 bpRequest.putProperty("number", "zero");
198 bpRequest.enable();
199
200 eventHandler.addListener(
201 new EventHandler.EventListener() {
202 public boolean eventReceived(Event event) {
203 if (event instanceof BreakpointEvent
&& bpRequest.equals(event.request())) {
204 synchronized(eventHandler) {
205 display("Received
communication breakpoint event.");
206 bpCount++;
207 eventHandler.notifyAll();
208 }
209 return true;
210 }
211 return false;
212 }
213 }
214 );
215 }
test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java:
...
140 display("......--> vm.suspend();");
141 vm.suspend();
142
143 display(" getting : Map<String,
Integer> suspendsCounts1");
144
145 Map<String, Integer> suspendsCounts1 =
new HashMap<String, Integer>();
146 for (ThreadReference threadReference :
vm.allThreads()) {
147 suspendsCounts1.put(threadReference.name(),
threadReference.suspendCount());
148 }
149 display(suspendsCounts1.toString());
150
151 display(" eventSet.resume;");
152 eventSet.resume();
153
154 display(" getting : Map<String,
Integer> suspendsCounts2");
This is where the breakpoint is encountered before the second set
of suspend counts is acquired.
155 Map<String, Integer> suspendsCounts2 =
new HashMap<String, Integer>();
156 for (ThreadReference threadReference :
vm.allThreads()) {
157 suspendsCounts2.put(threadReference.name(),
threadReference.suspendCount());
158 }
159 display(suspendsCounts2.toString());
# HG changeset patch
# User gadams
# Date 1533556609 14400
# Mon Aug 06 07:56:49 2018 -0400
# Node ID acef9fd4cdf33c47fea23c6086cc03698eb37723
# Parent c00451b6785425c3f3000afc15e7b91a3573e70a
8170089: nsk/jdi/EventSet/resume/resume008: ERROR: suspendCounts don't match
for : Common-Cleaner
Reviewed-by: cjplummer, sspitsyn
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001.java
@@ -50,9 +50,9 @@
* To check up on the method, a debugger,
* upon getting new set for ClassPrepareEvent,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -63,6 +63,13 @@
* making special clases loaded and prepared to create the Events
* - Upon getting the Events,
* the debugger performs the check required.
+ * - The debugger informs the debuggee when it completes
+ * each test case, so it will wait before hitting
+ * communication breakpoints.
+ * This prevents the breakpoint SUSPEND_ALL policy
+ * disrupting the first test case check for
+ * SUSPEND_NONE, if the debuggee gets ahead of
+ * the debugger processing.
*/
public class resume001 extends TestDebuggerType1 {
@@ -233,6 +240,7 @@
default: throw new Failure("** default case 1 **");
}
+ informDebuggeeTestCase(i);
}
display("......--> vm.resume()");
@@ -261,5 +269,24 @@
throw new Failure("** FAILURE to set up ClassPrepareRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume001a.java
@@ -33,7 +33,7 @@
public class resume001a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
@@ -57,6 +57,7 @@
static int exitCode = PASSED;
+ static int testCase = -1;
static int instruction = 1;
static int end = 0;
// static int quit = 0;
@@ -100,6 +101,10 @@
case 0:
TestClass2 obj2 = new TestClass2();
+ // Wait for debugger to complete the first test case
+ // before advancing to the first breakpoint
+ waitForTestCase(0);
+
break;
case 1:
@@ -119,6 +124,16 @@
log1("debuggee exits");
System.exit(exitCode + PASS_BASE);
}
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
}
class TestClass2 {
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java
@@ -48,9 +48,9 @@
* To check up on the method, a debugger, <BR>
* upon getting new set for the EventSet, <BR>
* suspends VM with the method VirtualMachine.suspend(), <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
* invokes the method EventSet.resume(), and <BR>
- * gets another List of geduggee's threads. <BR>
+ * gets another List of debuggee's threads. <BR>
* The debugger then compares values of <BR>
* each thread's suspendCount from first and second Lists. <BR>
* <BR>
@@ -87,12 +87,12 @@
public class resume002 {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
static final int PASS_BASE = 95;
- //----------------------------------------------------- templete parameters
+ //----------------------------------------------------- template parameters
static final String
sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume002 ",
sHeader2 = "--> debugger: ",
@@ -503,6 +503,7 @@
log2("......--> vm.resume()");
vm.resume();
+ informDebuggeeTestCase(i);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
log1(" TESTING ENDS");
@@ -642,5 +643,24 @@
throw new JDITestRuntimeException("** FAILURE to set up
AccessWatchpointRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002a.java
@@ -33,7 +33,7 @@
public class resume002a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
@@ -41,6 +41,7 @@
static ArgumentHandler argHandler;
static Log log;
+ static int testCase = -1;
//-------------------------------------------------- log procedures
@@ -98,8 +99,12 @@
//------------------------------------------------------ section tested
- case 0: resume002aTestClass.method();
- break;
+ case 0:
+ resume002aTestClass.method();
+ // Wait for debugger to complete the first test case
+ // before advancing to the first breakpoint
+ waitForTestCase(0);
+ break;
case 1: resume002aTestClass.method();
break;
@@ -118,6 +123,17 @@
log1("debuggee exits");
System.exit(exitCode + PASS_BASE);
}
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
+
}
class resume002aTestClass {
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java
@@ -48,9 +48,9 @@
* To check up on the method, a debugger, <BR>
* upon getting new set for the EventSet, <BR>
* suspends VM with the method VirtualMachine.suspend(), <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
* invokes the method EventSet.resume(), and <BR>
- * gets another List of geduggee's threads. <BR>
+ * gets another List of debuggee's threads. <BR>
* The debugger then compares values of <BR>
* each thread's suspendCount from first and second Lists. <BR>
* <BR>
@@ -87,12 +87,12 @@
public class resume003 {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
static final int PASS_BASE = 95;
- //----------------------------------------------------- templete parameters
+ //----------------------------------------------------- template parameters
static final String
sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume003 ",
sHeader2 = "--> debugger: ",
@@ -503,6 +503,8 @@
log2("......--> vm.resume()");
vm.resume();
+ informDebuggeeTestCase(i);
+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
log1(" TESTING ENDS");
@@ -642,5 +644,24 @@
throw new JDITestRuntimeException("** FAILURE to set up
ModificationWatchpointRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003a.java
@@ -33,7 +33,8 @@
public class resume003a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
+ static int testCase = -1;
static final int PASSED = 0;
static final int FAILED = 2;
@@ -98,8 +99,12 @@
//------------------------------------------------------ section tested
- case 0: resume003aTestClass.method();
- break;
+ case 0:
+ resume003aTestClass.method();
+ // Wait for debugger to complete the first test case
+ // before advancing to the first breakpoint
+ waitForTestCase(0);
+ break;
case 1: resume003aTestClass.method();
break;
@@ -118,6 +123,16 @@
log1("debuggee exits");
System.exit(exitCode + PASS_BASE);
}
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
}
class resume003aTestClass {
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java
@@ -48,9 +48,9 @@
* To check up on the method, a debugger, <BR>
* upon getting new set for the EventSet, <BR>
* suspends VM with the method VirtualMachine.suspend(), <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
* invokes the method EventSet.resume(), and <BR>
- * gets another List of geduggee's threads. <BR>
+ * gets another List of debuggee's threads. <BR>
* The debugger then compares values of <BR>
* each thread's suspendCount from first and second Lists. <BR>
* <BR>
@@ -87,12 +87,12 @@
public class resume004 {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
static final int PASS_BASE = 95;
- //----------------------------------------------------- templete parameters
+ //----------------------------------------------------- template parameters
static final String
sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume004 ",
sHeader2 = "--> debugger: ",
@@ -493,6 +493,7 @@
default: throw new JDITestRuntimeException("** default case
1 **");
}
+ informDebuggeeTestCase(i);
}
log2("......--> vm.resume()");
@@ -638,5 +639,24 @@
throw new JDITestRuntimeException("** FAILURE to set up
BreakpointRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004a.java
@@ -33,7 +33,8 @@
public class resume004a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
+ static int testCase = -1;
static final int PASSED = 0;
static final int FAILED = 2;
@@ -98,8 +99,10 @@
//------------------------------------------------------ section tested
- case 0: resume004aTestClass.method();
- break;
+ case 0:
+ resume004aTestClass.method();
+ waitForTestCase(0);
+ break;
case 1: resume004aTestClass.method();
break;
@@ -118,6 +121,16 @@
log1("debuggee exits");
System.exit(exitCode + PASS_BASE);
}
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
}
class resume004aTestClass {
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java
@@ -48,9 +48,9 @@
* To check up on the method, a debugger, <BR>
* upon getting new set for the EventSet, <BR>
* suspends VM with the method VirtualMachine.suspend(), <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
* invokes the method EventSet.resume(), and <BR>
- * gets another List of geduggee's threads. <BR>
+ * gets another List of debuggee's threads. <BR>
* The debugger then compares values of <BR>
* each thread's suspendCount from first and second Lists. <BR>
* <BR>
@@ -87,12 +87,12 @@
public class resume005 {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
static final int PASS_BASE = 95;
- //----------------------------------------------------- templete parameters
+ //----------------------------------------------------- template parameters
static final String
sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume005 ",
sHeader2 = "--> debugger: ",
@@ -493,6 +493,7 @@
default: throw new JDITestRuntimeException("** default case
1 **");
}
+ informDebuggeeTestCase(i);
}
log2("......--> vm.resume()");
@@ -634,5 +635,24 @@
throw new JDITestRuntimeException("** FAILURE to set up
ExceptionRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005a.java
@@ -33,7 +33,8 @@
public class resume005a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
+ static int testCase = -1;
static final int PASSED = 0;
static final int FAILED = 2;
@@ -98,8 +99,10 @@
//------------------------------------------------------ section tested
- case 0: resume005aTestClass.method();
- break;
+ case 0:
+ resume005aTestClass.method();
+ waitForTestCase(0);
+ break;
case 1: resume005aTestClass.method();
break;
@@ -122,7 +125,16 @@
public static void nullMethod() {
throw new NullPointerException("test");
}
-
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
}
class resume005aTestClass {
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java
@@ -48,9 +48,9 @@
* To check up on the method, a debugger, <BR>
* upon getting new set for the EventSet, <BR>
* suspends VM with the method VirtualMachine.suspend(), <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
* invokes the method EventSet.resume(), and <BR>
- * gets another List of geduggee's threads. <BR>
+ * gets another List of debuggee's threads. <BR>
* The debugger then compares values of <BR>
* each thread's suspendCount from first and second Lists. <BR>
* <BR>
@@ -87,12 +87,12 @@
public class resume006 {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
static final int PASS_BASE = 95;
- //----------------------------------------------------- templete parameters
+ //----------------------------------------------------- template parameters
static final String
sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume006 ",
sHeader2 = "--> debugger: ",
@@ -495,6 +495,7 @@
log2("......--> vm.resume()");
vm.resume();
+ informDebuggeeTestCase(i);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}
log1(" TESTING ENDS");
@@ -632,5 +633,24 @@
throw new JDITestRuntimeException("** FAILURE to set up
MethodEntryRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006a.java
@@ -33,7 +33,7 @@
public class resume006a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
@@ -41,6 +41,7 @@
static ArgumentHandler argHandler;
static Log log;
+ static int testCase = -1;
//-------------------------------------------------- log procedures
@@ -98,8 +99,12 @@
//------------------------------------------------------ section tested
- case 0: resume006aTestClass.method();
- break;
+ case 0:
+ resume006aTestClass.method();
+ // Wait for debugger to complete the first test case
+ // before advancing to the next breakpoint
+ waitForTestCase(0);
+ break;
case 1: resume006aTestClass.method();
break;
@@ -118,7 +123,16 @@
log1("debuggee exits");
System.exit(exitCode + PASS_BASE);
}
-
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
}
class resume006aTestClass {
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java
@@ -48,9 +48,9 @@
* To check up on the method, a debugger, <BR>
* upon getting new set for the EventSet, <BR>
* suspends VM with the method VirtualMachine.suspend(), <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
* invokes the method EventSet.resume(), and <BR>
- * gets another List of geduggee's threads. <BR>
+ * gets another List of debuggee's threads. <BR>
* The debugger then compares values of <BR>
* each thread's suspendCount from first and second Lists. <BR>
* <BR>
@@ -87,12 +87,12 @@
public class resume007 {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = Consts.TEST_PASSED;
static final int FAILED = Consts.TEST_FAILED;
static final int PASS_BASE = Consts.JCK_STATUS_BASE;
- //----------------------------------------------------- templete parameters
+ //----------------------------------------------------- template parameters
static final String
sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume007 ",
sHeader2 = "--> debugger: ",
@@ -490,6 +490,7 @@
default: throw new JDITestRuntimeException("** default case
1 **");
}
+ informDebuggeeTestCase(i);
}
log2("......--> vm.resume()");
@@ -631,5 +632,24 @@
throw new JDITestRuntimeException("** FAILURE to set up
MethodExitRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007a.java
@@ -33,7 +33,8 @@
public class resume007a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
+ static int testCase = -1;
static final int PASSED = 0;
static final int FAILED = 2;
@@ -98,8 +99,10 @@
//------------------------------------------------------ section tested
- case 0: resume007aTestClass.method();
- break;
+ case 0:
+ resume007aTestClass.method();
+ waitForTestCase(0);
+ break;
case 1: resume007aTestClass.method();
break;
@@ -118,7 +121,16 @@
log1("debuggee exits");
System.exit(exitCode + PASS_BASE);
}
-
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
}
class resume007aTestClass {
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008.java
@@ -50,9 +50,9 @@
* To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -63,6 +63,13 @@
* to be resulting in the event.
* - Upon getting new event, the debugger
* performs the check corresponding to the event.
+ * - The debugger informs the debuggee when it completes
+ * each test case, so it will wait before hitting
+ * communication breakpoints.
+ * This prevents the breakpoint SUSPEND_ALL policy
+ * disrupting the first test case check for
+ * SUSPEND_NONE, if the debuggee gets ahead of
+ * the debugger processing.
*/
public class resume008 extends TestDebuggerType1 {
@@ -124,7 +131,9 @@
}
display("......waiting for new ThreadStartEvent : " + i);
- EventSet eventSet = eventHandler.waitForRequestedEventSet(new
EventRequest[]{eventRequest}, waitTime, true);
+ EventSet eventSet = eventHandler
+ .waitForRequestedEventSet(new EventRequest[]{eventRequest},
+ waitTime, true);
EventIterator eventIterator = eventSet.eventIterator();
Event newEvent = eventIterator.nextEvent();
@@ -134,7 +143,8 @@
} else {
String property = (String)
newEvent.request().getProperty("number");
- display(" got new ThreadStartEvent with propety 'number'
== " + property);
+ display(" got new ThreadStartEvent with propety 'number'
== "
+ + property);
display("......checking up on EventSet.resume()");
display("......--> vm.suspend();");
@@ -144,7 +154,8 @@
Map<String, Integer> suspendsCounts1 = new HashMap<String,
Integer>();
for (ThreadReference threadReference : vm.allThreads()) {
- suspendsCounts1.put(threadReference.name(),
threadReference.suspendCount());
+ suspendsCounts1.put(threadReference.name(),
+ threadReference.suspendCount());
}
display(suspendsCounts1.toString());
@@ -154,7 +165,8 @@
display(" getting : Map<String, Integer>
suspendsCounts2");
Map<String, Integer> suspendsCounts2 = new HashMap<String,
Integer>();
for (ThreadReference threadReference : vm.allThreads()) {
- suspendsCounts2.put(threadReference.name(),
threadReference.suspendCount());
+ suspendsCounts2.put(threadReference.name(),
+ threadReference.suspendCount());
}
display(suspendsCounts2.toString());
@@ -163,85 +175,90 @@
switch (policy) {
- case SUSPEND_NONE :
- display(" case SUSPEND_NONE");
- for (String threadName : suspendsCounts1.keySet()) {
- display(" checking " + threadName);
- if (!suspendsCounts2.containsKey(threadName)) {
- complain("ERROR: couldn't get ThreadReference
for " + threadName);
- testExitCode = TEST_FAILED;
- break;
- }
- int count1 = suspendsCounts1.get(threadName);
- int count2 = suspendsCounts2.get(threadName);
- if (count1 != count2) {
- complain("ERROR: suspendCounts don't match for
: " + threadName);
- complain("before resuming : " + count1);
- complain("after resuming : " + count2);
- testExitCode = TEST_FAILED;
- break;
- }
- }
- break;
+ case SUSPEND_NONE :
+ display(" case SUSPEND_NONE");
+ for (String threadName : suspendsCounts1.keySet()) {
+ display(" checking " + threadName);
+ if (!suspendsCounts2.containsKey(threadName)) {
+ complain("ERROR: couldn't get ThreadReference for "
+ + threadName);
+ testExitCode = TEST_FAILED;
+ break;
+ }
+ int count1 = suspendsCounts1.get(threadName);
+ int count2 = suspendsCounts2.get(threadName);
+ if (count1 != count2) {
+ complain("ERROR: suspendCounts don't match for : "
+ + threadName);
+ complain("before resuming : " + count1);
+ complain("after resuming : " + count2);
+ testExitCode = TEST_FAILED;
+ break;
+ }
+ }
+ break;
- case SUSPEND_THREAD :
- display(" case SUSPEND_THREAD");
- for (String threadName : suspendsCounts1.keySet()) {
- display("checking " + threadName);
- if (!suspendsCounts2.containsKey(threadName)) {
- complain("ERROR: couldn't get ThreadReference
for " + threadName);
- testExitCode = TEST_FAILED;
- break;
- }
- int count1 = suspendsCounts1.get(threadName);
- int count2 = suspendsCounts2.get(threadName);
- String eventThreadName =
((ThreadStartEvent)newEvent).thread().name();
- int expectedValue = count2 +
(eventThreadName.equals(threadName) ? 1 : 0);
- if (count1 != expectedValue) {
- complain("ERROR: suspendCounts don't match for
: " + threadName);
- complain("before resuming : " + count1);
- complain("after resuming : " + count2);
- testExitCode = TEST_FAILED;
- break;
- }
- }
- break;
+ case SUSPEND_THREAD :
+ display(" case SUSPEND_THREAD");
+ for (String threadName : suspendsCounts1.keySet()) {
+ display("checking " + threadName);
+ if (!suspendsCounts2.containsKey(threadName)) {
+ complain("ERROR: couldn't get ThreadReference for "
+ + threadName);
+ testExitCode = TEST_FAILED;
+ break;
+ }
+ int count1 = suspendsCounts1.get(threadName);
+ int count2 = suspendsCounts2.get(threadName);
+ String eventThreadName = ((ThreadStartEvent)newEvent)
+ .thread().name();
+ int expectedValue = count2 +
+ (eventThreadName.equals(threadName) ? 1 : 0);
+ if (count1 != expectedValue) {
+ complain("ERROR: suspendCounts don't match for : "
+ + threadName);
+ complain("before resuming : " + count1);
+ complain("after resuming : " + count2);
+ testExitCode = TEST_FAILED;
+ break;
+ }
+ }
+ break;
- case SUSPEND_ALL :
+ case SUSPEND_ALL :
+ display(" case SUSPEND_ALL");
+ for (String threadName : suspendsCounts1.keySet()) {
+ display("checking " + threadName);
+ if (!newEvent.request().equals(eventRequest))
+ break;
+ if (!suspendsCounts2.containsKey(threadName)) {
+ complain("ERROR: couldn't get ThreadReference for "
+ + threadName);
+ testExitCode = TEST_FAILED;
+ break;
+ }
+ int count1 = suspendsCounts1.get(threadName);
+ int count2 = suspendsCounts2.get(threadName);
+ if (count1 != count2 + 1) {
+ complain("ERROR: suspendCounts don't match for : "
+ + threadName);
+ complain("before resuming : " + count1);
+ complain("after resuming : " + count2);
+ testExitCode = TEST_FAILED;
+ break;
+ }
+ }
+ break;
+ default: throw new Failure("** default case 1 **");
+ }
+ informDebuggeeTestCase(i);
- display(" case SUSPEND_ALL");
- for (String threadName : suspendsCounts1.keySet()) {
- display("checking " + threadName);
-
- if (!newEvent.request().equals(eventRequest))
- break;
- if (!suspendsCounts2.containsKey(threadName)) {
- complain("ERROR: couldn't get ThreadReference
for " + threadName);
- testExitCode = TEST_FAILED;
- break;
- }
- int count1 = suspendsCounts1.get(threadName);
- int count2 = suspendsCounts2.get(threadName);
- if (count1 != count2 + 1) {
- complain("ERROR: suspendCounts don't match for
: " + threadName);
- complain("before resuming : " + count1);
- complain("after resuming : " + count2);
- testExitCode = TEST_FAILED;
- break;
- }
- }
- break;
-
- default: throw new Failure("** default case 1 **");
- }
}
-
display("......--> vm.resume()");
vm.resume();
}
return;
}
-
private ThreadStartRequest settingThreadStartRequest(int suspendPolicy,
String property) {
try {
@@ -254,5 +271,24 @@
throw new Failure("** FAILURE to set up ThreadStartRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume008a.java
@@ -33,7 +33,7 @@
public class resume008a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
@@ -62,6 +62,7 @@
static int exitCode = PASSED;
+ static int testCase = -1;
static int instruction = 1;
static int end = 0;
// static int quit = 0;
@@ -70,6 +71,7 @@
static int lineForComm = 2;
+ // Debugger sets a breakpoint here to track debuggee
private static void methodForCommunication() {
int i1 = instruction;
int i2 = i1;
@@ -85,47 +87,38 @@
log1("debuggee started!");
label0:
- for (int i = 0; ; i++) {
-
- if (instruction > maxInstr) {
- logErr("ERROR: unexpected instruction: " + instruction);
- exitCode = FAILED;
- break ;
- }
-
- switch (i) {
-
+ for (int i = 0; ; i++) {
+ if (instruction > maxInstr) {
+ logErr("ERROR: unexpected instruction: " + instruction);
+ exitCode = FAILED;
+ break ;
+ }
+ switch (i) {
//------------------------------------------------------ section tested
-
- case 0:
- thread0 = new Threadresume008a("thread0");
- methodForCommunication();
-
- threadStart(thread0);
-
- thread1 = new Threadresume008a("thread1");
- methodForCommunication();
- break;
-
- case 1:
- threadStart(thread1);
-
- thread2 = new Threadresume008a("thread2");
- methodForCommunication();
- break;
-
- case 2:
- threadStart(thread2);
-
- //------------------------------------------------- standard end section
-
- default:
- instruction = end;
- methodForCommunication();
- break label0;
- }
+ case 0:
+ thread0 = new Threadresume008a("thread0");
+ methodForCommunication();
+ threadStart(thread0);
+ thread1 = new Threadresume008a("thread1");
+ // Wait for debugger to complete the first test case
+ // before advancing to the first breakpoint
+ waitForTestCase(0);
+ methodForCommunication();
+ break;
+ case 1:
+ threadStart(thread1);
+ thread2 = new Threadresume008a("thread2");
+ methodForCommunication();
+ break;
+ case 2:
+ threadStart(thread2);
+ //------------------------------------------------- standard
end section
+ default:
+ instruction = end;
+ methodForCommunication();
+ break label0;
}
-
+ }
log1("debuggee exits");
System.exit(exitCode + PASS_BASE);
}
@@ -145,24 +138,29 @@
}
return PASSED;
}
-
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
static class Threadresume008a extends Thread {
-
String tName = null;
-
public Threadresume008a(String threadName) {
super(threadName);
tName = threadName;
}
-
public void run() {
log1(" 'run': enter :: threadName == " + tName);
synchronized (waitnotifyObj) {
- waitnotifyObj.notify();
+ waitnotifyObj.notify();
}
log1(" 'run': exit :: threadName == " + tName);
return;
}
}
-
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009.java
@@ -50,9 +50,9 @@
* To check up on the method, a debugger,
* upon getting new set for the EventSet,
* suspends VM with the method VirtualMachine.suspend(),
- * gets the List of geduggee's threads calling VM.allThreads(),
+ * gets the List of debuggee's threads calling VM.allThreads(),
* invokes the method EventSet.resume(), and
- * gets another List of geduggee's threads.
+ * gets another List of debuggee's threads.
* The debugger then compares values of
* each thread's suspendCount from first and second Lists.
*
@@ -63,6 +63,13 @@
* to be resulting in the event.
* - Upon getting new event, the debugger
* performs the check corresponding to the event.
+ * - The debugger informs the debuggee when it completes
+ * each test case, so it will wait before hitting
+ * communication breakpoints.
+ * This prevents the breakpoint SUSPEND_ALL policy
+ * disrupting the first test case check for
+ * SUSPEND_NONE, if the debuggee gets ahead of
+ * the debugger processing.
*/
public class resume009 extends TestDebuggerType1 {
@@ -233,6 +240,7 @@
default: throw new Failure("** default case 1 **");
}
+ informDebuggeeTestCase(i);
}
display("......--> vm.resume()");
@@ -253,5 +261,24 @@
throw new Failure("** FAILURE to set up ThreadDeathRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume009a.java
@@ -33,7 +33,7 @@
public class resume009a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
@@ -62,6 +62,7 @@
static int exitCode = PASSED;
+ static int testCase = -1;
static int instruction = 1;
static int end = 0;
// static int quit = 0;
@@ -104,6 +105,9 @@
threadRun(thread0);
thread1 = new Threadresume009a("thread1");
+ // Wait for debugger to complete the first test
case
+ // before advancing to the first breakpoint
+ waitForTestCase(0);
methodForCommunication();
break;
@@ -152,6 +156,16 @@
}
return PASSED;
}
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
static class Threadresume009a extends Thread {
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java
@@ -48,9 +48,9 @@
* To check up on the method, a debugger, <BR>
* upon getting new set for the EventSet, <BR>
* suspends VM with the method VirtualMachine.suspend(), <BR>
- * gets the List of geduggee's threads calling VM.allThreads(), <BR>
+ * gets the List of debuggee's threads calling VM.allThreads(), <BR>
* invokes the method EventSet.resume(), and <BR>
- * gets another List of geduggee's threads. <BR>
+ * gets another List of debuggee's threads. <BR>
* The debugger then compares values of <BR>
* each thread's suspendCount from first and second Lists. <BR>
* <BR>
@@ -87,12 +87,12 @@
public class resume010 {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
static final int PASS_BASE = 95;
- //----------------------------------------------------- templete parameters
+ //----------------------------------------------------- template parameters
static final String
sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume010 ",
sHeader2 = "--> debugger: ",
@@ -488,6 +488,7 @@
default:
throw new JDITestRuntimeException("** default case 1
**");
}
+ informDebuggeeTestCase(i);
}
log2("......--> vm.resume()");
@@ -627,5 +628,24 @@
throw new JDITestRuntimeException("** FAILURE to set up
StepRequest **");
}
}
-
+ /**
+ * Inform debuggee which thread test the debugger has completed.
+ * Used for synchronization, so the debuggee does not move too quickly.
+ * @param testCase index of just completed test
+ */
+ void informDebuggeeTestCase(int testCase) {
+ if (!EventHandler.isDisconnected() && debuggeeClass != null) {
+ try {
+ ((ClassType)debuggeeClass)
+ .setValue(debuggeeClass.fieldByName("testCase"),
+ vm.mirrorOf(testCase));
+ } catch (InvalidTypeException ite) {
+ throw new Failure("** FAILURE setting testCase **");
+ } catch (ClassNotLoadedException cnle) {
+ throw new Failure("** FAILURE notifying debuggee **");
+ } catch (VMDisconnectedException e) {
+ throw new Failure("** FAILURE debuggee connection **");
+ }
+ }
+ }
}
diff --git
a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java
b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010a.java
@@ -33,7 +33,7 @@
public class resume010a {
- //----------------------------------------------------- templete section
+ //----------------------------------------------------- template section
static final int PASSED = 0;
static final int FAILED = 2;
@@ -60,6 +60,7 @@
static int exitCode = PASSED;
+ static int testCase = -1;
static int instruction = 1;
static int end = 0;
// static int quit = 0;
@@ -98,8 +99,12 @@
//------------------------------------------------------ section tested
- case 0: resume010aTestClass.method();
- break;
+ case 0:
+ resume010aTestClass.method();
+ // Wait for debugger to complete the first test case
+ // before advancing to the first breakpoint
+ waitForTestCase(0);
+ break;
case 1: resume010aTestClass.method();
break;
@@ -117,7 +122,16 @@
System.exit(exitCode + PASS_BASE);
}
-
+ // Synchronize with debugger progression.
+ static void waitForTestCase(int t) {
+ while (testCase < t) {
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+ }
}
class resume010aTestClass {