8072701: resume001 failed due to ERROR: timeout for waiting for a BreakpintEvent

Reviewed-by: amenkov, kevinw, sspitsyn
This commit is contained in:
Chris Plummer 2024-07-15 20:26:52 +00:00
parent 388fcf03c0
commit c8a95a763c
3 changed files with 33 additions and 13 deletions
test/hotspot/jtreg/vmTestbase/nsk
jdi/ThreadReference/resume
share/jdi

@ -117,6 +117,7 @@ public class resume001 {
static int waitTime;
static VirtualMachine vm = null;
static Debugee debuggee = null;
static EventRequestManager eventRManager = null;
static EventQueue eventQueue = null;
static EventSet eventSet = null;
@ -137,8 +138,6 @@ public class resume001 {
private int runThis (String argv[], PrintStream out) {
Debugee debuggee;
argsHandler = new ArgumentHandler(argv);
logHandler = new Log(out, argsHandler);
Binder binder = new Binder(argsHandler, logHandler);
@ -336,13 +335,23 @@ public class resume001 {
break label1;
log2(" thread2 is at breakpoint");
log2("......checking up that thread2.resume() resumes thread2 suspended with VirtualMachine.suspend()");
log2(" enabling breakpRequest3");
breakpRequest3.enable();
// don't do vm.suspend() until mainThread is waiting
line = pipe.readln();
if (line.equals("waiting")) {
log2(" : returned string is 'waiting'");
} else {
log3("ERROR: returned string is not 'waiting': " + line);
expresult = returnCode4;
break label1;
}
log2(" suspending the thread2 with vm.suspend()");
vm.suspend();
log2(" first resuming the thread2 with eventSet.resume()");
eventSet.resume();
log2(" checking up thread's state");
@ -361,13 +370,17 @@ public class resume001 {
break label1;
log2(" thread2 is at breakpoint");
log2(" resuming the thread2");
log2(" resuming the thread2");
thread2.resume();
log2(" undo the vm.suspend() with vm.resume()");
vm.resume();
}
// These are only needed if we break out of the loop due to an error
if (expresult != returnCode0) {
vm.resume();
vm.resume(); // for case error when both VirtualMachine and the thread2 were suspended
}
vm.resume();
vm.resume(); // for case error when both VirtualMachine and the thread2 were suspended
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
log2(" the end of testing");
@ -487,7 +500,8 @@ public class resume001 {
try {
eventSet = eventQueue.remove(waitTime*60000);
if (eventSet == null) {
log3("ERROR: timeout for waiting for a BreakpintEvent");
log3("ERROR: timeout for waiting for a BreakpointEvent");
debuggee.printThreadsInfo(vm);
returnCode = returnCode3;
break labelBP;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -81,7 +81,13 @@ public class resume001a {
String instruction;
log1("waiting for an instruction from the debugger ...");
log1("waiting for an instruction from the debugger: iteration " + i);
if (i == 1) {
// Let the debugger know we finished the first iteration and are now
// waiting for next command. This is needed so we don't suspend the
// main thread while it is doing a log(), which can hold a needed lock.
pipe.println("waiting");
}
instruction = pipe.readln();
if (instruction.equals("quit")) {
log1("'quit' recieved");

@ -595,9 +595,9 @@ public class Debugee extends DebugeeProcess {
/*
* Print information about all threads in debuggee VM
*/
protected void printThreadsInfo(VirtualMachine vm) {
public void printThreadsInfo(VirtualMachine vm) {
try {
log.display("------------ Try to print debuggee threads before killing process ------------");
log.display("------------ Print debuggee threads ------------");
if (vm == null) {
log.display("Can't print threads info because 'vm' is null");
return;
@ -631,7 +631,7 @@ public class Debugee extends DebugeeProcess {
}
}
}
log.display("----------------------------------------------------------------------");
log.display("------------------------------------------------");
} catch (Throwable t) {
log.complain("");
t.printStackTrace(log.getOutStream());