下载链接:ftp://sourceware.org/pub/gdb/releases/
1,编译gdb过程中需要使用texinfo, 先安装texinfo
sudo apt-get install texinfo
2,解压配置编译 arm-linux-gnueabihf端:--host=arm-linux-gnueabihf
windows:--host不用配置,默认即可
./configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- CC=arm-linux-gnueabihf-gcc --prefix=/home/alinx/gdb_install
--build:运行编译工具链的平台,也就是正在执行编译操作的平台。如果未指定此参数,则通过 config.guess 猜测得到。通常都不指定此参数。
--host:可执行程序将运行的平台。如果未指定此参数,则和 --build 相同。如果 --host 和 --build 不同,是交叉编译;否则是普通编译。
--target:可执行程序将处理的平台。如果未指定此参数,则和 --host 相同。一般来说,程序运行在什么平台,处理的就是什么平台,此参数值和 --host 参数相同,不需显式指定,所以通常不会关注到此参数。但在制作交叉编译工具 (如 gcc、gdb 等) 这种特殊情况下,此值和 --host 不同,例如交叉编译器 arm-linux-gcc,它运行在 x86-linux 平台 (--host 参数),但处理的是 arm-linux 平台 (--target 参数)。如果是交叉编译一个普通的应用,如运行于 arm-linux 平台的 tftp 程序,则它的运行平台和处理平台都是 arm-linux 平台
--program-prefix:指定将被加到所安装程序的名字上的前缀.例如,使用'--program-prefix=arm-linux-gnueabihf-'来configure,编译的gdb文件名为arm-linux-gnueabihf-gdb
--prefix:编译的时候用来指定程序存放路径 。不指定prefix,可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc。其它的资源文件放在/usr /local/share。
3,make make install
4,程序运行 ./gdbserver 172.27.226.141:5000 transdata
附录:petalinux2015.4 使用gdbserver方式: Adding GDB to the ROOTFS:
on target:
mount /dev/mmcblk0p1 /mnt/
ifconfig eth0 192.168.150.11
ping 192.168.150.243
gdbserver 192.168.150.243:2345 /mnt/linux_app.elf
on host:
aarch64-linux-gnu-gdb linux_app.elf
(gdb) target remote 192.168.150.11:2345
(gdb) break main
(gdb) continue
(gdb) continue