[英]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.