[英]setup lldb debugging with cpp extension in vscode linux
我主要使用 gdb 在 vscode 中調試 c++ 單個文件,但現在想嘗試 lldb,但在為 vscode 設置它時遇到了問題。
我首先創建默認的 launch.json 表單調試選項卡,選擇cpp gdb/lldb
然后clang++
進行配置。
當調試開始時..它顯示以下錯誤:
然后在 launch.json 我將miDebuggerPath
路徑形式/usr/bin/lldb-mi
更改為/usr/bin/lldb
。
然后,當我啟動調試器時,它什么也不做,只是在終端的頂部和以下行中調試控件:
warning: ignoring unknown option: --interpreter=mi
warning: ignoring unknown option: --tty=/dev/pts/1
我在這里想念什么?
我的整個launch.json
是:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "clang++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: clang++ build active file",
"miDebuggerPath": "/usr/bin/lldb"
}
]
}
lldb-mi
不是 LLDB 項目的一部分。 見lists.llvm.org
你仍然可以從項目的github repo自己構建它。 您需要首先構建 LLDB/Clang/LLVM,因為lldb-mi
編譯需要頭文件和編譯的庫才能按照 README 中所述的信息進行構建。
正如這個答案中提到的,並且在這里討論過,使用lldb-mi
可能不是最好的選擇。
lldb-vscode
( https://github.com/llvm/llvm-project/tree/main/lldb/tools/lldb-vscode ) 可以很好地在 linux 上使用 vscode 中的 lldb 進行調試,並且是 LLDB 項目的一部分。 以下是我用來(取自自述文件)在遠程 ssh vscode 服務器上設置它的步驟(假設存在 llvm 安裝):
# Create directory for a new VSCode extension $ mkdir -p ~/.vscode-server/extensions/llvm-org.lldb-vscode-0.1.0/bin # Copy the extension package.json from GitHub $ wget -P ~/.vscode-server/extensions/llvm-org.lldb-vscode-0.1.0/ https://raw.githubusercontent.com/llvm/llvm-project/main/lldb/tools/lldb-vscode/package.json # Copy the lldb-vscode binary to the bin directory $ cp $(which lldb-vscode) ~/.vscode-server/extensions/llvm-org.lldb-vscode-0.1.0/bin/ # also make sure all libraries are found by ldd for the copied lldb-vscode
現在在我的遠程主機上 vscode 的擴展選項卡下,顯示“LLDB native Debug stub”{ "version": "0.2.0", "configurations": [ { "name": "Launch lldb-vscode", "type": "lldb-vscode", "request": "launch", "program": "${command:cmake.launchTargetPath}", "args": [], "env": [], "cwd": "${workspaceFolder}", "stopOnEntry": false, "sourceMap": [["/path/a/", "/path/b"]] } ] }
CodeLLDB擴展在 Windows 10 中啟動的 Ubuntu docker 容器中完美運行。它建議了一些預定義的配置。
我在使用gdb
時遇到了問題,它在多線程應用程序上拋出了核心轉儲; lldb-vscode
還需要一些努力,正如Joe's answer的評論中所討論的那樣。
PS:容器有apt
安裝的gcc
clang
lldb
,也許它們是插件工作所必需的(也許不是)🙂
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.