mini2440 gdb遠端偵錯

來源:互聯網
上載者:User

  

我編譯gdb和gdbserver是參照以下文章做的當中編譯的時候遇到了三類主要錯誤:

 

錯誤1:

./configure 是的錯誤,這一類錯誤主要是主機上面缺少軟體和庫導致,一次安裝相應的庫和軟體即可

錯誤2:

make 時的錯誤, 主要是編譯錯誤。找出錯誤碼修改即可。這一類代碼錯誤通常都是很簡單的錯誤,由於作者用的源碼編譯器或者編譯器一樣但編譯器編譯配置不一樣導致(主要是兩類錯誤:1.變數未初始化錯誤  2. 函數傳回值未處理錯誤)

 錯誤3:

在編譯gdb server 的時候總是有錯誤:

解決方案:需要再gdb-server 下makeclearn 在重新./configure一下

主機和開發板調試串連通訊設定:

開發板端----

 [root@FriendlyARM hello]# ../gdbserver 10.11.11.101:7777 hello

../gdbserver  --編譯好的GDBserver

10.11.11.101 --主機ip地址

hello -- 編譯的可執行程式

pc端----

首先運行arm-linux-gdb

在arm-linux-gdb 輸入target remote 10.11.11.230:7777

10.11.11.230 --開發板IP

7777 通訊所用連接埠號碼

 

 本文系本站原創,歡迎轉載!

轉載請註明出處:http://sjj0412.cublog.cn/--------------------------------------------------------前幾天搞qtopia,編譯成功,下載到mini2440開發板運行,螢幕沒反應,然後就是segment error,感覺無從下手,決定搞
gdb遠端偵錯,記得大四的時候搞過一次,沒成功,後來也就沒搞了,這次沒辦法,下定決定搞好,在網上查了下資料,沒
想到輕鬆搞定,當然期間肯定有些錯誤,但是這些都是小事,很快搞定了,下面說下過程。
1.下載源碼,我下的是gdb-6.6
大家可以在下面的網址下載
http://www.gnu.org/software/gdb/download/
2. 解壓到~/source目錄下,這個目錄隨便你選擇
#tar xzvf gdb-6.6.tar.gz -C ~/source
cd ~/source
可以看到gdb-6.6
然後cd gdb-6.6
然後編譯宿主gdb,及目標板gdbserver
一般如果你安裝了arm cross交叉編譯鏈,就會有arm-linux-gdb,也就不用編譯宿主gdb,但是為了保證相容,還是編譯吧。
3,編譯宿主gdb
   首先建一個編譯目錄
   mkdir -p ~/armgdb/build
   cd ~/armgdb/build
   ~/source/gdb-6.6/configure --target=arm-linux --prefix=/home/jimmy/armgdb(注意這個要用絕對路徑,不能用~)
   然後make,make install
   這樣就可以在~/armgdb的bin下看到arm-linux-gdb及其他檔案。
4.編譯arm-linux-gdbserver
     編譯server的源碼檔案要變,在gdb/gdbserver裡
     進入這個檔案夾
     cd ~/source/gdb-6.6/gdb/gdbserver
     ./configure --host=arm-linux --target=arm-linux --prefix=/home/jimmy/armgdb/gdbserver
     make CC=你的交叉編譯鏈路徑(x/bin/arm-linux-gcc),如果已經加入PATH環境變數,則使用arm-linux-gcc
     make install
   然後就在~/armgdb/gdbserver/bin看到arm-linux-gdbserver
    這個對於不等於不同版本的交叉編譯鏈,可能會出錯,如果在編譯arm-linux-low.c這個檔案時提示找不到“sys/reg.h”, 則修改arm-linux-low.c,注釋掉#include "sys/reg.h"。
 如果是其他的問題,又找不到,那就換交叉編譯鏈,我的3.4.2沒問題,4.3.2隻有上面這個問題。

然後下載到目標板即可,啟動並執行時候會出問題,會說libthread_db.so.1找不到,這時可以在/usr/local/arm/3.4.1/arm-linux/lib將這個檔案下載到
目標板上去即可,一般放到/lib目錄,如果你放到其他目錄,要將其加到LD_LIBRARY_PATH環境變數裡。
5.調試
1.使用gdbserver
在目標板上運行gdbserver
在目標板上執行
#./gdbserver 192.168.1.230:7777 hello
其中192.168.1.230為目標板的IP。7777為gdbserver開啟的連接埠,可以自己設定。

2. 運行gdb用戶端
jimmy@jimmy-linux:/mnt/nfs/bin$ arm-linux-gdb hello
GNU gdb 6.6
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-linux"...
(gdb) target remote 192.168.1.230:7777
Remote debugging using 192.168.1.230:7777
0x40000dd0 in ?? () from /lib/ld-linux.so.2
(gdb) b main
Breakpoint 1 at 0x84a0: file hello.c, line 3.

(gdb) l
1 #include<stdio.h>
2 int main(){
3     int i=0;
4     i++;
5     printf("%d\n",i);
6 }
(gdb) b main
Breakpoint 1 at 0x84a0: file hello.c, line 3.
(gdb) c
Continuing.

Breakpoint 1, main () at hello.c:3
3     int i=0;
(gdb) n
4     i++;
(gdb) n
5     printf("%d\n",i);
(gdb)

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.