您的位置:首页 > 其它

编译安装gdb+insight和gdbserver远程调试

2008-11-14 12:18 399 查看
http://blog.csdn.net/taina2008/archive/2008/09/25/2980432.aspx
编译安装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: *** [tk3d.o] 错误 1
安装libx11-dev可以解决问题<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了
=====================================================================
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: