VSCode 搭建 Arm 遠端除錯環境的步驟詳解
阿新 • • 發佈:2020-04-04
簡介
前提條件:
- 確保本機已經安裝 VS Code。
- 確保本機已安裝 SSH client,並且確保遠端主機已安裝 SSH server。
- VSCode 已經安裝了外掛 C/C++。
本次搭建的環境:
- 主機:windows 10
- 伺服器:ubuntu 16.04
- VSCode 版本:February 2020 (version 1.43)
- Arm:海思 3559A (已配置好編譯工具鏈和 gdb server)
連線遠端主機
Remote Development
首先安裝 Remote Development 外掛,安裝完成之後:
如上圖所示,輸入:Remote-SSH:Connect to Host->Configure SSH Hosts->選擇一個config,配置資訊:
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host Server
HostName 10.10.1.111
User name
其中:
- Host: 遠端主機名稱。
- HostName: 遠端主機 IP。
- User: 連線使用者名稱。
輸入完畢後儲存,左側會出現配置好的資訊,右鍵登陸,可能需要密碼:
外掛安裝
連線到 server 後會發現,安裝的外掛分為兩欄,可以在遠端伺服器安裝需要的外掛:
遠端主機命令列
Ctrl + ~ 開啟終端視窗,VS Code 連線到遠端主機後,就可以直接使用終端視窗在遠端主機上執行終端命令。
arm 遠端除錯
VSCode 配置
配置 gdb 的配置檔案 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": [ { "type": "cppdbg","request": "launch","name": "Debug for test","skipFiles": [ "<node_internals>/**" ],"args": [],"program": "${workspaceFolder}/build/bin/test.debug","stopAtEntry": false,"cwd": "${workspaceFolder}","externalConsole": true,"MIMode": "gdb","setupCommands": [ { "description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true } ],"miDebuggerPath":"/opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin/aarch64-himix100-linux-gdb","miDebuggerServerAddress": "192.168.172.110:1234" } ] }
- type:除錯的型別
- name:配置檔案的名字
- request:配置檔案的請求型別,有 launch 和 attach 兩種,具體看官方文件
- program:可執行檔案的路徑和檔名稱
- args:主函式呼叫時傳入的引數
- stopAtEntry:設為true時程式將暫停在程式入口處
- cwd:除錯時的工作目錄
- externalConsole:除錯時是否顯示控制檯視窗
- MIMode:指定 VS Code 連線的偵錯程式,必須為 gdb 或者 lldb
- miDebuggerPath:偵錯程式路徑
- miDebuggerServerAddress: 板子 ip
arm 上執行 gdb server
./gdbserver :1234 test.debug
開始除錯
VSCode 按 F5 開始除錯:
斷點設定,變數、棧檢視:
總結
到此這篇關於VSCode 搭建 Arm 遠端除錯環境的步驟詳解的文章就介紹到這了,更多相關VSCode Arm 遠端除錯環境內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!