-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8295303: cleanup debug agent's confusing use of EI_GC_FINISH #10887
Conversation
👋 Welcome back cjplummer! A progress list of the required criteria for merging this PR into |
@plummercj The following label will be automatically applied to this pull request:
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. |
* GARBAGE_COLLECTION_FINISH is special since it is not tied to any handlers or an EI, | ||
* so it cannot be setup using threadControl_setEventMode(). Use JVMTI API directly. | ||
*/ | ||
error = JVMTI_FUNC_PTR(gdata->jvmti,SetEventNotificationMode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add space after the comma:
error = JVMTI_FUNC_PTR(gdata->jvmti, SetEventNotificationMode)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omitting the space is consistent with other uses of JVMTI_FUNC_PTR.
if ( i < EI_min || i > EI_max ) { | ||
EXIT_ERROR(AGENT_ERROR_INVALID_INDEX,"bad EventIndex"); | ||
jdwpEvent event = 0; | ||
if (ei >= EI_min || ei >= EI_max) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "(ei >= EI_min && ei <= EI_max"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
if ( i < EI_min || i > EI_max ) { | ||
EXIT_ERROR(AGENT_ERROR_INVALID_INDEX,"bad EventIndex"); | ||
jvmtiEvent event = 0; | ||
if (ei >= EI_min || ei >= EI_max) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "(ei >= EI_min && ei <= EI_max"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@plummercj this pull request can not be integrated into git checkout 8295303_gc_finish
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
@@ -232,6 +232,7 @@ eventText(int i) | |||
CASE_RETURN_TEXT(EI_THREAD_START) | |||
CASE_RETURN_TEXT(EI_THREAD_END) | |||
CASE_RETURN_TEXT(EI_CLASS_PREPARE) | |||
CASE_RETURN_TEXT(EI_CLASS_UNLOAD) | |||
CASE_RETURN_TEXT(EI_CLASS_LOAD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Would it be a little better to place it after EI_CLASS_UNLOAD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean put EI_CLASS_UNLOAD after EI_CLASS_LOAD, I tried to keep the current ordering. If you look in util.h (bottom of this page), it used to have:
EI_CLASS_PREPARE = 7,
EI_GC_FINISH = 8,
EI_CLASS_LOAD = 9,
and now it has:
EI_CLASS_PREPARE = 7,
EI_CLASS_UNLOAD = 8,
EI_CLASS_LOAD = 9,
There are a couple of other places where this ordering is preserved and I tried to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks.
It makes sense then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Thanks,
Serguei
@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:
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 4 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Thanks Alex and Serguei! /integrate |
Going to push as commit 74f2b16.
Your commit was automatically rebased without conflicts. |
@plummercj Pushed as commit 74f2b16. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR renamed EI_GC_FINISH to EI_CLASS_UNLOAD and does some other minor cleanups related to EI_GC_FINISH.
The debug agent deals with 3 types of events: JVMTI (per the spec), JDWP (per the spec), and an event indexing that the debug agent refers to as EI (Event Index) events. We have the following EI_GC_FINISH event. The indexing is into the array of jdwp event handlers which are created when the debugger sends an EventRequest command.
Note there is no EI_CLASS_UNLOAD event that maps to the JDWP CLASS_UNLOAD event, but instead we have:
EI_GC_FINISH = 8,
And these are the mappings between EI_GC_FINISH and JDWP and JVMTI events
So there is this odd relationship between EI_GC_FINISH and the JDWP CLASS_UNLOAD event. Note that JVMTI does not have a CLASS_UNLOAD (except for unused support in the extension mechanism), and JDWP has no GC_FINISH event.
This relationship between EI_GC_FINISH and the JDWP CLASS_UNLOAD events stems from the fact that at one point JVMTI_EVENT_GARBAGE_COLLECTION_FINISH was used to trigger the synthesizing all of JDWP CLASS_UNLOAD events for classes that unloaded during the last GC. That is no longer the case, and instead each time a JVMTI OBJECT_FREE event is triggered for a Class instance, the JDWP CLASS_UNLOAD is generated.
Since JDWP CLASS_UNLOAD maps to EI_GC_FINISH, we have the following:
node = getHandlerChain(EI_GC_FINISH)->first;
By looking at this line of code, you would never guess that this is how you fetch the event handler chain for JDWP CLASS_UNLOAD EventRequests, but it is.
To clean this up I renamed EI_GC_FINISH to EI_CLASS_UNLOAD. However, that still leaves the EI_GC_FINISH to JVMTI_EVENT_GARBAGE_COLLECTION_FINISH mapping to deal with. It's not needed anymore. When we get a JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, this is all we ever do with it:
So the event is not passed around at all, and doesn't trigger other events or mapping to a JDWP event. It is never used as an "event index". This means jvmti2EventIndex should assert if it is ever passed in, since following mapping should never be needed:
This is accomplished by simply deleting the above code, and failing through to the default error handling code.
Also no longer needed is the following entry:
For this we just assign the entry to 0, which will result in an error if the entry is ever referenced.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10887/head:pull/10887
$ git checkout pull/10887
Update a local copy of the PR:
$ git checkout pull/10887
$ git pull https://git.openjdk.org/jdk pull/10887/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10887
View PR using the GUI difftool:
$ git pr show -t 10887
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10887.diff