Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8292250: Create test for co-located JDI MethodEntry, Step, and Breakpoint events #9840

Closed
wants to merge 7 commits into from

Conversation

plummercj
Copy link
Contributor

@plummercj plummercj commented Aug 11, 2022

We currently have no tests for co-located MethodEntry, Step, and Breakpoint events. We should make sure they are being properly co-located as described in the JDI spec, and also do special test cases for JDK-8292217.

https://docs.oracle.com/en/java/javase/17/docs/api/jdk.jdi/com/sun/jdi/event/EventSet.html

And sorry in advance that the logic is a bit hard to follow in this test due to having multiple test cases, and dealing with the async nature of JDI testing. All I can say is that is used to be a lot worse before I did multiple passes to improve it.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8292250: Create test for co-located JDI MethodEntry, Step, and Breakpoint events

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9840/head:pull/9840
$ git checkout pull/9840

Update a local copy of the PR:
$ git checkout pull/9840
$ git pull https://git.openjdk.org/jdk pull/9840/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9840

View PR using the GUI difftool:
$ git pr show -t 9840

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9840.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 11, 2022

👋 Welcome back cjplummer! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@plummercj
Copy link
Contributor Author

plummercj commented Aug 11, 2022

Here is output from a test run that might be useful when reviewing the test:

Got main thread: instance of java.lang.Thread(name='main', id=1)
Waiting for events:

EventSet for test case #0: event set, policy:2, count:1 = {BreakpointEvent@CLEDebugee:75 in thread main}
Got BreakpointEvent(1): CLEDebugee.test1:75

EventSet for test case #1: event set, policy:2, count:5 = {MethodEntryEvent@java.lang.ClassLoader:521 in thread main, MethodEntryEvent@jdk.internal.loader.ClassLoaders$AppClassLoader:180 in thread main, MethodEntryEvent@java.lang.System:497 in thread main, MethodEntryEvent@java.lang.System:205 in thread main, MethodExitEvent@java.lang.System:205 in thread main}
TESTCASE #1 FAILED (ignoring): too many events in EventSet: 5
Got MethodEntryEvent: java.lang.ClassLoader.loadClass:521
Got MethodEntryEvent: jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass:180
Got MethodEntryEvent: java.lang.System.getSecurityManager:497
Got MethodEntryEvent: java.lang.System.allowSecurityManager:205
Got MethodExitEvent: java.lang.System.allowSecurityManager:205

EventSet for test case #1: event set, policy:2, count:1 = {StepEvent@CLEDebugee:76 in thread main}
Got StepEvent: CLEDebugee.test1:76

EventSet for test case #1: event set, policy:2, count:1 = {BreakpointEvent@CLEDebugee:78 in thread main}
Got BreakpointEvent(2): CLEDebugee.test2:78

EventSet for test case #2: event set, policy:2, count:5 = {MethodEntryEvent@java.lang.ClassLoader:521 in thread main, MethodEntryEvent@jdk.internal.loader.ClassLoaders$AppClassLoader:180 in thread main, MethodEntryEvent@java.lang.System:497 in thread main, MethodEntryEvent@java.lang.System:205 in thread main, MethodExitEvent@java.lang.System:205 in thread main}
TESTCASE #2 FAILED (ignoring): too many events in EventSet: 5
Got MethodEntryEvent: java.lang.ClassLoader.loadClass:521
Got MethodEntryEvent: jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass:180
Got MethodEntryEvent: java.lang.System.getSecurityManager:497
Got MethodEntryEvent: java.lang.System.allowSecurityManager:205
Got MethodExitEvent: java.lang.System.allowSecurityManager:205

EventSet for test case #2: event set, policy:2, count:1 = {StepEvent@t2:44 in thread main}
Got StepEvent: t2.foo:44

EventSet for test case #2: event set, policy:2, count:1 = {BreakpointEvent@CLEDebugee:63 in thread main}
Got BreakpointEvent(3): CLEDebugee.runTests:63

EventSet for test case #3: event set, policy:2, count:3 = {MethodEntryEvent@CLEDebugee:87 in thread main, StepEvent@CLEDebugee:87 in thread main, BreakpointEvent@CLEDebugee:87 in thread main}
Got MethodEntryEvent: CLEDebugee.test3:87
Got StepEvent: CLEDebugee.test3:87
Got BreakpointEvent(4): CLEDebugee.test3:87
TESTCASE #3 PASSED

