搜尋
首頁開發工具VSCodevscode如何使用gdb調試

vscode如何使用gdb調試

Feb 12, 2020 pm 02:00 PM
gdbvscode

vscode如何使用gdb調試

1、vscode啟動debug視窗

按Ctrl Shift D,開啟Debug視窗

預設是“No configurations”, 點選“F5”,會提示你設定GDB參數(選擇gcc build and debug active file),設定檔名稱為launch.json(設定參考3)

設定完成後,再按F5, 會提示設定GCC,選擇「Configure Task”,選擇“C/C : build and debug active file”, 設定檔名稱為task.json(設定參考2)

2、GCC設定

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "gcc build active file",
            "command": "/usr/share/mips-gcc-4.6/staging_dir/bin/mips-linux-gcc",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ]
        }
    ]
}

“command”: 編譯鏈的位址

3、GDB配置

{
    // 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": "gcc build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "miDebuggerServerAddress": "192.168.0.1:10000",
            "program": "/home/renyinshan/work/p53/apps/cmdlib/test",
            "args": [],
            "stopAtEntry": true,
            "cwd": "/home/renyinshan/work/p53/apps/cmdlib/",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc build active file",
            "miDebuggerPath": "/home/renyinshan/work/p53/apps/gdb/install/bin/mips-linux-gdb"
        }
    ]
}

“program”: 要調試的程式名稱(包含路徑,最好絕對路徑,免得麻煩)

“miDebuggerServerAddress” : 伺服器的位址與連接埠

「cwd」: 偵錯程度的路徑

「miDebuggerPath」: gdb的路徑

4、GDB server編譯及執行

1)編譯

P53編譯時,請開啟下列開關; P59需要從編譯鏈目錄拷貝一個。

scripts/tozedap-router_4g_industry/config.tozedap-router_4g_industry:564:export NO_CPP_LIB=0

GDB运行需要libstdc++.so.6的库,所以需要把此开关打开。
./cool 3 gdb_build

等待完成即可

編譯完成後的檔案如下:

renyinshan@renyinshan:~/work/p53/build$ ls ../apps/gdb/install/*
../apps/gdb/install/bin:
mips-linux-gdb  mips-linux-gdb-add-index  mips-linux-run

../apps/gdb/install/include:
gdb

../apps/gdb/install/lib:
libmips-linux-sim.a

../apps/gdb/install/share:
gdb  info  locale  man

renyinshan@renyinshan:~/work/p53/build$ ls ../apps/gdb/installgdbserver/bin/
mips-linux-gdbserver
renyinshan@renyinshan:~/work/p53/build$

說明:

install/bin 目錄的mips-linux-gdb為vscode中設定所需的;

installgdbserver/bin/ 目錄中的mips-linux-gdbserver,需要拷貝到板子中;

2)ssh登入設備,下載gdbserver到/tmp目錄中,並增加x權限

#3)ssh登入設備,下載可執行程式到/tmp目錄中, 並增加x權限

4)運行

/tmp # ./mips-linux-gdbserver :10000 ./test

调试输出:

/tmp # ./mips-linux-gdbserver :10000 test 
Process /tmp/test created; pid = 22608
Listening on port 10000
Remote debugging from host 192.168.0.245
APP is running!

備註說明:
1) 下載的可執行程序,必須保證是設備所需編譯鏈編譯的;
2) vscode中按F5調試時,GCC編譯的配置和GDB參考1和2;

5、調試

準備完成, 在VSCode進行調試。

相關推薦:vscode教學

#

以上是vscode如何使用gdb調試的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
vscode如何格式化jsonvscode如何格式化jsonApr 16, 2025 am 07:54 AM

在 VS Code 中格式化 JSON 的方法有:1. 使用快捷鍵 (Windows/Linux:Ctrl Shift I;macOS:Cmd Shift I);2. 通過菜單(“編輯” > “格式化文檔”);3. 安裝 JSON 格式化程序擴展(如 Prettier);4. 手動格式化(使用快捷鍵縮進/縮出塊或添加花括號和分號);5. 使用外部工具(如 JSONLint 和 JSON Formatter)。

vscode如何編譯vscode如何編譯Apr 16, 2025 am 07:51 AM

在 VSCode 中編譯代碼分 5 步:安裝 C 擴展;在項目文件夾中創建 "main.cpp" 文件;配置編譯器(如 MinGW);使用快捷鍵("Ctrl Shift B")或 "Build" 按鈕編譯代碼;使用快捷鍵("F5")或 "Run" 按鈕運行編譯後的程序。

vscode如何安裝vscode如何安裝Apr 16, 2025 am 07:48 AM

要安裝 Visual Studio Code,請按以下步驟操作:訪問官方網站 https://code.visualstudio.com/;根據操作系統下載安裝程序;運行安裝程序;接受許可協議並選擇安裝路徑;安裝完成後,VSCode 將自動啟動。

vscode如何放大字體vscode如何放大字體Apr 16, 2025 am 07:45 AM

在 Visual Studio Code 中放大字體的方法有:打開設置面板(Ctrl , 或 Cmd ,)。搜索並調整“Font Size”。選擇具有適合大小的“Font Family”。安裝或選擇提供合適大小的主題。使用鍵盤快捷鍵(Ctrl 或 Cmd )放大字體。

vscode如何連接遠程服務器vscode如何連接遠程服務器Apr 16, 2025 am 07:42 AM

如何通過 VSCode 連接遠程服務器?安裝 Remote - SSH 擴展配置 SSH在 VSCode 中創建連接輸入連接信息:主機、用戶名、端口、SSH 密鑰在 Remote Explorer 中雙擊已保存的連接

vscode如何運行vuevscode如何運行vueApr 16, 2025 am 07:39 AM

在 VSCode 中運行 Vue 項目需要以下步驟:1. 安裝 Vue CLI;2. 創建 Vue 項目;3. 切換到項目目錄;4. 安裝項目依賴;5. 運行開發服務器;6. 打開瀏覽器訪問 http://localhost:8080。

vscode如何比較兩個文件vscode如何比較兩個文件Apr 16, 2025 am 07:36 AM

VSCode 中比較文件的方法:1. 打開兩個文件,2. 啟用“差異”視圖(“視圖”菜單),3. 查看差異(新增綠色、刪除紅色、修改紫色),4. 使用箭頭鍵導航,5. 接受或拒絕更改。附加功能包括合併更改、複製更改、查看詳細信息和編輯差異。

vscode如何運行js代碼vscode如何運行js代碼Apr 16, 2025 am 07:33 AM

如何在 VSCode 中運行 JS 代碼?創建.js文件並編寫代碼;安裝 Node.js 和 npm;安裝Debugger for Chrome;打開調試控制台;選擇Chrome;添加調試配置;設置調試腳本;運行代碼;調試代碼(可選)。

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
4 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
4 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
1 個月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.聊天命令以及如何使用它們
1 個月前By尊渡假赌尊渡假赌尊渡假赌

熱工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

將Eclipse與SAP NetWeaver應用伺服器整合。

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境