【发布时间】:2021-01-19 04:49:51
【问题描述】:
问题陈述:
调试器无法提供 STL 容器的内容(即向量或字符串)。
概述:
下面是我的launch.json,我按照this thread 添加了-enable-pretty-printing,但我看不到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"
}
]
}
我什至尝试在监视窗口中添加表达式。但这对我也不起作用。或者,也许我错过了一些东西。 this thread
【问题讨论】:
-
你扩展
_M_start了吗? -
@sweenish,它只是给了我向量的第一个元素。
-
是的,那里可能还有另一个成员,展开后会显示下一个成员。事情就是这样。我看到的只是
push_back()s,您可能会看到a.back()的值,但同时向量的行为是正确的。可见断点看起来毫无意义。
标签: c++ visual-studio-code gdb vscode-debugger