EventSet for test case #3: event set, policy:2, count:1 = {BreakpointEvent@CLEDebugee:64 in thread main}
Got BreakpointEvent(5): CLEDebugee.runTests:64

EventSet for test case #4: event set, policy:2, count:2 = {MethodEntryEvent@CLEDebugee:95 in thread main, BreakpointEvent@CLEDebugee:95 in thread main}
Got MethodEntryEvent: CLEDebugee.test4:95
Got BreakpointEvent(6): CLEDebugee.test4:95
TESTCASE #4 PASSED

EventSet for test case #4: event set, policy:2, count:1 = {BreakpointEvent@CLEDebugee:65 in thread main}
Got BreakpointEvent(7): CLEDebugee.runTests:65

EventSet for test case #5: event set, policy:2, count:2 = {StepEvent@CLEDebugee:102 in thread main, BreakpointEvent@CLEDebugee:102 in thread main}
Got StepEvent: CLEDebugee.test5:102
Got BreakpointEvent(8): CLEDebugee.test5:102
TESTCASE #5 PASSED

EventSet for test case #5: event set, policy:2, count:1 = {BreakpointEvent@CLEDebugee:66 in thread main}
Got BreakpointEvent(9): CLEDebugee.runTests:66

EventSet for test case #6: event set, policy:2, count:2 = {MethodEntryEvent@CLEDebugee:109 in thread main, StepEvent@CLEDebugee:109 in thread main}
Got MethodEntryEvent: CLEDebugee.test6:109
Got StepEvent: CLEDebugee.test6:109
TESTCASE #6 PASSED

EventSet for test case #6: event set, policy:2, count:2 = {VMDeathEvent, VMDeathEvent}
All done...

EventSet for test case #6: event set, policy:0, count:1 = {VMDisconnectEvent}

@openjdk openjdk bot changed the title 8292250 8292250: Create test for co-located JDI MethodEntry, Step, and Breakpoint events Aug 11, 2022
@openjdk
Copy link

openjdk bot commented Aug 11, 2022

@plummercj The following label will be automatically applied to this pull request:

  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Aug 11, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 11, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 11, 2022

Webrevs

@plummercj
Copy link
Contributor Author

Ping!

Comment on lines 135 to 137
String method;
String signature;
int lineNumber;

Choose a reason for hiding this comment

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

Should be final

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines 160 to 161
List frames = thread.frames();
Iterator iter = frames.iterator();

Choose a reason for hiding this comment

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

List, Iterator and type cast is not needed2 lines below

if (isColocated(set, true, true, true)) {
testcaseFailed = false;
}
}

Choose a reason for hiding this comment

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

break missed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

if (isColocated(set, true, false, true)) {
testcaseFailed = false;
}
}

Choose a reason for hiding this comment

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

break missed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

if (isColocated(set, false, true, true)) {
testcaseFailed = false;
}
}

Choose a reason for hiding this comment

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

break missed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

if (isColocated(set, true, true, false)) {
testcaseFailed = false;
}
}

Choose a reason for hiding this comment

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

break missed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

