Skip to content

Commit

Permalink
8072701: resume001 failed due to ERROR: timeout for waiting for a Bre…
Browse files Browse the repository at this point in the history
…akpintEvent

Reviewed-by: amenkov, kevinw, sspitsyn
  • Loading branch information
plummercj committed Jul 15, 2024
1 parent 388fcf0 commit c8a95a7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private static void log3(String message) {
static int waitTime;

static VirtualMachine vm = null;
static Debugee debuggee = null;
static EventRequestManager eventRManager = null;
static EventQueue eventQueue = null;
static EventSet eventSet = null;
Expand All @@ -137,8 +138,6 @@ private static void log3(String message) {

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

Debugee debuggee;

argsHandler = new ArgumentHandler(argv);
logHandler = new Log(out, argsHandler);
Binder binder = new Binder(argsHandler, logHandler);
Expand Down Expand Up @@ -336,13 +335,23 @@ private int runThis (String argv[], PrintStream out) {
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");
Expand All @@ -361,13 +370,17 @@ private int runThis (String argv[], PrintStream out) {
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");
Expand Down Expand Up @@ -487,7 +500,8 @@ private int breakpoint () {
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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -81,7 +81,13 @@ public static void main (String argv[]) {

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");
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/vmTestbase/nsk/share/jdi/Debugee.java
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ public int endDebugee() {
/*
* 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;
Expand Down Expand Up @@ -631,7 +631,7 @@ protected void printThreadsInfo(VirtualMachine vm) {
}
}
}
log.display("----------------------------------------------------------------------");
log.display("------------------------------------------------");
} catch (Throwable t) {
log.complain("");
t.printStackTrace(log.getOutStream());
Expand Down

0 comments on commit c8a95a7

Please sign in to comment.