VSCode 启用 Pretty Printing For GDB 以调试 vector 等 STL 容器
VSCode 启用 Pretty Printing For GDB 以调试 vector 等 STL 容器
在我使用的gdb版本(GNU gdb (GDB) 15.2
)中,无需额外配置即可启用。
在VSCode的launch.json
文件中的setupCommands
片段加入以下Json:
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
重新开始调试即可。
附完整配置文件:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc build active file"
}
]
}
License:
CC BY 4.0