try {
// Setup all breakpoints
for (MethodBreakpointData bpData : breakpoints) {
Location loc = findMethodLocation(targetClass, bpData.method,

Choose a reason for hiding this comment

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

Specify breakpoints by line number in a method is better than just line number, but did you think about mark them with some tag and parse source file to get line numbers? (like in test/jdk/com/sun/jdi/lib/jdb/JdbTest.java, parseBreakpoints method)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like the tests in com/sun/jdi are split between those that extend JdbTest and those that extend TestScaffold. I'm not too sure of the rationale for using one over the other, but I ended up with TestScaffold because of the test I initially used as a template (BreakpointTest.java). parseBreakpoints() is only supported by JdbTest, so I would need to convert the test to extend it instead. I have no idea how disruptive this might be to the test.

I think the breakpoints I have are fairly safe from code movement and modifications. It would require edits within the methods with the breakpoints, all of which are very simple and well commented, and there really is no reason to ever edit them in the first place. Also there are 8 other tests that are sensitive to line numbers (search for THIS TEST IS LINE NUMBER SENSITIVE), and they are at much greater risk (adding or removing a line anywhere before the breakpoint will break the test).

Choose a reason for hiding this comment

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

AFAIR JdbTest is a base class to test jdb functionality, I didn't mean to extend it. But breakpoint parsing code is quite simple, I thought about add similar method to TestScaffold instead of findMethodLocation.
As I wrote your way with findMethodLocation is much better than just line numbers (used in "THIS TEST IS LINE NUMBER SENSITIVE" tests), I'm okay with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Thanks for the review!

@openjdk
Copy link

openjdk bot commented Aug 24, 2022

@plummercj This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8292250: Create test for co-located JDI MethodEntry, Step, and Breakpoint events

Reviewed-by: amenkov, kevinw

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 162 new commits pushed to the master branch:

  • e353b57: 8292890: Remove PrintTouchedMethodsAtExit and LogTouchedMethods
  • 95a33fe: 8292314: Cleanup legacy address handling
  • 5d799d8: 8292304: [REDO] JDK-8289208 Test DrawRotatedStringUsingRotatedFont.java occasionally crashes on MacOS
  • 4f50316: 8292680: Convert Dictionary to ConcurrentHashTable
  • 2fe0ce0: 8292203: AArch64: Represent Registers as values
  • 251bff6: 8292877: java/util/concurrent/atomic/Serial.java uses {Double,Long}Accumulator incorrectly
  • f57d342: 8292867: RISC-V: Simplify weak CAS return value handling
  • 88af204: 8292494: Ensure SystemDictionary::set_platform_loader and set_system_loader are called only once
  • 8d3d439: 8292903: enhance round_up_power_of_2 assertion output
  • 054c23f: 8290025: Remove the Sweeper
  • ... and 152 more: https://git.openjdk.org/jdk/compare/a28ab7b62abcfce56425d62d5a8162d8f1623393...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 24, 2022
@plummercj
Copy link
Contributor Author

I had to undo the last change that checked if the breakpoint was the expected one. There were two issues. The first was that the breakpoints are not in order, so it always threw an exception on the first breakpoint. However, the test still passed. That was because of a pre-existing bug. I declared testFailed locally within the test class. The overrode the one declared in TestScaffold, and which gets set false if there is an exception thrown in the event handler. I got rid of the override, and then test started to properly fail due to the incorrect breakpoint checks, which I have now also removed.

@plummercj plummercj requested review from kevinjwalls and alexmenkov and removed request for kevinjwalls and alexmenkov August 25, 2022 19:10
Copy link
Contributor

@kevinjwalls kevinjwalls left a comment

Choose a reason for hiding this comment

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

OK thanks, the extra breakpoint check might have been nice but maybe not worth it right now.

Copy link

@alexmenkov alexmenkov left a comment

Choose a reason for hiding this comment

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

Still LGTM

@plummercj
Copy link
Contributor Author

Thanks!

@plummercj
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Aug 25, 2022

Going to push as commit d83faea.
Since your change was applied there have been 162 commits pushed to the master branch:

  • e353b57: 8292890: Remove PrintTouchedMethodsAtExit and LogTouchedMethods
  • 95a33fe: 8292314: Cleanup legacy address handling
  • 5d799d8: 8292304: [REDO] JDK-8289208 Test DrawRotatedStringUsingRotatedFont.java occasionally crashes on MacOS
  • 4f50316: 8292680: Convert Dictionary to ConcurrentHashTable
  • 2fe0ce0: 8292203: AArch64: Represent Registers as values
  • 251bff6: 8292877: java/util/concurrent/atomic/Serial.java uses {Double,Long}Accumulator incorrectly
  • f57d342: 8292867: RISC-V: Simplify weak CAS return value handling
  • 88af204: 8292494: Ensure SystemDictionary::set_platform_loader and set_system_loader are called only once
  • 8d3d439: 8292903: enhance round_up_power_of_2 assertion output
  • 054c23f: 8290025: Remove the Sweeper
  • ... and 152 more: https://git.openjdk.org/jdk/compare/a28ab7b62abcfce56425d62d5a8162d8f1623393...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 25, 2022
@openjdk openjdk bot closed this Aug 25, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 25, 2022
@openjdk
Copy link

openjdk bot commented Aug 25, 2022

@plummercj Pushed as commit d83faea.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@plummercj plummercj deleted the 8292250-cle branch October 11, 2022 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants