-
Notifications
You must be signed in to change notification settings - Fork 287
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
DAP documentation #902
Comments
Insofar as DAP is concerned, we follow the specification. Though I don't think we have consumers using From the other thread:
This is actually expected if they were sent to the root session -- the root is a logical wrapper session and doesn't implement any debugging methods. |
Which launcher should be used if the client doesn't support the customized sessionID and custom message? The comments in the Is there an issue in the debug-adapter-protocol repository that suggests a |
You can try out the vscode-js-debug/src/vsDebugServer.ts Lines 111 to 123 in d8fcf56
by not passing a port when calling
Not right now. I'll talk to Andre and open an issue there after the holiday (monday) |
@connor4312 Would we also be able to use How does this package relate to https://github.com/microsoft/vscode-node-debug2? |
node-debug2 is deprecated and has been replaced by this package. Ultimately you'll need to deal with multiple sessions and sessionIds in some way. |
Okay, that's helpful to know, I really love that microsoft is investing in LSP and DAP to make it more extensible and make it work across editors but it would really help if the custom extensions were as documented, at least for the required ones. As it's not super clear from this thread. Is the following flow correct: if the editor wants a new session, it can just re-init with a new sessionId and again with sequence number 0? |
I don't see such sessions part of the DAP specification. Am I missing something? |
I tried implementing this for nvim-dap but it feels very complex. So first you start up a vsDebugServer.js, that one only outputs the port of the root session. With that port, you talk DAP to initialize and configure, breakpoints get rejected and when you send a launch/attach command, you get the specific message (attachedChildSession). Then you need to connect to that port and send the init DAP messages again (including breakpoints?), I guess? Do you still need to send the launch command as well? ( I guess instead of connecting to that port, you could use the other server and then you would have to use the same connection, just with a connectionId?) |
This can be simplified by passing directly a port to the command, so you don't have to read the output to know the port.
That's the main issue I see. This command seems necessary yet it's not part of the spec. So it seems to me that vscode-js-debug is not actually DAP compliant as it requires non-standard messages to be usable? |
What I also find strange is that if there is a launch/attach request for |
Currently DAP itself has no knowledge of the relation between different sessions, therefore we use out-of-bounds signalling today. However, that might change with microsoft/vscode#116730.
That looks correct, yea. Though we don't really care about
If by re-init you mean launch a new vsDebugServer, yes. I believe the vsDebugServer is currently designed such that it is unique for each session 'tree'. Though in practice I'm less familiar with it as it's only consumed by our friends at VS proper.
That's all correct. VS Code sends all its breakpoints to each session, so that's what js-debug expects. When launching the child you should use the configuration given in the
That's surprising, the type should be the same except when developing a VS Code extension, which you are not doing. vscode-js-debug/src/sessionManager.ts Lines 215 to 218 in 0564a51
|
OK, so it's impossible to use this debug adapter with plain DAP at the moment. Would it be possible to have some flag or initialization option such as |
So every time the editor wants to start a session, it needs to start a new root session? What is the tree you are talking about? In what scenario can you get more than a root and child session? How would the flow look with flatSessionManager, would you also need to restart a new flatSessionManager? Or how do you start a new session / tree there?
I'll report back if I work on this further, but that's what I got in my initial tests of the protocol etc. I was very confused by that |
There are several of them: multiple tabs debugging a browser, webworkers, service workers, iframes, child processes, and worker_threads. These form the "tree" I was referring to.
Yea, the difference is that the sessions are inline in the same server/connection instead of having a separate websocket server for each child. |
But so every time the editor starts up a session, a new root session is needed? The root session cannot be re-used by the client? |
Right |
@EricCornelson What do you think about proposal in #902 (comment) to have a flag instructing debug adapter to assume there is just 1 session and not send unexpected messages? |
I am not eager to support such a feature. It adds complexity to this already pretty complex package and loses features. A far simpler way would perhaps be some bit of translator code that flattens the top session and ignores all child sessions if the editor can't support them. |
It loses features only for those clients that don't support it, but on the other hand, it will actually provide features as right now it just doesn't work in other editors. And I get that there is complexity but right now the complexity will actually have to live in every editor, which is fine if it were the official protocol but it's just an extension for 1 language.
That sounds okay to me. Would that top session then just be the first child session (so no root session, you immediately get the "child" session and there cannot be any other children? |
Sure, that sounds like a good way to do it as well; and I trust you if you think it's simpler. Or maybe is it possible to implement the Debug Adapter in a way that if only 1 session is existing and attached, all requests to the root debug adapter get forwarded to the single session? Most clients that are doing just-DAP could work with that as they'll likely never start multiple sessions (DAP doesn't allow that). |
I'd agree with Connor here. It's already sort of cumbersome in VS to deal with the "root session", as that whole concept (if I recall correctly) was created particularly because VS Code can use it to show a nice hierarchical tree of debug targets (VS doesn't have the concept of "child" and "parent" sessions at all, so we end up with a dummy process in the UI that represents the "root" session). I'd be in favor of flattening the root session to be whatever the first debug session happens to be (e.g. the web page or the first node process). For what it's worth, we did propose adding this to the debug adapter protocol, but it hasn't reached a critical mass yet to be adopted. |
I was able to get a child session working with vsDebugServer.js but my breakpoints are still being rejected. Is there a certain moment you need to send them? Or maybe it needs more info? (I'm using the vsDebugServer.js) (Is there maybe a way to get a log of all messages sent from VSCode to this DAP so I can checkout what they are doing? Because the exact same flow is working in VSCode but not in neovim) (In case it's important, it's in typescript and I'm trying to debug a jest test) |
Unless you pass You can have js-debug log traffic to a text file by setting |
OK, but what about the case of a plain node.js hello world ? Couldn't the Debug Adapter support a similar |
Sure, that is technically possible. Perhaps with some custom debug launcher script that has some bit of translation code (#902 (comment)). I would accept a PR for this provided it can be done is a reasonably durable self-contained way. |
I got it working for neovim now (mfussenegger/nvim-dap#136 (comment)) but we were wondering (mfussenegger/nvim-dap#281), do we actually need to send a response to the |
Also, when I use jest and launch, my breakpoints keep getting rejected (even on the actual session) while they are working (the debugger stops). When I try to use an attach configuration, they keep getting rejected and they are not working. I'm in the right session though because when I set a breakpoint in vs code, it does show in my ui, I get all the details from the debugger From what I can see in the trace logs, I don't see a difference in the command, is there anything special you need to do for breakpoints in typescript to work? |
I'm back on this topic. Do I get it right that at the moment: |
@connor4312 While trying to use Did something like that happened somehow in the past? I'm using |
@gfszr I managed to get it working with I'm not sure exactly how it works with For anyone else stumbling upon this thread, check out this post where I discuss potential solutions to the aforementioned breakpoints issue. |
@mxsdev Thanks for your quick reply! I'm not sure exactly how |
Hey all! Came here after a short jaunt through google searches for a DAP-compliant javascript debugger. Sad to see that the choice between conforming to a specification and having features is as difficult as it seems here 😞 Is it the general consensus that if I want to debug javascript using a tool that implements DAP as specified, I should use the deprecated |
Fyi this will soon be compliant with the adoption of microsoft/debug-adapter-protocol#79 this month, though DAP clients may take longer to update. |
Hello!
I've been trying to get this running in neovim, but I've been having a lot of trouble, are there any docs for how just the DAP is supposed to work, separate from vscode?
Thanks.
The text was updated successfully, but these errors were encountered: