七、Ubuntu系统上gdb工具编译

33 篇文章 1 订阅
15 篇文章 5 订阅

     本文编译的gdb版本为8.3。

一、系统编译环境搭建

编译之前请自行安装gcc等相关编译环境,而且还要安装 texinfo 这个工具,否则会出现如下错误

/home/jack/Downloads/gdb-8.3/missing: 81: /home/jack/Downloads/gdb-8.3/missing: makeinfo: not found
WARNING: 'makeinfo' is missing on your system.
         You should only need it if you modified a '.texi' file, or
         any other file indirectly affecting the aspect of the manual.
         You might want to install the Texinfo package:
         <http://www.gnu.org/software/texinfo/>
         The spurious makeinfo call might also be the consequence of
         using a buggy 'make' (AIX, DU, IRIX), in which case you might
         want to install GNU make:
         <http://www.gnu.org/software/make/>
Makefile:486: recipe for target 'gdb.info' failed
make[5]: *** [gdb.info] Error 127
make[5]: Leaving directory '/home/jack/Downloads/gdb-8.3/gdb/doc'
Makefile:1994: recipe for target 'subdir_do' failed
make[4]: *** [subdir_do] Error 1
make[4]: Leaving directory '/home/jack/Downloads/gdb-8.3/gdb'
Makefile:1752: recipe for target 'install-only' failed
make[3]: *** [install-only] Error 2
make[3]: Leaving directory '/home/jack/Downloads/gdb-8.3/gdb'
Makefile:1749: recipe for target 'install' failed
make[2]: *** [install] Error 2
make[2]: Leaving directory '/home/jack/Downloads/gdb-8.3/gdb'
Makefile:9155: recipe for target 'install-gdb' failed
make[1]: *** [install-gdb] Error 2
make[1]: Leaving directory '/home/jack/Downloads/gdb-8.3'
Makefile:2222: recipe for target 'install' failed
make: *** [install] Error 2

    执行以下命令安装即可

sudo apt-get install texinfo

二、GDB源代码修改  

    环境安装成功后,将源代码解压出来

tar -zxvf ./gdb-8.3.tar.gz

如果要进行gdb远程调试,则需要对remote.c文件中的代码进行修改。 

  if (buf_len > 2 * rsa->sizeof_g_packet)

    error (_("Remote 'g' packet reply is too long (expected %ld bytes, got %d "
	     "bytes): %s"),
	   rsa->sizeof_g_packet, buf_len / 2,
	   rs->buf.data ());

修改为

#if 0
  if (buf_len > 2 * rsa->sizeof_g_packet)

    error (_("Remote 'g' packet reply is too long (expected %ld bytes, got %d "
	     "bytes): %s"),
	   rsa->sizeof_g_packet, buf_len / 2,
	   rs->buf.data ());
#else
 if (buf_len > 2 * rsa->sizeof_g_packet) {
    rsa->sizeof_g_packet = buf_len;
    for (i = 0; i < gdbarch_num_regs(gdbarch); i++) {
        if (rsa->regs[i].pnum == -1)    
            continue;
        if (rsa->regs[i].offset >= rsa->sizeof_g_packet)
            rsa->regs[i].in_g_packet = 0;
        else
            rsa->regs[i].in_g_packet = 1;
    }
  }
#endif

三、配置脚本及编译安装

   执行如下指令

./configure --target=arm-linux --program-prefix=arm-linux- --prefix=`pwd`/output/
make && make install

  如无问题,在gdb的编译目录下面可以看到output文件夹,相关的执行文件在这里面。

 

四、未解之谜

   目前发现如果使用git管理gdb源代码(从gitlab仓库中拉取代码),然后通过步骤三进行编译,会出现报错,而且这些错误都是随机的。

   解决方式,通过解压 gdb-8.3.tar.gz 这个压缩包覆盖仓库代码(被修改过的文件,无需覆盖),然后重新编译即可。

 

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值