-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
Provide debug adapter executable the arguments for the debug session #45220
Comments
|
It would be nice if we could bail out of this gracefully too. Currently if a user sets |
@weinand The issue I noticed was actually for when the active file was the wrong file type, not that there was no active file. I noticed it because I switched to my launch.json and added |
I tried to workaround this issue by making a single debug adapter that could delegate to an adapter selected at @weinand Is there an easy way to "proxy" a set of |
You could run the debug adapter(s) completely on your own inside the extension. See section "Run a debug adapter inside the debug extension" in https://code.visualstudio.com/updates/v1_20#_debug-api. With that approach you can do anything. As you can see here the launching of the DA takes place inside the resolveDebugConfiguration method where you should have access to all info you need. Instead of running the DA inline you could of course spawn it as a separate process as well. |
@weinand I was under the impression that was for debugging convenience, but is it reasonable/a good idea to do that for shipping to end users? And if so, is that API stable enough that it won't break on us? |
There are already debug extensions out there that use this approach, e.g. Java. |
Ok cool! Now I'm wondering why we had it in another process in the first place? That caused much complication, now I'm thinking we can simplify a huge bunch of things! |
Many DAs are not written in JS/TS but in C# or C++. How do you want to run them in the extension host? And better make sure that your DA frees up all resources properly after a session. Running a DA for one session as a separate process is more forgiving than running it continuously as a server for a week... And a DA that lives in an extension (and relies on the extension a lot), will no longer be able to run in any other UI frontends (because they only support DAs but not extensions). So there are some consequences and drawbacks... |
I was actually wondering about writing ours in Dart, but wasn't sure if the over-the-wire protocol was well defined and how much logic there was inside the nodejs package. Is there info on the protocol somewhere I can read up?
Yep, understood. We're mostly just proxying onto the Dart VM so there's only really one process for us to track, so this should be easy enough. |
The wire protocol is defined here and the corresponding TS source is generated by this trivial tool. The TS library does not contain a lot of logic (see https://github.com/Microsoft/vscode-debugadapter-node/blob/master/adapter/src/debugSession.ts). The only interesting thing might be the code that deals with the (legacy) JSON-RPC. |
@weinand Cool, thanks for all the info. In the short-term I'll see whether moving the DA in-process solves the original problem for me. |
Or just launch it yourself but still run it as a separate process. |
How simple is that/ I had a look in the repo and found this doCreateProcess method but it seems to be doing a lot. Which is the correct part for me to copy/call from my resolveDebugConfig? Thanks! |
Noooooooo! Just a It is basically what you have in your "server" launch config. And use a free random port (instead of 1234) and add this number to the launch config as the "debugServer" attribute. |
Oooh, gotcha! I'll give it a go - thanks! :) |
Did you try to run your DA "in-process"? Just move the and in your
|
It seems to launch, but fails with ENOENT spawning my VM - I wonder if it's the working directory? But I'm not sure how to set that from the code above? By the way - why don't I have the
I've got my engine in package.json set to v1.21 and have run |
Actually, I'm not sure it's working - debugger never seems to recieve the launch request. This is the code I have in my
Just seems to silently do nothing when run (this code does run, but nothing happens in the test extension host - debugger toolbar never appears, etc.). I've turned on All Exceptions and Promise Rejects in the debugger, but nothing. |
If you are running the DA in-process, it is now trivial to debug your DA as part of the extension in VS Code. Just press "F5" in your extension and in the new window open a dart project and start debugging again with "F5". Is your resolve method hit? |
It calls resolve, and everything looks good (except I had to do the weird cast mentioned above because I can't see anything different to yours though. This is the exact change: I tried both with DartDebugSession and FlutterDebugSession, but see same behaviour. I'll have to try debugging more tomorrow or next week. |
@weinand Ok, getting somewhere! My failure to launch was a typo - I had two variables, So, everything is good except I don't understand why I need this cast and you don't:
My |
@weinand I have no need for this now, the above solution works fine, so feel free to close. I am still confused by thing mentioned in my last comment though; I'm not sure why I get a compile error and have to cast |
In the proposed API I've added a new method The previous method The new method makes it possible to run a node.js based debug adapter "inline" in the extension with this: private _server?: Net.Server;
provideDebugAdapter(session: vscode.DebugSession, folder: WorkspaceFolder | undefined, executable: vscode.DebugAdapterExecutable, config: DebugConfiguration, token?: CancellationToken): ProviderResult<vscode.DebugAdapterDescriptor> {
// start port listener on launch of first debug session
if (!this._server) {
// start listening on a random port
this._server = Net.createServer(socket => {
const session = new MockDebugSession();
session.setRunAsServer(true);
session.start(<NodeJS.ReadableStream>socket, socket);
}).listen(0);
}
// make VS Code connect to debug server instead of launching debug adapter
return new vscode.DebugAdapterServer(this._server.address().port);
} |
@weinand For DAs already spawning their own server in-process in the resolve method, is there value in moving that code to |
@DanTup for the time being, the only value in moving that code to |
I recently merged my two debuggers and started using
adapterExecutableCommand
to switch between my project types to allow debugging without alaunch.json
.However, while trying to support projects in sub-folders (and unit testing, which works differently to debugging on the device) I've discovered that I need to know the
program
and/orcwd
for the session being launched in order to know which of the debuggers to launch.Currently, adapterExecutableCommand (and it's replacement,
DebugConfigurationProvider.debugAdapterExecutable
) are only provided the workspace folder.Is it possible to provide more information about the session being started? I need it to support people that have projects in sub-folders of their root and for running tests.
The text was updated successfully, but these errors were encountered: