-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Breakpoints don't work on wrapped variable assignments #56932
Comments
Summary: Breakpoints are not working on variable assignments wrapped in parentheses, preventing stepping into functions called within the assignment. This issue arises from a recent change intended to improve breakpoint behavior, but it seems to have unintended consequences for certain code patterns. |
@derekxu16 will follow up with @DanTup on two options
|
The debugger currently doesn't know the token range covered by any particular statement, and it would be a significant undertaking to support that, so it's not something we can promise in the foreseeable future. As Siva mentioned, our only options for now are to: 1) keep enforcing that breakpoints can only be resolved on the same line where they were requested (it would be nice to show users which lines contain debuggable code, but I don’t think it’s possible to show that when there’s no active debug session, right?), 2) revert the change and allow breakpoints to move any number of lines, or 3) enforce that breakpoints can only move up to some fixed number of lines. Please let me know what you think. |
This would only work when there is a debug session, but breakpoints are often set before a debug session is starting. It might be useful to use this information (just so setting breakpoints when a session is active is better), but it probably doesn't solve this problem well enough.
I think this might be the best experience, though I'm not sure that number should be. I feel like jumping one line is probably reasonable. Jumping 15 lines is probably not. 2? 3? I'm less sure. Maybe we should start with 1 though and see what the feedback is like. I think it will be better than both the old and the new/current behaviour. WDYT? |
@DanTup jumping one line might sound reasonable but I am worried we may encounter scenarios where it might work better if we had picked two lines or three lines. I see two scenarios here
|
We could certainly print some output whenever we fail to set a breakpoint in the debug console. Adding the reason as a tooltip to the I don't think that addresses the main issue above - it could be quite annoying to have to remember every time you want to set a breakpoint on an assignment like that (particularly if you don't see the text until after the breakpoint is missed, or you're debugging a CLI script that has no exited and you need to run again).
In the debug adapter (which is the only place we can execute code here, VS Code talks directly to the debug adapter) we don't have easy access to the source code, so I doubt we could do this reliably (probably we could get the source from the VM, but at that point the VM could probably do this itself better/faster?).
It's definitely possible, but I think a variable assignment over 1 line is the only case I can come up with so far. That said, I also feel there's something inconsistent here.. why is the breakpoint on line 6 valid, but the one on line 8 should be 9? If I can stop at 6 I feel like I should be able to stop at 8? |
I just looked into this. For the assignment on line 6, we mark the sdk/runtime/vm/compiler/frontend/kernel_to_il.cc Line 2274 in 53bad05
For the assignment on line 8, we know that the RHS of the assignment is a call, and calls are already locations where breakpoints can be set, so we do not mark the |
@derekxu16 what's the reason for the difference? (why wasn't it just set on the RHS?) Are you able to add synthetic locations to break at? Would it be possible for every assignment like this to just have a stop point at the start of the line? |
Yes, we are able to synthetically mark locations as "breakable". That's what we're doing to the
That is possible, but I would personally like it more if the |
A statement like |
That's true, but I don't think if my debugger stopped at the start of the statement and then again on |
A change was recently made to prevent breakpoints from jumping to different lines than the one where they were added if the location was invalid (#56820). While I think the idea is right, it seems to have impacted some kinds of code I hadn't considered and I'm not sure it's a good experience.
Consider this code:
I wanted to step into
ElementLocator.locate
so I put a breakpoint on line 78 expecting it to be the correct one (because I wanted to stop on this statement). However, line 78 is not a valid location to stop, so now we don't pause at all and it feels like a bug.I'm not sure I could define rules that would fix this without reverting the change for #56820, but perhaps someone more familiar with the internals could.
@bkonyi @derekxu16
The text was updated successfully, but these errors were encountered: