In VSC, for a C++ program, I've configured the launch.json file for debuging as:
{
// 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": [
{
"name": "my_target",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bazel-ddad_fca/bazel-out/k8-dbg/bin/my_target",
"args": [
"input_file",
"output_file"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bazel-ddad_fca/bazel-out/k8-dbg/bin/my_target.runfiles/working_folder",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Skip std",
"text": "skip -rfu ^std::([a-zA-Z0-9_]+)\<.*\>::~?\\1 *\\(",
"ignoreFailures": true
},
{
"description": "Skip files std",
"text": "skip -gfi /usr/include/c++/*/bits/*.h",
"ignoreFailures": true
}
],
"sourceFileMap": {
"/proc/self/cwd/external/": "${workspaceFolder}//external",
"/proc/self/cwd/": "${workspaceFolder}"
}
},
]
}
but when I launch the debug, the vsc debugger keeps initialising but never starts.
I don't know what's causing it. I've tried to reinstall C++ extensions but it did not solve my issue.
Does anyone know what it could be related to or experience the same?
Related
I am really sorry if this question is been asked before, but I couldn't get a solution.
The following is my launch.json and Adding a picture as well. And I am really sure about it that the Program file path and debugger path is correct. The main issue is that I can not see the values of local variables even though I have marked breakpoints.
{
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe",//Program File path is correct
"args": [],
"stopAtEntry": true,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",//And I am sure this is correct as well
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
I'm trying to use the debugger in vs code. I have problems to activate and run it.
This is my code:
#include <gtest/gtest.h>
// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
}
VSCode reports that the program path is missing or invalid, even though I copied the address of the .exe file to the program path of launch.json, then GDB reports that the .exe file not in file format recognized. Any idea would be appreciate much. TY
This is the code in my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [
""
],
"stopAtEntry": false,
"cwd": "c:/Users/ABC/Desktop/Test",
"environment": [],
"program": "c:/Users/ABC/Desktop/Test/hello_test.exe",
"internalConsoleOptions": "openOnSessionStart",
"MIMode": "gdb",
"miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
I'm learning a basic to c++ in Vscode but I'm having issues with debugging, I followed everything downloaded MinGW, edit the environment path variable value to C:\MingGW\Bin. I tried but when I try to run it opens a launch.JSON what do I do after that? When I run > start debugging I get two options, I click on C++(GDB/LLDB). It opens a JSON file it reads :
{
// 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": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/path/to/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
I don't know what do to next please help...
I'm trying to make a json file to debug. I keep getting the error message saying my miDebuggerPath is invalid. this is my launch.json
{
// 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": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/Matrix_public_test.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
//"miDebuggerPath": "/path/to/gdb",
"miDebuggerPath": "usr/bin/gdbus",
//"miDebuggerPath": "C:\\MinGW64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Comments are not allowed in JSON.
Although very similar, just remember JSON is not Javascript. After removing comments your Json validates cleanly at: https://jsonlint.com/ try it.
so i have a problem with debugging a program in VS Code in Ubuntu. When i try that i get this message launch:program 'enter program name, for example /home/daniel/Desktop/OOP/Test/a.out'does not exist and i have an option to see the launch.json file. So any ideas what is the problem? And whats wrong?
Here is the launch.json file:
{
// 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": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.out",
"args": [],
"stopAt`enter code here`Entry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Try changing the line
"program": "enter program name, for example ${workspaceFolder}/a.out",
to this
"program": "/home/daniel/Desktop/OOP/Test/a.out",