下載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