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

Breakpoints are not able to move to different sources on update #89756

Closed
connor4312 opened this issue Jan 31, 2020 · 10 comments
Closed

Breakpoints are not able to move to different sources on update #89756

connor4312 opened this issue Jan 31, 2020 · 10 comments
Assignees
Labels
debt Code quality issues debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Milestone

Comments

@connor4312
Copy link
Member

See microsoft/vscode-js-debug#277 (comment). Tl;dr is that in a new debug session, the 'same' sources can get assigned different source references. Although we can use extra information in the adapterData of the source to reconcile the breakpoint to the correct place, updating the source referenced in the breakpoints changed event doesn't appear to have an effect.

@connor4312 connor4312 added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jan 31, 2020
@isidorn isidorn added the debt Code quality issues label Jan 31, 2020
@isidorn isidorn added this to the On Deck milestone Jan 31, 2020
@isidorn
Copy link
Contributor

isidorn commented Jan 31, 2020

I acknowledge this limitation.
Breakpoint currently do not support this, the only update from the session they respect are in this interface. So the fix would be that breakpoints also allow the uri to be updated via the update event (which the DAP supports).
Let me know if this is important for your scenario and I can look into it next milestone potentially.

Code pointer

@connor4312
Copy link
Member Author

Not super high priority but I would prefer this to get fixed before js-debug exits preview, so within the next two milestones probably.

@isidorn
Copy link
Contributor

isidorn commented Jan 31, 2020

Ok, makes sense. Let's assign to February and try to get it in then.

@isidorn isidorn modified the milestones: On Deck, February 2020 Jan 31, 2020
@connor4312
Copy link
Member Author

connor4312 commented Jan 31, 2020

Played around with this, where we derive the sourceReference from a hash of the original source data: microsoft/vscode-js-debug#277 (comment)

However it looks like even if the source reference and paths is the same between sessions, VS Code still treats them as separate files. So then it looks like unless the source reference is 0 they're always different, I don't think there's any way to implement this correctly at the moment.

Here's a log of a restarted debug session:

A set breakpoint from first session being restored: 
{"command":"setBreakpoints","arguments":{"source":{"name":"extension.js","path":"/Users/copeet/.vscode-insiders/extensions/samverschueren.final-newline-0.3.2/out/extension.js","sourceReference":257145157},"lines":[23],"breakpoints":[{"line":23}],"sourceModified":false},"type":"request","seq":3}

Load the same source again--everything identical:
{"seq":264,"type":"event","event":"loadedSource","body":{"reason":"new","source":{"name":"extension.js","path":"/Users/copeet/.vscode-insiders/extensions/samverschueren.final-newline-0.3.2/out/extension.js","sourceReference":257145157}}}

Getting the paused stacktrace: 
{"seq":376,"type":"response","request_seq":11,"command":"stackTrace","success":true,"body":{"stackFrames":[{"id":56,"name":"_onWillDocumentSave","line":23,"column":18,"source":{"name":"extension.js","path":"/Users/copeet/.vscode-insiders/extensions/samverschueren.final-newline-0.3.2/out/extension.js","sourceReference":257145157},"presentationHint":"normal"}],"totalFrames":31}}

Then vscode thinks ref 257145157 is a new file from the one I have open in the editor already and requests its contents:
{"command":"source","arguments":{"sourceReference":257145157,"source":{"path":"/Users/copeet/.vscode-insiders/extensions/samverschueren.final-newline-0.3.2/out/extension.js","sourceReference":257145157}},"type":"request","seq":8}

Swapping back to the old source requests it again:
{"command":"source","arguments":{"sourceReference":257145157,"source":{"name":"extension.js","path":"/Users/copeet/.vscode-insiders/extensions/samverschueren.final-newline-0.3.2/out/extension.js","sourceReference":257145157}},"type":"request","seq":19}

@isidorn
Copy link
Contributor

isidorn commented Feb 7, 2020

@connor4312 I pushed a potential fix for this. Please try it out and let me know how it goes.
I changed two things:

  1. When a source gets opened in the editor ignore the query (which has the source). That way mutiple sessions should open the same file hopefully
  2. Breakpoints now allow for hte update event to change their Source

@connor4312
Copy link
Member Author

Works beautifully, thank you!

@connor4312 connor4312 added the verified Verification succeeded label Feb 10, 2020
@isidorn
Copy link
Contributor

isidorn commented Feb 10, 2020

Good to know, thanks!

@isidorn
Copy link
Contributor

isidorn commented Feb 13, 2020

@connor4312 actually my change to ignore the query when opening the source is BAD. @weinand just found a regression.
I forgot that later on we are reliying on decoding the session id and the reference from the source uri query. Thus we can not do that. So I reverted my commit
Code pointer where we relly on the session id

session = this.debugService.getModel().getSession(data.sessionId);

So across sessions the sources with sourceRef != 0 will always be different.

@connor4312
Copy link
Member Author

Hm, okay. Well if the breakpoint can still move to a different Source it will still be better than it was--just confusing if the user kept the file from the previous session open in their editor.

@isidorn
Copy link
Contributor

isidorn commented Feb 13, 2020

Yeah, breakpoints can still move to a different Source I did not revert that. That part is perfectly fine.

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debt Code quality issues debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants