The debugger is not able to provide the content of an STL container (i.e. vector or string).
Below is my launch.json
, where I have added -enable-pretty-printing
as per this thread but I'm unable to see the content of the STL Container.
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"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 tried even adding expression in the watch window. But that also didn't work for me. Or maybe I am missing something. this thread
You have to change it so it runs in the terminal. Go to the menu Code > Preferences > Settings. In the User tab on the left panel, expand the Extensions section. Find and select Run Code Configuration.
Firstly, you probably used x64 Windows.
I found one valid solution, when installing MinGW in x64 Windows, install i686 (win32)
version (the bottom of this comment gives its official download link) of MinGW instead of x86_64
version, see below:
win32 version of MinGW download:
i686-win32-dwarf
I just extracted the downloaded file into the folder D:\MinGW
, then add the bin path of MinGW D:\MinGW\i686-8.1.0-release-posix-dwarf-rt_v6-rev0\mingw32\bin
to the PATH
of System Variable of environment.
.vscode\tasks.json
{
"tasks": [
{
// "type": "shell",
"label": "C/C++: g++.exe build active file",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
.vscode\launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{ // Display content in STL containers pretty
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
.vscode\c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "g++", // Or complete absolute path "D:/MinGW/i686-8.1.0-release-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.exe"
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x86"
}
],
"version": 4
}
VSCode Version: 1.53.2 (system setup)
OS Version: Windows 10 x64 (Windows_NT x64 10.0.19041)
MinGW version: i686-8.1.0-release-posix-dwarf-rt_v6-rev0
GDB version: 8.1.0 (Target: i686-w64-mingw32)
Initially posted on https://github.com/microsoft/vscode-cpptools/issues/3921#issuecomment-780379258.
May it be helpful for you.
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