vscode 除錯linux程式
阿新 • • 發佈:2020-12-18
-
Remote SSH 連線到Linux伺服器
-
https://github.com/microsoft/vscode-cpptools/releases 下載cpptools-linux.vsix
-
載入擴充套件 (… --> Install from VSIX…)
-
選擇show Local載入下載的cpptools-linux.vsix等待安裝完成
-
開啟一個cpp檔案,F5 選擇編譯環境,選擇一個配置選項,.vs_code目錄下會生成launch.json和tasks.json 檔案
-
修改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": "g++ - Build and debug active file",
"type" : "cppdbg",
"request": "launch",
"program": "/media/sf_LinuxShare/build/test",//修改要啟動的執行程式名稱(絕對路徑)
"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++: g++ build active file",// 關閉編譯任務
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
- cmake 編譯新增除錯資訊,編譯軟體
cmake -DCMAKE_BUILD_TYPE=Debug
- vscode開啟cpp檔案,新增斷點,F5執行