I am using VS Code and I try to debug an executable with cygwin gdb compiled with cygwin gcc.
The problem is that it searches for the files within the build folder:
C:\XXX\build\gcc\C\XXX\test\source\test_source.cpp
Of course it cannot find it there, because the sources are not in the build folder, but one folder above.
This is the launch.json I use:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\build\\gcc\\XXX\\test\\XXX.exe",
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files\\T_cygwin\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
This all happens on Windows. I tried out using mingw64 directly where this problem does not occur. So I assume it has to do something with Unix paths. Is there a way to find the right debug files?
Related
Since the update of CMake Tools 1.4.2 (Incorrect run folder #1395) the working directory of the launched binary isn't the workspace directory anymore, but the build directory (due to that files loaded with relative paths are not found anymore).
I tried to figure out in the release notes and the settings if there were some changes that cause that behavior, but I'm not able to find a reason or a solution for that.
The setup is:
Linux
VSCode 1.14.1
CMake Tools 1.4.2
I tried to set the cwd using launch.json, but I'm not able to get it to work.
My launch.json currently looks that way:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Does anyone know how the working directory can be changed?
For debugging it can be changed with:
"cmake.debugConfig": {
"cwd": "${workspaceFolder}"
},
For a regular run/launch it is currently not possible without changing the source of the extension.
i am struggling to get my vscode working. it pops up this error.
"Unable to start debugging. Launch options string provided by the project system is invalid. Unable to determine path to debugger. Please specify the Unable to start debugging. Launch options string provided by the project system is invalid. Unable to determine path to debugger. Please specify the "MIDebuggerPath" option. option."
the code should be working alright, but there must be something im missing and my research in youtube tutorials was not very helpful.
pd im using OSX
here is my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"program": "${workspaceFolder}/bin/main"
},
"osx": {
"MIMode": "lldb",
"miDebuggerPath": "lldb-mi",
"program": "${workspaceFolder}/bin/main"
},
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"program": "${workspaceFolder}/bin/main.exe"
},
"preLaunchTask": "build"
}
]
}
I had the same problem, it was solved by installing GDB (it does not come bundled with VS Code). In your case it seems like it is looking for lldb, here as a stackoverflow question that discusses installing lldb on osx.
I am using vscode to debug a typescript program. Below is the configuration. It has a preLaunchTask to use the task to build the code before debugging. when I run debugger, it prompts an error dialog Could not find the task 'build'. It fails to find the build task which is already defined in tasks section. How can I make it work in vscode?
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/node/src/index.ts",
"skipFiles": [
"<node_internals>/**"
],
"preLaunchTask": "build",
"outFiles": [
"${workspaceFolder}/node/dist/**/*.js"
]
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
],
"tasks": [
{
"label": "build",
"type": "npm",
"script": "yarn build"
}
]
}
The custom tasks should be in a separate tasks.json file, not in the same launch.json file.
From the docs on launch.json attributes:
preLaunchTask - to launch a task before the start of a debug
session, set this attribute to the name of a task specified in
tasks.json (in the workspace's .vscode folder).
See the VS Code tutorial on creating Tasks Auto-Detection and Custom Tasks.
I want to debug my C++ code in VSCode, but after I pressed F5, the external console didn't pop up as expected.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"internalConsoleOptions": "neverOpen",
"MIMode": "gdb",
"miDebuggerPath": "E:\\MinGW\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
],
"preLaunchTask": "Compile for Debug"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile for Debug",
"type": "shell",
"command": "g++",
"args": [
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}",
"-g",
"-Wall",
"-Wextra",
"-Wl,--stack=1024000000"
]
}
]
}
When I press F5, the window looks like this:
enter image description here
It seems that the debug session runs normally (the bar in the red box), but as you can see, the external console doesn't appear.
P.S. My system is Windows 10 (x64), and the vscode is the latest.
Finally, I know how to solve that. It seems a bug of C/C++ extension.
I just set the option "Beta: Use Unicode UTF-8 for worldwide language support" in Windows OFF, and everything works.
More details can be found here.
Thanks a lot to Github user #everything411.
From what I can tell looking at your picture, is that I the program stopped at your break point (I don't use the same version so I'm not entirely sure). You have to click next for your program to finish compiling. If you just want to see what your output is, no break points or anything, hit Crtl + F5.
You can follow this link to learn how to use C++ debugger in Linux:
VS Code Debugger for C++
This tutorial is the official tutorial by the Microsoft VS Code Community.
Follow the steps and you will get to know how to debug C++ files.
Note: You need to have a project folder and keep you .cpp inside it.
I have just started with Perl today and installed ActivePerl 5.24.1 and everything went well. I was able to create my test program testPerl.pl with simple a print command and run it through console.
Now I wanted to use Visual Studio Code to run my Perl script, and so I opened the project folder [testPerl.pl location] with Visual Studio Code and tried to debug the code. I have installed the Perl-Debug extension in the editor and when I hit F5, Visual Studio Code asked me to Select Environment and I chose the Perl Debug option, which actually created the launch.json file for me with the below contents.
{
"version": "0.0.2",
"configurations": [
{
"type": "perl",
"request": "launch",
"exec": "perl",
"name": "Perl-Debug",
"root": "${workspaceRoot}/",
"program": "${workspaceRoot}/${command.AskForProgramName}",
"inc": [],
"stopOnEntry": true
}
]
}
I have kept default values as it, and when I hit F5 again, it asked me for a command with default value test.pl. It is because of ${command.AskForProgramName}, I assume. I entered my file name testPerl.pl in the command, but then nothing happens. It starts and ends without any print in console.
How can I actually configure this launch.json file or is there another way I need to do this?
I tried with a newer version of the plugin: Perl Debug version 0.2.0.
This works out of the box. The proposed configuration looks as follows:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug local",
"program": "${workspaceFolder}/${relativeFile}",
"exec": "perl",
"execArgs": [],
"root": "${workspaceRoot}/",
"inc": [],
"args": [],
"env": {},
"stopOnEntry": true
},
{
"type": "perl",
"request": "launch",
"name": "Perl-Debug remote",
"program": "${workspaceFolder}/${relativeFile}",
"root": "${workspaceRoot}/",
"stopOnEntry": true,
"port": 5000
}
]
}
Do note I tried this out on a Mac, with Visual Studio Code version 1.24.0.
I ran Visual Studio Code on a Mac and changed
"program": "${workspaceRoot}/${command.AskForProgramName}"
to
"program": "${file}"
to get the current file to debug.