-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Expose DAP IDs of breakpoints in vscode API #99716
Comments
@connor4312 if we were to add this I think the most elegant way is simply add an additonal method as you propose to the Please note that currently the vscode api has no notion of the debug adapter protocol. But has a notion of debug adapters, and thus I would not include the word protocol in the name of this method. Also this feels very internal and thus maybe not a best candidate for new API. @weinand for thoughts and suggestions. Where there other requests for something like this from other extension authors? |
Unassigning myself for now. @weinand feel free to assign back to me once you have decided on the best path forward. Thanks |
I've planned to investigate in July what to do here. |
VS Code breakpoints are independent from debug adapters and they live outside of debug sessions. VS Code breakpoints are identified by a UUID (of type string). When a debug sessions starts, VS Code breakpoints are registered with the debug adapter of the debug session and VS Code receives a DAP breakpoint in return. That means one VS Code breakpoint maps to one or more DAP breakpoints (depending on the number of concurrently active debug sessions). DAP breakpoints are identified within a debug session by a numeric ID (of type integer). VS Code maintains a mapping between its breakpoints and corresponding DAP breakpoints. Surfacing this mapping in the extension API is possible in basically three different ways. As already suggested above we could add a prominent method on the VS Code breakpoint: export class Breakpoint {
getDAPBreakpointForSession(session: DebugSession) : DAPBreakpoint | undefined;
} Another approach is to provide the mapping prominently on the session: export class DebugSession {
getDAPBreakpoint(breakpoint: Breakpoint) : DAPBreakpoint | undefined;
} or we could "hide" this mapping in the debug namespace: export namespace debug {
export function getDAPBreakpoint(session: DebugSession, breakpoint: Breakpoint) : DAPBreakpoint | undefined;
} I'm leaning towards the third option because it better hides this really advanced API. Another issue is the use of the Whenever there is a need to connect VS Code's extension API with DAP we introduce an opaque stand-in type. Examples for this are This leads to the following proposal: /**
* A DebugProtocolBreakpoint is an opaque stand-in type for the [Breakpoint](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint) type defined in the Debug Adapter Protocol.
*/
export interface DebugProtocolBreakpoint {
// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint).
}
export namespace debug {
export function getDebugProtocolBreakpoint(session: DebugSession, breakpoint: Breakpoint) : DebugProtocolBreakpoint | undefined;
} @connor4312 what do you think? |
Regardless of where it's exposed, the stand-in type looks good. Putting the method on the breakpoint or debug session is prominent, mainly because these two types have few existing properties or methods. Having this one prominent advantaged API on either of those feels odd to me as well. On the other hand, from a OOP point of view one of those would be the most natural place, but it's ambiguous which one. So option 3 makes sense to me. |
@isidorn it would not be a big effort to implement the |
@weinand correct. That should be doable. |
After discussing the proposal in the API sync call, we've agreed to add the new API on the /**
* A DebugProtocolBreakpoint is an opaque stand-in type for the [Breakpoint](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint) type defined in the Debug Adapter Protocol.
*/
export interface DebugProtocolBreakpoint {
// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint).
}
export class DebugSession {
getDebugProtocolBreakpoint(breakpoint: Breakpoint) : DebugProtocolBreakpoint | undefined;
} |
This looks good to me. Let me know if you need help with the implementation. The stored object contains a bit more, as seen with the |
Looks good, pushed a minor fix on top. |
I've implemented the proposed API which is now ready for finalisation (but still needs a jsdoc). |
@connor4312 the new API is now available in Insiders. Please give it a try... |
I've adopted this in microsoft/vscode-js-debug@2540489#diff-f44b7dbc3c9b27f609323871139f7d34, seems to work very nicely 🙂 |
The final proposed API which is now ready for finalisation: vscode/src/vs/vscode.proposed.d.ts Lines 740 to 756 in b0f0a1b
|
For performance profiling, we let users pick the breakpoints to run to. For this I need to know the DAP ID of the breakpoint, since that's what my debug adapter, in turn, knows about. However, the breakpoint IDs exposed on the API only have a GUID which does not seem correlated with anything else.
In the past I got around this by just having a custom "get breakpoints" request through DAP that returned the breakpoints from the debug adapter and we can show the right UI. But with Jackson's good suggestion here #96473 (comment) I now also want to get the file URI of the breakpoint to show it as a preview.
This ultimately means I need to either redo the URI-generation behavior, or have logic to correlate my DAP breakpoints with debug breakpoints. I ended up doing the latter, but it would be much nicer if breakpoints had some API like:
My current hack-around: https://github.com/microsoft/vscode-js-debug/blob/88e380e64f5bac3a722f879a95793e2688bd4062/src/ui/profiling/breakpointTerminationCondition.ts#L58-L71
The text was updated successfully, but these errors were encountered: