第一步:安装arm-linux-gcc

这个网上很多,这里不再重复,开发板一般都自带有该工具。

第二步:安装eclipse插件:Zylin Embedded CDT

进入help菜单 -> Software Updates... -> Available Software -> Add Site
输入http://opensource.zylin.com/zylincdt,按提示进行安装;

第三步:编译、配置GDB Server & GDB Client 

首先在http://ftp.gnu.org/gnu/gdb/下载GDB的源代码,解压到/usr/local/arm-gdb/中。 

  
  
cd gdb - 7.6
.
/ configure -- target = arm - linux -- prefix = /usr/crosstool/GDB-7.6
make
make install

  如果出现如下错误:

configure: error: no termcap library found
make[1]: *** [configure-gdb] 错误 1
make[1]:正在离开目录 `/usr/local/arm-gdb/gdb-7.6'
make: *** [all] 错误 2 

则说明需要下载安装一个libncurses5-dev。

然后编译GDB Server 

cd /usr/local/arm-gdb/gdb/gdbserver
export PATH
=$PATH:/usr/local/arm-gdb/bin
.
/configure --target=arm-linux --host=arm-linux
make CC
=arm-linux-gcc
  
  

如果出现make错误,有可能是你的arm-linux-gcc版本太低造成的; 


第四步:在目标板上运行gdbserver

将编译生成的gdbserver和需要调试的可执行文件传到板子上
运行命令:gdbserver 192.168.1.102:2345 foo
其中192.168.1.102是远程主机的IP,2345是目标板使用的端口。foo是要调试的可执行文件。


第五步:配置eclipse,进行调试

进入Run菜单 -> Debug Configurations -> Zylin Embedded debug(Native)
新建一个调试配置
进入main选项卡,选择要调试的C/C++工程;
进入debugger选项卡,选择交叉编译的gdb的路径,例如我的是:/usr/crosstool/GDB-7.6/bin/arm-linux-gdb;
进入commands选项卡,在初始化命令里填写动态链接库目录、目标板的IP和端口:

set solib-absolute-prefix /home/nsqk/mini2440/rootfs_qtopia_qt4
set solib-search-path /home/nsqk/mini2440/rootfs_qtopia_qt4/lib
target remote 192.168.1.230:2345


其中rootfs_qtopia_qt4是交叉编译环境中的文件系统目录,两个“set”是为了防止调试时出现以下错误:

warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x400007c0 in ?? ()
warning: `/lib/libc.so.6': Shared library architecture unknown is not compatible with target architecture armv4t.
warning: Could not load shared library symbols for /lib/ld-linux.so.3.
Do you need "set solib-search-path" or "set sysroot"?

点击Debug按钮选择刚才设置好的调试项进行远程调试;




Logo

更多推荐