<var id="fnfpo"><source id="fnfpo"></source></var>
<rp id="fnfpo"></rp>

<em id="fnfpo"><object id="fnfpo"><input id="fnfpo"></input></object></em>
<em id="fnfpo"><acronym id="fnfpo"></acronym></em>
  • <th id="fnfpo"><track id="fnfpo"></track></th>
  • <progress id="fnfpo"><track id="fnfpo"></track></progress>
  • <tbody id="fnfpo"><pre id="fnfpo"></pre></tbody>

  • x
    x

    建立嵌入式gdb調試環境

    發布時間:2011-3-24 13:48    發布者:techshare
    關鍵詞: GDB , 調試環境 , 嵌入式
    一.下載gdb-6.4.tar.gz源代碼

    http://ftp.gnu.org/gnu/gdb/


    二.編譯 GDB

    #tar zxvf gdb-6.4.tar.gz


    2.1 編譯GDB Server

    #cd gdb-6.4

    #./configure --target=arm-linux --prefix=/usr/local/arm-gdb

    #make

    注意: 這里如果你用的是gcc-4.3.2的話,編譯可能會出錯!你可以改成 gcc-4.1 就可以順利編譯通過

    編譯ARM用的GDB時出現error: no termcap library found錯誤的解決方法2009年03月28日 星期六 21:55在Ubuntu下編譯gdb時出現如下錯誤:


    ........


    checking for library containing gethostbyname... none required

    checking for library containing socketpair... none required

    checking for library containing waddstr... no

    checking for library containing dlgetmodinfo... no

    checking for library containing tgetent... no

    configure: error: no termcap library found

    make[1]: *** [configure-gdb] 錯誤 1


    解決方法:sudo apt-get install libncurses5-dev


    安裝完后,在make就OK了!


    #make install // 生成/usr/local/arm-gdb/bin


    2.2 編譯GDB Client

    #cd ./gdb/gdbserver

    #export PATH=$PATH:/usr/local/arm-gdb/bin

    #./configure --target=arm-linux --host=arm-linux

    #vi config.h

    //#define HAVA_SYS_REG_H //注釋此句

    #make CC=arm-softfloat-linux-gnu-gcc //編譯用于目標機的stub程序 生成gdbserver是GDB客戶端程序,在板子上運行。


    三.實戰調試

    1.編輯文件

    # vi gdbtest.c

    1 #include <stdio.h>

    2

    3 int

    4 func(int n){

    5 int sum=0, i;

    6 for (i=0; i<n; i++){

    7 sum += i;

    8 }

    9 return sum;

    10 }

    11

    12 int

    13 main(void)

    14 {

    15 int i;

    16 long result = 0;

    17 for (i=0; i<=100; i++){

    18 result += i;

    19 }

    20

    21 printf("result[1-100] = %d \n", result);

    22 printf("resutl[1-225] = %d \n", func(255));

    23

    24 return 0;

    25 }

    # arm-linux-gcc -g gdbtest.c -o gdbtest // 交叉編譯

    2.下載文件到目標板: gdbtest和gdbserver

    假設 host pc ip:192.168.1.45

    board ip:192.168.1.180

    將文件拷貝到目標板上:

    先將gdbtest和gdbserver兩個文件拷貝到主機的/tftpboot目錄下

    在目標板的Linux中運行:

    #mount 192.168.1.108:/tftpboot /mnt/nfs

    #cd /mnt/nfs

    #ls

    看是否有gdbtest和gdbserver兩個文件。

    3.運行調試

    client board:

    #./gdbserver 192.168.1.45:1234 gdbtest // 目標板上運行gdbtest 監聽端口1234


    host pc:

    #cd /usr/local/arm-gdb/bin/

    #copy gdbtest /usr/local/arm-gdb/bin/ // 將前面編譯的文件gdbtest拷貝到此目錄

    #./arm-linux-gdb gdbtest

    (gdb)target remote 192.168.1.180:1234 // 連接到開發板 成功后就可以進行調試

    (gdb)list or l

    (gdb)break func

    (gdb)break 22

    (gdb)info br

    (gdb)continue or c // 這里不能用 run

    (gdb)next or n

    (gdb)print or p result

    (gdb) finish // 跳出func函數

    (gdb) next

    (gdb) quit

    建立連接后進行gdb遠程調試和gdb本地調試方法相同。
    本文地址:http://www.portaltwn.com/thread-59738-1-1.html     【打印本頁】

    本站部分文章為轉載或網友發布,目的在于傳遞和分享信息,并不代表本網贊同其觀點和對其真實性負責;文章版權歸原作者及原出處所有,如涉及作品內容、版權和其它問題,我們將根據著作權人的要求,第一時間更正或刪除。
    您需要登錄后才可以發表評論 登錄 | 立即注冊

    廠商推薦

    • Microchip視頻專區
    • EtherCAT®和Microchip LAN925x從站控制器介紹培訓教程
    • MPLAB®模擬設計器——在線電源解決方案,加速設計
    • 讓您的模擬設計靈感,化為觸手可及的現實
    • 深度體驗Microchip自動輔助駕駛應用方案——2025巡展開啟報名!
    • 貿澤電子(Mouser)專區

    相關視頻

    關于我們  -  服務條款  -  使用指南  -  站點地圖  -  友情鏈接  -  聯系我們
    電子工程網 © 版權所有   京ICP備16069177號 | 京公網安備11010502021702
    快速回復 返回頂部 返回列表
    精品一区二区三区自拍图片区_国产成人亚洲精品_亚洲Va欧美va国产综合888_久久亚洲国产精品五月天婷