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

Multi-Debug Session Support #586

Closed
inclyc opened this issue Jun 11, 2022 · 8 comments
Closed

Multi-Debug Session Support #586

inclyc opened this issue Jun 11, 2022 · 8 comments

Comments

@inclyc
Copy link

inclyc commented Jun 11, 2022

Problem Statement

In VSCode, multiple debug sesssions can be launched at the same time. The benefit of this is to debug some languages that have FFI, such as C extensions for Python.

Ideas or possible solutions

The current code seems to be written for a single debugger, we can assign a session number to each DAP, and then pass parameters in the debugger action (step over/into etc.) to determine which debug session to use. If there is currently only one DAP, just keep the legacy behaviour

@mfussenegger
Copy link
Owner

You could already create multiple sessions using the lower level APIs and switch around the active session using set_session. The bigger issue is that the breakpoints are global and use signs.

@inclyc inclyc closed this as completed Jul 3, 2022
@mfussenegger
Copy link
Owner

I still want to improve this somehow but there are many details to consider.

E.g if you set a breakpoint, to which session does it go. What if one session rejects it and another doesn't.
What if one session stops at a breakpoint while you're already stopped in another session.

There's also session hierarchy to consider for extensions like nvim-dap-python and nvim-dap-vscode-js

@johnybx
Copy link

johnybx commented Nov 7, 2022

now that the reverse request StartDebugging is released do you plan to add support for multiple sessions @mfussenegger ?

@mfussenegger
Copy link
Owner

I plan to add support for startDebugging, but it's currently not implemented in any debug adapter.
And it's a bit different than what this issue is about - although related. startDebugging will use hierarchical sessions. This one is about having multiple top-level sessions.

@mxsdev
Copy link

mxsdev commented Nov 14, 2022

@mfussenegger

According to this comment support in vscode-js-debug will happen soon.

Just wanted to say that I'm happy to help in the adoption of startDebugging due to its importance for nvim-dap-vscode-js 👍

One concern, as you were mentioning earlier, is on the fact that breakpoints are currently handled globally, which poses a problem for hierarchical/multi-sessions. Looking at the codebase it seems this is still the case. I remember around the time you posted this, I spent some time trying to solve the problem on the nvim-dap side, and it got pretty complicated and messy pretty quick, so I kind of gave up on it for the time being.

This is a good excuse to work on it though. Would you be open to a PR that reworked breakpoints to be per-session, assuming I can find a reasonable way to accomplish it?

@mfussenegger
Copy link
Owner

Would you be open to a PR that reworked breakpoints to be per-session, assuming I can find a reasonable way to accomplish it?

Thanks for the offer, but I think I'll look into this myself once I get to implement startDebugging. It's also important for debugpy for multiprocessing support.

I suspect that reworking them to make them per-session may even be the wrong thing to do, because I it could be that all sessions will need to receive the breakpoint info. It was unfortunately left unspecified in the specification. If that's the case there'll need to be some broadcast mechanism, and the rejection handling will need to account for one session rejecting and another session accepting.

@mfussenegger
Copy link
Owner

With #844 there is now support for running multiple sessions in parallel in master.

And there's also a PR up for startDebugging (#853) but that will need a little bit more work.

@mfussenegger
Copy link
Owner

startDebugging is merged too (#853)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants