vscode-cpptools
vscode-cpptools copied to clipboard
Support "Run without debugging"
I'm running VSCode 1.17.02 on Ubuntu 16.04 x64 and cpptools 0.14.
Could you please add information about how to launch an application w/o debugging (CTRL+F5) to the VSCode C++ docs and maybe post a complete tasks.json / launch.json example here? I've read a couple of issues now and can't quite make launching work... I use make to build my projects. I put
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"runtimeExecutable": "MYEXECUTABLE",
"program": "${workspaceRoot}/MYOUTPUT.FILE",
"preLaunchTask": "Make"
}
]
}
into launch.json. My tasks.json looks like this:
{
"version": "2.0.0",
"tasks": [
{
"taskName": "Make",
"type": "shell",
"command": "make",
"args": [""],
"group": "build",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
The binary file is built successfully via CTRL+SHIFT+B, but when launching via CTRL+F5 I get the message "No executable targets are available". I guess vscode does not know what output file make generates...
Just create another task that runs builds and runs executable :|
And connect that to CTRL+F5 through the key bindings? Might work, but how is it actually meant to be done?! What about my launch.json example? Should that work? Why not? The docs are lacking there imo... :/
No you cannot connect it to CTRL + F5 but you'd be able to run it with CTRL+SHIFT+B if you set it default build task which I've done :)
Thanks for the workaround, but I suspect there must be an actual solution to the problem...
@HorstBaerbel We haven't implemented Launch without Debugging. I'll mark this as a feature request but you may either do it as @agauniyal suggested with a batch file or from the Terminal within VSCode.
Thanks. Will try the "build-and-run" version then for the moment...
I would also love to see a Launch Without Debugging feature added to vscode.
In some cases, you can use Code Runner an alternative.
Isn't CTRL+F5 already the default key binding for Start (without debugging) (workbench.action.debug.run
)? ~It seems to work for me out of the box too: F5 launches with debugging, CTRL+F5 launches without.~
EDIT: In my case I don't think debugging is actually ever running properly, but at least CTRL+F5 is still "running without debugging". The only difference I see is that the call stack shows threads when I F5 but not when I CTRL+F5...
Visual Studio Code Default Key Bindings: https://code.visualstudio.com/docs/getstarted/keybindings#_debug
My launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/data/",
"environment": [],
"externalConsole": true,
}
]
}
My tasks.json file:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g", "${workspaceFolder}/src/main.cpp", "-o", "${workspaceFolder}/bin/main.exe"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
My version of VS Code:
Version: 1.27.1 (system setup)
Commit: 5944e81f3c46a3938a82c701f96d7a59b074cfdc
Date: 2018-09-06T09:21:18.328Z
Electron: 2.0.7
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64
@pieandcakes maybe a week ago, Ctrl+F5 do the same with Start without debugging
. Don't why doesn't work now.
@roachsinai We haven't done work enable that scenario and we haven't shipped an extension update since 0.20.1 which shipped a few months back. Did you apply a VS Code update?
Yes, update it at 2019-01-09...
Needing this launch feature.
We need this to run external application and capture the stdout, with no debug attached.
@polyclash @xgdgsc for now you can use the VS Code Terminal window to launch your application from the command line.
@pieandcakes yes, I use a task, the internal terminal is configured with bash(mingw64), but the terminal don't receive the stdout from the application.
But then I have to set environment variables again in the terminal, I already set those in launch configurations.
Looking forward to this feature.
Also waiting for this feature.
One more vote. Setting all environment vars, launch arguments with unit test filters etc again separately is quite annoying. Debuggers start really slowly in larger projects, due to big symbol tables, being able to make minor edits to code and hit Ctrl+F5 to trigger rebuild and run would really speed iterations.
Another vote. I am writing performance-critical code and I often want to benchmark runtime in release mode. The command line arguments I specify in launch.json are not passed to the command.
+1, I want to reuse args from launch.json. Also enable to start from the terminal.
Is this implemented yet?
+1
@fufjvnvnf No.
+1
Has there been any progress on this? This is a very nice feature to have.
My scenario is that I use compounds
to launch client and server executables and debug them both at the same time. Command-line arguments are sometimes long and verbose for configuring various debug environments. For most cases this is great.
However, they both share a lot of the same library code and sometimes I need breakpoints to only trigger for one process and the other process interferes, making debugging slow.
Support for run without debugging with be perfect here.
Meanwhile, I'm using the fact that VSCode currently doesn't debug child processes, creating a forwarding executable that launches the target and exits immediately:
#include <Shlwapi.h>
#include <stdio.h>
#include <windows.h>
#pragma comment(lib, "shlwapi.lib")
int main(int argc, const char* argv[])
{
// Header
printf("Forwarder.exe Running...\n\n");
if (argc < 2)
{
printf("ERROR: Not enough arguments provided\n");
return 1;
}
// Get target executable
const char* executable = argv[1];
printf("Executable to Launch : %s\n", executable);
if (!PathFileExists(executable))
{
printf("ERROR: Executable path doesn't exist\n");
return 1;
}
// Parse command line for forwarding
const char* command_line = GetCommandLine();
printf("Command Line : %s\n", command_line);
const char* arguments = PathGetArgs(command_line);
printf("Forwarder Arguments : %s\n", arguments);
const char* forward_arguments = PathGetArgs(arguments);
printf("Arguments to forward : %s\n\n", forward_arguments);
// Launch and forward, exiting immediately
STARTUPINFO si{};
si.cb = sizeof(si);
PROCESS_INFORMATION pi{};
if (CreateProcess(executable, (char*)forward_arguments, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi) == FALSE)
{
printf("ERROR: Failed to create process\n");
return 1;
}
printf("Success\n");
return 0;
}
I would love to be able to delete this :)
I don't get it. VSCode seems so complicated, with these json configurations to launch. Isn't it possible to tell vscode to run some executable when hitting ctrl+f5, without an attached debugger? I can't even figure out how to set up two launch configurations, and tell VSCode to run one for ctrl+f5 and the other for f5.
The makefile tools extension sets up a play and a debug button, but there doesn't seem to be an obvious way to configure these, and to connect them to the f5 and ctrl-f5 shortcuts.
"Run without debugging" not working and also devices are not being listed in VS code while if we write and run command in command line then flutter application is compiled. Its weird with VSCode now, it was working well earlier. any suggestion will be welcomed. Thanks.