Emacs+GDB远程调试ARM-LINUX程序

来源:互联网 发布:linux pip安装 编辑:程序博客网 时间:2024/05/16 15:25
 

首先我们需要为arm-linux目标平台编译gdb和gdbserver,根据宿主机gdb的版本(比如我的rhel5.5上的gdb版本是6.8)在http://www.gnu.org/software/gdb现在对应版本的源代码。 解压到/opt目录下,详细的编译指令如下:
#cd /opt
#tar xzvf /root/gdb-6.8.tar.gz
#cd gdb-6.8
#./configure --target=arm-linux --prefix=/usr/local/arm/4.3.2
#make
#make install
 prefix指定了编译结果的存放位置,也就是安装目录。下面开始交叉编译gdbserver:
#cd /opt/gdb-6.8/gdb/gdbserver
#./configure --target=arm-linux --host=arm-linux --prefix=/usr/local/arm/4.3.2/arm-linux

#make
#make install
 完成了gdb和gdbserver的编译后,将arm-linux-gdbserver和待调试的程序放置到目标板的nfs挂载点如我配置的/nfsroot,arm-linux-gdbserver依赖库libthread_db-1.0.so,请在arm-linux工具链中拷贝到/nfsroot相关目录,大致结构如下:

 

进行下例操作前先交叉编译好hello程序,使用arm-linux-gcc -g -o hello hello.c;目标板里运行如下命令开启gdbserver:

# cat ./nfs
cat ./nfs
#!/bin/sh
mount -o nolock 192.168.1.1:/nfsroot /home
ln -s /home/lib /lib
# cat /home/gdbs
cat /home/gdbs
./arm-linux-gdbserver 192.168.1.2:1234 hello

# cd /home/
cd /home/
# ls
ls
ace_test.cpp hello gdbs~
txt hello.c ace_test
arm-linux-gdbserver a.out txt~
libbak支持ACE gdbs lib.tar.gz
lib hello.c~
# ./gdbs
./gdbs
Process hello created; pid = 52
Listening on port 1234
Remote debugging from host 192.168.1.1

这样gdbserver在目标系统里面运行起来了,他监视1234端口,调试hello程序。宿主机里在emacs里调出gdb调试命令行,输入arm-linux-gdb --annotate=3 hello,即可开始arm程序hello的远程调试了!见下图:

程序的输出在目标板的调试口,现在我统一了linux和嵌入式linux程序编写和调试环境,采用emacs编写代码,采用gdb调试程序!后续打算将sqllite和gtk+2.0引入到嵌入式linux的开发中来。

 

原创粉丝点击