[P12][P13] Preventing debug point removal when target method has been modified from reinstalling the method as it was before installation + adding tests #16782
+38
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #16743
Description:
When modifying in the debugger a method with a debug point in it, it would reinstall the method correctly in the debugger (which is correct) while reinstalling the version of the method before installation of the debug point (which is not correct, the installed method should be the modified one).
Explanation:
When recompiling a method in the debugger, it install the method by the OpalCompiler.
As the method already exists is recompiled, it creates a
MethodModified
announcement.This announcement is received by the
DebugPointManager
, class-side.At this stage, the modified method is installed in the system.
When the announcement is received, it finally calls the method
#removeFromMethod:
on each debug point targeting the modified method, which calls the method#removeFromMethod:for:
on their target.In the case of a node, the method simply removes the debug point:
However, the method
remove
from debug points does several things including uninstalling its metalink:Uninstalling the metalink uninstalls the associated reflective method. However, this metalink has the
compiledOnLinkInstallation
option.In this case, uninstalling the reflective method actually reinstalls the compiled method as it was before the metalink was installed:
So that's why the modified method in the debugger is overriden by the previous version of the method.
The problem didn't appear in the previous breakpoint system, because breakpoints didn't uninstall their metalink when their method was modified or remove.
So I fixed the problem by doing the same thing: for debug points: debug points do not uninstll their metalink if they are removed because their target method has been modified or removed.
To me, this solution is not very clean, but it is okay as the metalink should be garbage collected anyway and their target method is not installed anymore, so it should not have any effect.
Anyway, the bug must be in Pharo12 too so the fix should be backported later