[英]Where to find source code for specific function in C++ standard library? (Visual Studio installation)
[英]Debug C++ Standard Library with Visual Studio Code on macOS
我在 macOS 上使用带有Microsoft C/C++ 扩展的Visual Studio Code来评估生产环境中的实际可用性和生产力。
在我的场景中,我使用的是Clang/LLVM编译器和LLDB调试器。
由于某些未知原因,我无法调试 C++ 标准库。 我可以进入我的应用程序中定义的符号,但不能对标准符号做同样的事情,例如std::vector
构造函数。
目前尚不清楚这是不正确的配置还是这些工具的限制。 在 web 上搜索时,我注意到 C++ 标准库调试在使用 GNU 工具链的 Linux 上运行良好。
有没有办法使用LLDB调试器调试标准符号? 有人在生产中使用这些工具吗?
为了完整起见,它遵循我当前且非常简单的配置:
tasks.json
:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: /usr/bin/clang++"
}
]
}
launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"console": "externalTerminal",
"MIMode": "lldb",
"preLaunchTask": "${defaultBuildTask}"
}
]
}
Microsoft C/C++ 扩展支持团队指出这是由于lldb
的默认配置。 实际上, target.process.thread.step-avoid-regexp
默认设置为^std::
:
(lldb) settings show target.process.thread.step-avoid-regexp
target.process.thread.step-avoid-regexp (regex) = ^std::
将此设置更改为""
,调试器也能够进入标准模板符号。 这可以在launch.json
配置文件中配置,添加:
"setupCommands": [
{
"text": "settings set target.process.thread.step-avoid-regexp \"\"",
"description": "Enable stepping into STL"
}
]
或者,也可以通过将此配置放在主目录的.gdbinit
文件中,在用户级别进行设置:
settings set target.process.thread.step-avoid-regexp ""
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.