-
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
Suggestion: Start VSCode debugger from the command-line #10979
Comments
This would enable integration with React Native - Debugging using custom debugger. One would then simply press "Debug in Remote Debugger" in the app developer menu in the React Native app on the device/emulator and VSCode would launch and attach to the packager. |
I'll try to investigate what to do here in March. |
Hi I am very interested in this feature and would like to contribute, but I am new to the VS Code codebase. Perhaps I can work with someone? |
@isidorn please advise (since I'm on vacation until October 22). |
@warric11 a good example to follow would be the And then if we start in that mode just get the debugService and call startDebugging on it with the passed name. |
@warric11 the second feature of the original request "launch another instance of vscode in debug mode as part of a debug configuration" is no longer necessary as VS Code supports concurrent debug sessions with the compound feature. |
Yes. I would aslo call this flag |
|
@weinand For my work I don't need the second feature because I am only debugging a single thread of a process, but I definitely want to be able to issue the --debug and give the Python file on the commandline so that I start up the Python file in a debug session. |
@isidorn thanks for the example to follow, I will take a look at it soon. |
@warric11 please focus on passing a "launch config name" first, e.g. Passing additional command line arguments like So the only viable solution would be to pass a stringified json of the launch config (because that contains the names of the affected attributes). E.g. Another approach would be to use a named launch config and a mechanism to replace individual attributes, e.g. So I expect you to investigate these (and more) approaches before submitting a PR. |
+1 what @weinand is saying. We will not support passing the full json. Only the name of the configuraiton. |
Well I for one would very much like to be able to pass a full launch configuration so I hope you'll consider adding that once you've got support for a named configuration working. |
One could write a |
Oh if there's a way to do that then fine. |
Copying over my post from #46496: I like the debugger that comes with Code, and I'd like to use it more often, but in some cases starting it up is cumbersome. My use case:
As far as I know the only way to do that would be to create a launch configuration file, which would look like this: {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "/whatever/foo.js",
"args": ["--flag1"]
}
]
} I have some problems with this approach:
Basically always requiring the creation of a launch configuration files leads to an awful user experience for me. Proposed solution:Node has the |
With the auto-attach feature you can just start your node program from the command line and VS Code will automatically attach to it. Would this address your problem? A first cut of this will appear in the March release. See #42521 |
@weinand not really. I've tried your extension and I've found these problems this it:
Wouldn't it be better to add
Please make sure there will be an option for disabling this. |
@fabiospampinato Sorry, but it is working as expected. Since hello.js is launched with Yes, the fix for terminal multiplexers is in the works. Please define the semantics of |
@weinand Exactly, I don't think the debugger is attaching itself fast enough. I'm not sure this can actually be done in every case, but we could certainly avoid the 1s delay between polls if we used
This would fix my issue because:
|
Which version of vscode includes the auto attach feature? I'm on version 1.16.1 but have no option for it. |
@tamj0rd2 The current stable version is at 1.24. You are 8 months behind, I suggest to always upgrade to the latest. Please click on the gear button in the lower left corner. |
This feature would be great for we want to launch vscode into the debugger. Please add this feature. |
I've just implemented this and what I proposed (configuration-less debugging) in Debug Launcher. Before getting to what the extension actually does I'd like to say a few things:
Getting back to the extension, it allows us to launch the debugger with a custom configuration just by running something like this in the shell: open 'vscode://fabiospampinato.vscode-debug-launcher/launch?args={"type":"node","name":"Foo","request":"launch","program":"/path/to/foo.js"}' Here's a demo of this, but I'm actually using a custom plugin for The extension also allows us to debug whole projects and single files (this is pretty nice) without needing to write tedious launch configurations or tasks. Currently only JS projects/files and VSCode extensions are supported, other kinds of projects/files could be added easily: Enjoy! |
@fabiospampinato very cool and interesting approach! Some comments:
|
That's pretty great, I didn't know about that. It seems that I can't debug single files if the whole project has a
True, but on the flip side with my approach one can have a customized default configuration for each debugger (say I want
Maybe something like |
The code that analyses the package.json is here: https://github.com/Microsoft/vscode-node-debug/blob/70c5980becc2bfbf1aafa290cc8ef3c3720cf6c0/src/node/extension/configurationProvider.ts#L230 A workspace or folder is not just a directory path (or 'cwd') but some entity with a uri. |
@fabiospampinato @weinand I developed a npm package called easy-attach and a vscode extension which launches a rpc server to make attaching even easier: The only downside is that you have to touch the code you want to debug. However, in contrast to the auto-attach feature of vscode, you don't have to launch your app from within vscode and you can debug more than one target as the debug port is chosen randomly. I use it to debug my typescript language service plugin that is being hosted in another vscode instance. |
I need to debug a cli program which is installed via npm. I am using nvm and the cli code is downloaded and available in:
This is a symbolic link and gets added in PATH. Code for the same can be found in
This cli accepts various cli arguments. I want to debug code in
when this command is invoked from iTerm2, such that I could debug this in VS Code. I have tried different configuration options available for debugging, but can't figure out which setting I should use in vscode to do the same. Note: If I use Node.js Launch Program, debugging works, but then I always have to run this within VS Code terminal. Attach to process, doesn't work because the program doesn't wait for debugger to attach. What command line arguments I can use to start a debugging session for any npm module which is installed on my machine? |
@cksachdev have a look at easy attach. It was designed exactly for usecases like yours (where the process to debug is not launched from within vscode). |
If I understand @cksachdev correctly then "asar" is a short running command line program, not a server. So I'm not sure that the "easy attach" extension would help here. I was able to debug "asar" easily with the following launch config: {
"type": "node",
"request": "launch",
"name": "Launch asar",
"program": "/Users/weinand/.nvm/versions/node/v10.15.1/bin/asar",
"stopOnEntry": true,
"args": [
// add any command line args here
]
} Alternatively you can launch "asar" from the terminal in debug mode as follows:
and then use this VS Code generic "attach" config to debug it: {
"type": "node",
"request": "attach",
"name": "Attach to any node program",
"port": 9229
}, The "brk" in "--inspect-brk" makes node.js wait for the debugger to attach. And please see our doc for node.js debugging: https://code.visualstudio.com/docs/nodejs/nodejs-debugging |
I've been using VSCode quite a bit lately and must say I am very happy with it. Recently I needed a way to grab a particular inspect process and this post may help: https://blog.june07.com/socket-watcher/ Further the NiMS VSCode extension helps if you want to debug VSCode processes in Chrome DevTools as it publishes the inspect metadata that gets swallowed by VSCode. There was a lot in this thread so I figured I'd add what may be helpful info. |
When this feature would be available? if not soon any work around to achieve the same. |
Any chance this feature could make it into a future iteration plan? This would be really helpful to automate debugging workflows with VSCode. |
One work around I found is to send key sequences to the vs code window from terminal. I use Ubuntu as host with docker dev container setup. Below is my helper script: window_title="${PWD} - Visual Studio Code"
command_string="xdotool windowactivate --sync \$(xdotool search --name '$window_title' | head -n 1) key Ctrl+Shift+F5"
echo $command_string >> local/docker_host.pipe
You can start a screen session on host to read and execute commands from this pipe upon container start with below setting in devcontainer.json: "initializeCommand": ["/bin/sh", "listen_to_command_pipe_in_screen.sh"], This setup works well for me. Hope this helps. 🎉 |
It would be nice to be able to start the VSCode debugger from the command line, for example:
In addition, it would be nice to be able to launch another instance of vscode in debug mode as part of a debug configuration entry in .vscode/launch.json.
This would serve to make extension development easier (e.g. debug with the language client in one vscode instance, and start another instance to debug the language server).
The text was updated successfully, but these errors were encountered: