Modifying debugger to return the same breakpoints in 'debugInfo' response as 'setBreakpoints' #1140
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.
In this PR, I make changes to
debugger.py
so that the breakpoints returned in adebugInfo
response match the breakpoints returned in the most recentsetBreakpoints
request.Bug context:
When a user clicks on a gutter to add/remove a breakpoint, a setBreakpoints request is sent. The UI changes according to the response of the setBreakpoints request, which gives a list of the breakpoints that were actually added. debugInfo is used to populate the UI breakpoints when a notebook is refreshed. So, it is important that the debugInfo and setBreakpoints information aligns.
Let's say we try to add a breakpoint at a commented out line (say line 2).
debugpy
will infer that that line is not a runnable piece of code, so it will add a breakpoint to the line of code before that (say line 1), and thesetBreakpoints
response will consist of a breakpoint at line 1. However, thedebugInfo
request is implemented byipykernel
, and the list of breakpoints for that is maintained by just recording the breakpoints that were sent in the setBreakpoints request. So, adebugInfo
request would contain the information that there is a breakpoint at line 2. This causes confusing jumping behavior when thedebugInfo
request gets called, like on refresh.In the video, the breakpoint jumps from line 1 to line 2 when the page is refreshed. Then, if I try to add a breakpoint at line 1, the breakpoint at line 2 disappears (because the
setBreakpoints
response contains the correct info, which is that there is no breakpoint at line 2).inconsistent-breakpoints.mov
Fix:
I fix this by modifying the
setBreakpoints
request handler indebugger.py
to record the response of thesetBreakpoints
request as the information for the debugInfo request.