Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8270434: JDI+UT: Unexpected event in JDI tests
Backport-of: 8c022e2c174cca2b03e8fdf4fadad42bc11c65f1
  • Loading branch information
GoeLin committed Apr 20, 2023
1 parent ef1a9ec commit db3b06f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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 @@ -320,6 +320,8 @@ private void testRun()
log1(" TESTING BEGINS");

{
final String testThreadName = "thread2";

log2("......setting up ThreadStartRequest");
ThreadStartRequest tsr = eventRManager.createThreadStartRequest();
tsr.addCountFilter(1);
Expand All @@ -342,7 +344,7 @@ private void testRun()
vm.resume();

log2("......waiting for ThreadStartEvent");
getEventSet();
getEventSetForThreadStartDeath(testThreadName);
eventSets[10] = eventSet;

Event receivedEvent = eventIterator.nextEvent();
Expand All @@ -357,7 +359,7 @@ private void testRun()
vm.resume();

log2("......waiting for ThreadDeathEvent");
getEventSet();
getEventSetForThreadStartDeath(testThreadName);
eventSets[9] = eventSet;
receivedEvent = eventIterator.nextEvent();
if ( !(receivedEvent instanceof ThreadDeathEvent) ) {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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 @@ -266,7 +266,7 @@ private void testRun()
for (int i = 0; ; i++) {

vm.resume();
breakpointForCommunication();
breakpointForCommunication(debuggeeName);

int instruction = ((IntegerValue)
(debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value();
Expand Down
21 changes: 21 additions & 0 deletions test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java
Expand Up @@ -197,4 +197,25 @@ protected void breakpointForCommunication() throws JDITestRuntimeException {
throw new JDITestRuntimeException("** event '" + event + "' IS NOT a breakpoint **");
}

// Similar to breakpointForCommunication, but skips Locatable events from unexpected locations.
// It's useful for cases when enabled event requests can cause notifications from system threads
// (like MethodEntryRequest, MethodExitRequest).
protected void breakpointForCommunication(String debuggeeName) throws JDITestRuntimeException {
log2("breakpointForCommunication");
while (true) {
getEventSet();

Event event = eventIterator.nextEvent();
if (event instanceof BreakpointEvent) {
return;
}
if (EventFilters.filtered(event, debuggeeName)) {
log2(" got unexpected event: " + event + ", skipping");
eventSet.resume();
} else {
throw new JDITestRuntimeException("** event '" + event + "' IS NOT a breakpoint **");
}
}
}

}

1 comment on commit db3b06f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.