編譯安裝gdb+insight和gdbserver遠端偵錯

來源:互聯網
上載者:User
編譯安裝gdb+insight和gdbserver遠端偵錯arm開發板native應用程式

下載gdb-6.8.tar.bz2
http://ftp.cs.pu.edu.tw/Linux/sourceware/gdb/releases/
一.編譯安裝gdb
<1>luther@gliethttp:~/gdb-6.8$ ./configure --target=arm-linux --enable-sim --prefix=/usr/local
<2>luther@gliethttp:~/gdb-6.8$ make
<3>luther@gliethttp:~/gdb-6.8$ sudo make install
二.編譯安裝gdbserver
<1>luther@gliethttp:~/gdb-6.8/gdb/gdbserver$ ./configure --target=arm-linux --host=arm-linux
<2>luther@gliethttp:~/gdb-6.8/gdb/gdbserver$ make
   或者make CC=/usr/local/arm-linux/bin/arm-linux-gcc指定編譯器目錄
<3>這樣在gdb-6.8/gdb/gdbserver目錄下就產生了一個gdbserver可執行檔,拷貝到
   目標開發板上.
三.測試arm-linux-gdb + gdbserver
在minicom或者putty輸入:[192.168.100.1為pc機ip地址,2345為監聽連接埠]
<1>gdbserver 192.168.100.1:2345 hello
在pc機上輸入:[192.168.100.2為開發板ip地址]
<2>luther@gliethttp:~/ arm-linux-gdb hello 然後輸入
target remote 192.168.100.2:2345
這樣在開發板minicom或putty上可以看到如下提示資訊:
/ # ./gdbserver 192.168.100.1:2345 hello
Process wpa_cli created; pid = 730
Listening on port 2345
Remote debugging from host 192.168.100.1
=====================================================================
具體執行個體如下:
=====================================================================
pc端log或者使用arm-linux-gdbtui簡易圖形gdb終端
luther@gliethttp:~/arm$ arm-linux-gdb hello
GNU gdb 6.8
Copyright (C) 2008 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.100.2:2345
Remote debugging using 192.168.100.2:2345
[New Thread 1514]
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x400007e0 in ?? ()
(gdb) b main
Breakpoint 1 at 0x835c: file hello.c, line 6.
(gdb) l
1    #include <stdio.h>
2    
3    int main(int argc, char *argv[])
4    {
5        int i;
6        for(i = 0;i < 10;i++)
7        {
8            printf("%d/n", i);
9        }
10        return 0;
(gdb) c  不要輸入r,輸入c,因為target端的hello在載入時處於了run狀態.
Continuing.
warning: .dynamic section for "/lib/libc.so.6" is not at the expected address (wrong library or version mismatch?)
Error while mapping shared library sections:
/lib/ld-linux.so.3: No such file or directory.

Breakpoint 1, main (argc=1, argv=0xbeb4ad84) at hello.c:6
6        for(i = 0;i < 10;i++)
(gdb) n
8            printf("%d/n", i);
(gdb) n
6        for(i = 0;i < 10;i++)
(gdb) n
8            printf("%d/n", i);

(gdb)
=====================================================================
target板端log
/ # ./gdbserver 192.168.100.1:2345 hello
[ 3688.476398] init: untracked pid 1513 exited
Process hello created; pid = 1514
Listening on port 2345
Remote debugging from host 192.168.100.1
0

=====================================================================
也可以使用ddd -debugger arm-linux-gdb hello圖形化調試,
insight需要從源碼編譯才行:
<1>下載源碼insight-6.8.tar.bz2
http://sourceware.org/insight/
<2>luther@gliethttp:~/insight-6.8$ ./configure --target=arm-linux --enable-sim --prefix=/usr/local
<3>luther@gliethttp:~/insight-6.8$ make
<4>luther@gliethttp:~/insight-6.8$ sudo make install
編譯於insight配對的gdbserver
<1>luther@gliethttp:~/insight-6.8/gdb/gdbserver$ ./configure --target=arm-linux --host=arm-linux
<2>luther@gliethttp:~/insight-6.8/gdb/gdbserver$ make
啟動arm-linux-insight,因為arm-linux-insight依賴gdb,所以會自動編譯出arm-linux-gdb.
=====================================================================
具體執行個體如下:
luther@gliethttp:~/arm$ arm-linux-insight
ide_initialize_paths failed: Can't find the GUI Tcl library in the following directories:
    /home/usr/share/redhat/gui /home/share/redhat/gui /share/redhat/gui /usr/local/libgui/library /home/usr/share/redhat/ide /home/share/redhat/ide /share/redhat/ide /usr/local/libide/library
後來發現/usr/local/arm-linux/bin目錄下
lrwxrwxrwx 1 root root  32 2008-02-03 11:00 arm-linux-insight -> arm-iwmmxt-linux-gnueabi-insight
-rwxr-xr-x 1 root root 16M 2008-02-03 11:00 arm-iwmmxt-linux-gnueabi-insight
把它幹掉就ok了
=====================================================================

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.