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

vscode.startDebug should take debug configuration json as argument #4615

Closed
Alphapage opened this issue Mar 23, 2016 · 19 comments
Closed

vscode.startDebug should take debug configuration json as argument #4615

Alphapage opened this issue Mar 23, 2016 · 19 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality
Milestone

Comments

@Alphapage
Copy link

Hello,

This request is related to #4607.

I need to be able to start the debugger using a configuration with a specific name.
For now, vscode can only launch the default or selected configuration.

I hope you will take my request into consideration and it will enhance vscode.

Thanks in advance for your feedback.

@isidorn isidorn added feature-request Request for new features or functionality debug Debug viewlet, configurations, breakpoints, adapter issues labels Mar 23, 2016
@isidorn isidorn changed the title Feature request for extensions : add a command to launch a configuration with a specific name workbench.action.debug.start should take debug configuration name as argument Mar 23, 2016
@isidorn isidorn removed their assignment Mar 23, 2016
@isidorn isidorn added this to the Backlog milestone Mar 23, 2016
@isidorn isidorn self-assigned this Mar 23, 2016
@isidorn isidorn modified the milestones: April 2016, Backlog Mar 24, 2016
@Alphapage
Copy link
Author

It would be great if we could give a json config directly, something like this:

workbench.action.debug.start('{
            "name": "LaunchCustom",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/index.js",
            "stopOnEntry": false,
            "args": [],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": null,
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development"
            },
            "externalConsole": false,
            "sourceMaps": false,
            "outDir": null
        }
');

And some events like:

workbench.action.debug.onDidStart((launchName)=>{});

workbench.action.debug.onDidStop((launchName)=>{});

@isidorn isidorn modified the milestones: Backlog, April 2016 Apr 21, 2016
@jcansdale
Copy link

Yes, being able to take a json config directly would be ideal!

@isidorn
Copy link
Contributor

isidorn commented May 10, 2016

We have tackled this issue as part of #3789
I will leave this one open for being able to take a json config directly - which we do not support at the moment.

@isidorn isidorn changed the title workbench.action.debug.start should take debug configuration name as argument vscode.startDebug should take debug configuration json as argument May 10, 2016
@isidorn isidorn modified the milestones: Backlog, May 2016 May 10, 2016
@isidorn
Copy link
Contributor

isidorn commented May 10, 2016

Ok, we now allow both
vscode.commands.executeCommand('vscode.startDebug', 'MyConfigurationName') and something like

vscode.commands.executeCommand('vscode.startDebug', {
            "name": "Launch",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/hello.js",
            "stopOnEntry": false,
            "args": [],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": null,
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development"
            },
            "externalConsole": false,
            "sourceMaps": false,
            "outDir": null,
            "internalConsoleOptions": "openOnFirstSessionStart"
        });

Notice that if the passed argument is a string we will try to find the launch configuration in launch.json, if the passed argument is an object we will try to use it as a launch configuration.

Try it out on the alpha channel and let me know what you think - thanks!

@jcansdale
Copy link

I'm confused about the example code above. What is the 'vscode.startDebug' command? The command I was expecting to see is called 'workbench.action.debug.start'. Was that a typo?

What my extension needs is a way to 'run' rather than 'start' the debugger with a custom configuration object. For example:

vscode.commands.executeCommand('workbench.action.debug.run', {
"name": "Launch",
"type": "node",

Any chance it could be tweaked so that I can do this? Your example is tantalizingly close to being perfect, but unfortunately I can't use it like that. :(

Thanks!

@isidorn
Copy link
Contributor

isidorn commented May 17, 2016

Hi @jcansdale we have changed the name of the command to conform to our naming patterns in the API. You are not able to use it yet in the stable VSCode since this is not released yet.
But once our May release is out - some time in June you will be able to use the code snippet you wrote with just changin the command name.

Hope that makes sense

@jcansdale
Copy link

Will I be able to use it with 'workbench.action.debug.run' as well as 'workbench.action.debug.start'?

I was hoping to try it using the VS Code 'Insiders' version, see it is only currently on the 'alpha channel'. I'll give the alpha version a try. :)

@jcansdale
Copy link

I see the insiders channel is being retired. Where can I find 'Alpha' channel builds?

Thanks!

@isidorn
Copy link
Contributor

isidorn commented May 17, 2016

Alpha channel will be announced soon. @chrisdias can provide more info

@jcansdale
Copy link

Thanks, I'll ping @chrisdias. What about support for 'workbench.action.debug.run' (as opposed to '...debug.start')? That is the major issue for me.

@isidorn
Copy link
Contributor

isidorn commented May 17, 2016

No, workbench.action.debug.runis not public api and should not be used.
Why don't you just use a different string?

@jcansdale
Copy link

I'm confused. How do you mean it's not public api? It's the command that is by default associated with "ctrl+f5". Are you saying there is a way to get similar behavior to "ctrl+f5" by passing a string to another command?

@isidorn
Copy link
Contributor

isidorn commented May 17, 2016

Sorry for the confusion, I misread the string you posted.
I can also look into adding vscode.startDebugWithoutDebugging, created #6425

@Alphapage
Copy link
Author

I tested vscode.startDebug and it is working great, but I found only 2 little problems:

  • you can't restart the configuration submitted when using a custom one which is not listed in launch.json
  • the debug panel is not enabled, so you need to click and enable debug console manually

Do you plan to implement those features ?
Thankyou very much anyway for the api.

@isidorn
Copy link
Contributor

isidorn commented Jun 16, 2016

When you say restart what do you mean - clicking on the restart button does not restart the session - if that is the case then it is a bug and please file a seperate issue.
The debug panel behavior has changed in the latest release, we have intoduced an options to control this, please check it out
https://code.visualstudio.com/Updates#_debugging

@atian25
Copy link

atian25 commented Sep 28, 2016

@isidorn
how could I get startDebug state?
get notification when the debug process is dead. So I can restart it.

where can I find workbench.action.debug.onDidStop doc?

@isidorn
Copy link
Contributor

isidorn commented Sep 28, 2016

@atian25 can you please provide more details? What are you trying to do - are you writing an extension? Your extension can be activated on event: 'onDebug:TYPE' where TYPE is for instance node. Currently we do not have any notifications when the debugged process dies, for that please file a feature request so we consider to add this in the future.

@atian25
Copy link

atian25 commented Sep 28, 2016

just want to find workaround for cluster debug.

our framework will start 3 process, named master/agent/worker, and worker will reload when file change.

so I want to write an extendsion to auto detect worker's new debug port and auto attach to it.

@isidorn
Copy link
Contributor

isidorn commented Sep 28, 2016

This sounds like a scenario which we do not support at the moment. Please create a new issue with the feature request - extension should be able to react on debuggee terminated

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants