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

Allow debug adapter to control which frame to focus when stopping (eg. on exception) #65012

Closed
DanTup opened this issue Dec 13, 2018 · 7 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded

Comments

@DanTup
Copy link
Contributor

DanTup commented Dec 13, 2018

This is slightly related to #64193. The current expected behaviour is that VS Code walks up the stack frames and focuses the first frame that has source code (though it's not working correctly due to that bug).

However, assuming "the first frame with source" is the one that is most relevant isn't the best option. For example some languages/frameworks may ship source code for their internal libraries which means often the implementation of an assert method may have source - and this will result in the user looking at that implementation when it may be more appropriate to be looking at their call to it.

It would be best if the debug adapter could explicitly control which frame to focus when an exception is hit (most simply would probably be a flag on the frame for whether it should be excluded from auto-focus, and that flag used in place of the current "has source" check, but it could also make sense in the StoppedEvent).

@vscodebot
Copy link

vscodebot bot commented Dec 13, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@isidorn isidorn assigned weinand and unassigned isidorn Dec 14, 2018
@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality labels Dec 14, 2018
@weinand
Copy link
Contributor

weinand commented Dec 14, 2018

In general this is a valid request.

However, I wonder how realistic it is for a debug adapter to determine the "best frame to focus on" without any help/hints coming from the user.

Based on this observation here is an alternative proposal based on an existing concept:

VS Code has already the concept of "uninteresting" source. This is surfaced in node-debug via the "skipFiles" glob attribute (which is not part of DAP). Whatever source matches that glob gets the special presentationHint deemphasize.

VS Code uses this hint to render stackframes in a dimmed style and collapses adjacent frames into one. We could easily extend VS Code notion of "deemphasized" sources by ignoring them when determining the best frame to focus on.

So in your case you could just return the deemphasize hint for source/frames that should not be focused. And if you can provide this hint even without introducing something like a "skipFiles" glob attribute, then even better.

@DanTup what do you think?

@weinand weinand added the under-discussion Issue is under discussion for relevance, priority, approach label Dec 14, 2018
@DanTup
Copy link
Contributor Author

DanTup commented Dec 14, 2018

However, I wonder how realistic it is for a debug adapter to determine the "best frame to focus on" without any help/hints coming from the user.

In this case I'm trying to focus on "user code" rather than "framework code", so I think the DA is best placed to know this.

So in your case you could just return the deemphasize hint for source/frames that should not be focused.

We actually already set this to get the collapsed stack traces, so using this would be perfect for me. We even let the user control this by opting in to debugging framework code if they want, so this would also be more flexible.

@weinand
Copy link
Contributor

weinand commented Dec 16, 2018

So then let's go with this approach.
@isidorn please consider this when fixing #64193.

@weinand weinand assigned isidorn and unassigned weinand Dec 16, 2018
@weinand weinand added this to the December/January 2019 milestone Dec 16, 2018
@weinand weinand removed the under-discussion Issue is under discussion for relevance, priority, approach label Dec 16, 2018
@isidorn
Copy link
Contributor

isidorn commented Dec 27, 2018

@DanTup I have pushed a fix for this, please try it out in the insiders after we start updating it again after holidays (in 10 days).

@isidorn isidorn added the verification-needed Verification of issue is requested label Dec 27, 2018
@DanTup
Copy link
Contributor Author

DanTup commented Jan 3, 2019

@isidorn Tested in insiders, and it now skips the deemphasize frames and goes to my source - thanks!

screenshot 2019-01-03 at 3 58 50 pm

@isidorn
Copy link
Contributor

isidorn commented Jan 3, 2019

Thanks for trying it out. Adding verified label

@isidorn isidorn added the verified Verification succeeded label Jan 3, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants