Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8270434: JDI+UT: Unexpected event in JDI tests
Reviewed-by: sspitsyn, kevinw
  • Loading branch information
Alex Menkov committed Sep 16, 2021
1 parent b982904 commit 8c022e2
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 **");
}
}
}

}

3 comments on commit 8c022e2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 8c022e2 Apr 19, 2023

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 8c022e2 Apr 19, 2023

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-8c022e2c in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 8c022e2c from the openjdk/jdk repository.

The commit being backported was authored by Alex Menkov on 16 Sep 2021 and was reviewed by Serguei Spitsyn and Kevin Walls.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-8c022e2c:GoeLin-backport-8c022e2c
$ git checkout GoeLin-backport-8c022e2c
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git GoeLin-backport-8c022e2c

Please sign in to comment.