参考博文:
https://blog.csdn.net/qq_36490086/article/details/85246107
本文主要是参考上述博主的文章的安装方法安装最新的的gdb9.2的步骤:
wget http://ftp.gnu.org/gnu/gdb/gdb-9.2.tar.xz
tar -xf gdb-9.2.tar.xz
cd gdb-9.2/
此时我们位于解压出的源码的目录,需要在当前目录下创建一个build目录以执行configure脚本,但是需要注意,configure的时候需要写上编译代码时用到的工具链 --target=arm-xxxx,如我当前使用的平台是RK3xxx,编译链是arm-rockchip-linux-gnueabihf ,步骤如下:
mkdir build
cd ./build
../configure --target=arm-rockchip-linux-gnueabihf
如果执行该配置脚本时没有指定编译工具链,则在gdb debug Core文件的时候出现如下问题:
warning: `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/libnetutils.so': Shared library architecture unknown is not compatible with target architecture i386.
warning: `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/libnetutils.so': Shared library architecture unknown is not compatible with target architecture i386.
Reading symbols from /xxxxxxxxxxxxxxx/libnetutils.so...
(gdb)
(gdb)
(gdb) break
No default breakpoint address now.
(gdb) backtrace
#0 <unavailable> in ?? ()
Backtrace stopped: not enough registers or memory available to unwind further
(gdb) q
然后脚本就会开始配置,终端开始打印一些log,这个脚本执行完毕后会在build目录下生成makefile:
该脚本执行完毕后,仍旧在build目录下执行make,以生成gdb执行文件
make
make完毕后在build文件夹下生成Makefile,执行sudo make install 编译出gdb
sudo make install
编译完毕后会生成gdb的二进制文件,拷贝到用户bin目录
sudo cp ./gdb/gdb /usr/local/bin/gdb
执行该句完毕后执行gdb -v查看是否安装成功,如安装成功,则有如下打印
GNU gdb (GDB) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.