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

Modifying debugger to return the same breakpoints in 'debugInfo' response as 'setBreakpoints' #1140

Merged
merged 2 commits into from
Aug 4, 2023

Conversation

vaishnavi17
Copy link
Contributor

@vaishnavi17 vaishnavi17 commented Aug 4, 2023

In this PR, I make changes to debugger.py so that the breakpoints returned in a debugInfo response match the breakpoints returned in the most recent setBreakpoints 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 the setBreakpoints response will consist of a breakpoint at line 1. However, the debugInfo request is implemented by ipykernel, and the list of breakpoints for that is maintained by just recording the breakpoints that were sent in the setBreakpoints request. So, a debugInfo request would contain the information that there is a breakpoint at line 2. This causes confusing jumping behavior when the debugInfo 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 the setBreakpoints request as the information for the debugInfo request.

@blink1073 blink1073 added the bug label Aug 4, 2023
Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

Thank you! I'll release this early next week.

@blink1073 blink1073 merged commit 18e54f3 into ipython:main Aug 4, 2023
27 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants