Chinaunix首页 | 论坛 | 博客
  • 博客访问: 608739
  • 博文数量: 262
  • 博客积分: 8433
  • 博客等级: 中将
  • 技术积分: 2141
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-31 09:37
文章分类

全部博文(262)

文章存档

2012年(1)

2011年(168)

2010年(92)

2009年(1)

分类: 嵌入式

2010-12-17 11:02:17

编译安装gdb+insight和gdbserver远程调试arm开发板native应用程序

下载gdb-6.8.tar.bz2

一.编译安装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 <
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
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

<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

阅读(713) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~