編譯安裝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 CC=gcc422 --target=arm-linux --enable-sim --prefix=/usr/local
注意:這裡我指定的是我另外安裝的4.2.2版的gcc,如果用4.3的gcc會編譯出錯
<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 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了
=====================================================================
【注意:arm-linux-insight配置為
Connection選項卡:
Target: GDBserver/TCP
Hostname: 192.168.100.2
Port: 1000
More Options選項卡:
Run Options
*Attach to Target 選中
Download Program 取消
詳細資料如:
】
luther@gliethttp:~/arm$ arm-linux-insight hello