linux应用程序调试gdb+gdbserver

来源:互联网 发布:linux中rpm文件 编辑:程序博客网 时间:2024/06/05 15:25

rlx平台

在目标板子上gdbserver ip:port /bin/xxx
在pc上xxxx/xxx-linux-gdb /bin/xxx,进入gdb后target remote ip:port开始进行gdb调试

如果发现出现no debugging symbols found的时候,需要在编译的地方加-g选项,并且make menuconfig中按照如下设置,
[*] Enable debug symbols (-g)
[*] Disable symbol stripping support


arm平台

同样,在arm平台上也需要交叉编译过的gdb和gdbserver
下载最新版本的gdb-6.8.tar.gz,可以到ftp://ftp.gnu.org/gnu/gdb下载.
准备好自己的工作目录,如下示

/home/user/gdb            |--gdb-6.8            |--obj-gdb                    |--build            |--obj-gdbserver                    |--build            |--bin

脚本obj-gdb/build内容如下:

#!/bin/sh../gdb-6.8/configure --target=arm-linux --enable-shared --prefix=/usr/src/arm/gdb/build-gdb --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettextmakeecho "done"

脚本obj-gdbserver/build内容如下:

#!/bin/shCC=/opt/toolchain/arm-linux/bin/arm-linux-gcc../gdb-6.8/gdb/gdbserver/configure --host=arm-linux --without-included-regex --without-included-gettextecho "done"

开始编译:
(1) cd obj-gdb
./build
(2) cd obj-gdbserver
./build
这时会生成Makefile,修改Makefile如下
LDFLAGS= -static
然后make
(3) cd bin
cp ../obj-gdb/gdb/gdb .
cp ../obj-gdbserver/gdbserver .
arm-linux-strip gdbserver
(4) 好了bin目录下就是最终编译出来的gdb+gdbserver了

gdbserver使用:
(1) 目标机中
执行命令gdbserver 10.0.12.144:1234 test
注意test在编译的时候是要加-g选项的
(2) 宿主机中
gdb test
再输入命令target remote 10.0.12.143:1234
接下来就可以gdb的调试了
(3) 说明
目标机IP:10.0.12.143
宿主机IP: 10.0.12.144
端口是随意指定的,只要两端保持一致就行了
test程序两端也必须相同(stavy)


参考文章

  1. 嵌入式arm linux环境中gdb+gdbserver调试
0 0
原创粉丝点击