I have written a simple C++(11) program to test the debugger in Visual studio code in Windows. I am using MinGW distributions for compiler options.
I have setup my tasks.json and launch.json as per the doc here:
https://code.visualstudio.com/docs/cpp/config-mingw
Here is the sample cpp code:
typedef std::vector<int> vi;
int main(int argc, char const *argv[])
{
fast();
int tests = 1;
cin >> tests;
while(tests--)
{
int n = 5, k = 25;
cin >> n >> k;
vi permutation(n);
for (int i = 0; i < n; i++)
{
cin >> permutation[i];
}
// vi permutation = {5,4,3,2,1};
auto ans = solve(permutation, k);
// other logic goes here
}
return 0;
}
My tasks.json file:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"-std=c++11",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\MinGW\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": false,
"reveal": "always",
"focus": true,
"panel": "shared",
"clear": false,
"showReuseMessage": false
},
}
]
}
My 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": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
I am seeing this in the debugger window:

As per the doc, I should see a screen something like this:

Am I setting something wrong here? Why am I not seeing the content of containers? I have observed that I can't see the values of other containers also.
I faced the same issue when I installed the MINGW from the site which you have mentioned. Then I installed MINGW from SourceForge mentioned in the wiki and it started working fine. Please have a try once.
maybe try this https://github.com/microsoft/vscode-cpptools/issues/69 { "description": "Enable pretty-printing for gdb", "text": "python import sys;sys.path.insert(0, '/usr/share/gcc-8/python');from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)", "ignoreFailures": false },
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With