Skip to content

Commit c8a95a7

Browse files
committedJul 15, 2024
8072701: resume001 failed due to ERROR: timeout for waiting for a BreakpintEvent
Reviewed-by: amenkov, kevinw, sspitsyn
1 parent 388fcf0 commit c8a95a7

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed
 

‎test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/resume/resume001.java

+22-8
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ private static void log3(String message) {
117117
static int waitTime;
118118

119119
static VirtualMachine vm = null;
120+
static Debugee debuggee = null;
120121
static EventRequestManager eventRManager = null;
121122
static EventQueue eventQueue = null;
122123
static EventSet eventSet = null;
@@ -137,8 +138,6 @@ private static void log3(String message) {
137138

138139
private int runThis (String argv[], PrintStream out) {
139140

140-
Debugee debuggee;
141-
142141
argsHandler = new ArgumentHandler(argv);
143142
logHandler = new Log(out, argsHandler);
144143
Binder binder = new Binder(argsHandler, logHandler);
@@ -336,13 +335,23 @@ private int runThis (String argv[], PrintStream out) {
336335
break label1;
337336
log2(" thread2 is at breakpoint");
338337

339-
340338
log2("......checking up that thread2.resume() resumes thread2 suspended with VirtualMachine.suspend()");
341339

342340
log2(" enabling breakpRequest3");
343341
breakpRequest3.enable();
342+
343+
// don't do vm.suspend() until mainThread is waiting
344+
line = pipe.readln();
345+
if (line.equals("waiting")) {
346+
log2(" : returned string is 'waiting'");
347+
} else {
348+
log3("ERROR: returned string is not 'waiting': " + line);
349+
expresult = returnCode4;
350+
break label1;
351+
}
344352
log2(" suspending the thread2 with vm.suspend()");
345353
vm.suspend();
354+
346355
log2(" first resuming the thread2 with eventSet.resume()");
347356
eventSet.resume();
348357
log2(" checking up thread's state");
@@ -361,13 +370,17 @@ private int runThis (String argv[], PrintStream out) {
361370
break label1;
362371
log2(" thread2 is at breakpoint");
363372

364-
365-
log2(" resuming the thread2");
373+
log2(" resuming the thread2");
366374
thread2.resume();
367375

376+
log2(" undo the vm.suspend() with vm.resume()");
377+
vm.resume();
378+
}
379+
// These are only needed if we break out of the loop due to an error
380+
if (expresult != returnCode0) {
381+
vm.resume();
382+
vm.resume(); // for case error when both VirtualMachine and the thread2 were suspended
368383
}
369-
vm.resume();
370-
vm.resume(); // for case error when both VirtualMachine and the thread2 were suspended
371384

372385
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
373386
log2(" the end of testing");
@@ -487,7 +500,8 @@ private int breakpoint () {
487500
try {
488501
eventSet = eventQueue.remove(waitTime*60000);
489502
if (eventSet == null) {
490-
log3("ERROR: timeout for waiting for a BreakpintEvent");
503+
log3("ERROR: timeout for waiting for a BreakpointEvent");
504+
debuggee.printThreadsInfo(vm);
491505
returnCode = returnCode3;
492506
break labelBP;
493507
}

‎test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/resume/resume001a.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,13 @@ public static void main (String argv[]) {
8181

8282
String instruction;
8383

84-
log1("waiting for an instruction from the debugger ...");
84+
log1("waiting for an instruction from the debugger: iteration " + i);
85+
if (i == 1) {
86+
// Let the debugger know we finished the first iteration and are now
87+
// waiting for next command. This is needed so we don't suspend the
88+
// main thread while it is doing a log(), which can hold a needed lock.
89+
pipe.println("waiting");
90+
}
8591
instruction = pipe.readln();
8692
if (instruction.equals("quit")) {
8793
log1("'quit' recieved");

‎test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,9 @@ public int endDebugee() {
595595
/*
596596
* Print information about all threads in debuggee VM
597597
*/
598-
protected void printThreadsInfo(VirtualMachine vm) {
598+
public void printThreadsInfo(VirtualMachine vm) {
599599
try {
600-
log.display("------------ Try to print debuggee threads before killing process ------------");
600+
log.display("------------ Print debuggee threads ------------");
601601
if (vm == null) {
602602
log.display("Can't print threads info because 'vm' is null");
603603
return;
@@ -631,7 +631,7 @@ protected void printThreadsInfo(VirtualMachine vm) {
631631
}
632632
}
633633
}
634-
log.display("----------------------------------------------------------------------");
634+
log.display("------------------------------------------------");
635635
} catch (Throwable t) {
636636
log.complain("");
637637
t.printStackTrace(log.getOutStream());

0 commit comments

Comments
 (0)
Please sign in to comment.