• Linux之gdb安装和升级


    一、前言

      GDB是linux环境下的程序调试工具。一般来说,GDB主要帮助你完成下面四个方面的功能:

    • 1、启动你的程序,可以按照你的自定义的要求随心所欲的运行程序。
    • 2、可让被调试的程序在你所指定的调置的断点处停住。(断点可以是条件表达式)
    • 3、当程序被停住时,可以检查此时你的程序中所发生的事。
    • 4、你可以改变你的程序,将一个BUG产生的影响修正从而测试其他BUG。
        升级glibc的时候需要升级gdb版本,源码升级gdb的时候各种报错,博主觉得此升级过程足够单独成文展现。环境说明:
    • 操作系统:centos7.6
    • gdb版本:升级前7.6.1,升级后7.8

    二、安装

    1、yum安装

    [root@s142 gdb-7.8]# yum install -y gdb

    2、查看gdb版本

    [root@s142 gdb-7.8]# gdb -v
    GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
    Copyright © 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later

    三、升级步骤

    1、下载待升级的gdb版本

    [root@s142 opt]# wget http://ftp.gnu.org/gnu/gdb/gdb-7.8.tar.gz

    2、解压软件包

    [root@s142 opt]# tar -zxvf gdb-7.8.tar.gz

    3、修改授权

    [root@s142 opt]# chown -R root.root gdb-7.8

    4、预编译

    [root@s142 gdb-7.8]# mkdir build
    [root@s142 build]# …/configure --prefix=/usr

    configure: creating ./config.status
    config.status: creating Makefile

    5、编译

      遇到预编译或者编译报错,请参照QA章节处理。

    [root@s142 build]# make
    make[4]: Leaving directory `/opt/gdb-7.8/build/gdb/build-gnulib’
    make[3]: Leaving directory `/opt/gdb-7.8/build/gdb’
    make[2]: Leaving directory `/opt/gdb-7.8/build/gdb’
    make[1]: Nothing to be done for `all-target’.
    make[1]: Leaving directory `/opt/gdb-7.8/build’

    6、编译安装

    [root@s142 build]# make install

    make[2]: Leaving directory `/opt/gdb-7.8/build/gdb’
    make[1]: Nothing to be done for `install-target’.
    make[1]: Leaving directory `/opt/gdb-7.8/build’

    7、查看升级后的版本

    在这里插入图片描述

    [root@s142 build]# gdb -v
    GNU gdb (GDB) 7.8

    四、QA

    1、预编译的时候报错no acceptable C compiler found in $PATH

    • 报错信息:configure: error: no acceptable C compiler found in $PATH
    • 报错原因:未安装gcc
    • 解决方案:yum install -y gcc*

    2、make的时候报错[all-bfd] Error

    • 报错信息:make[3]: *** [bfd.info] Error 1
    • 报错原因:没有安装texinfo模块
    • 解决方案:yum install -y texinfo,然后重新执行预编译步骤

    3、make的时候报错

    • 报错信息:no termcap library found
    • 报错原因:没有安装termcap
    • 解决方案:源码安装termcap
      #下载termcap软件包
      [root@s142 opt]# wget https://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz --no-check-certificate
      #解压软件包
      [root@s142 opt]# tar -zxvf termcap-1.3.1.tar.gz
      #修改属主
      [root@s142 opt]# chown -R root.root termcap-1.3.1
      #预编译
      [root@s142 termcap-1.3.1]# ./configure --prefix=/usr
      #编译
      [root@s142 termcap-1.3.1]# make
      #编译安装
      [root@s142 termcap-1.3.1]# make install
  • 相关阅读:
    【视觉SLAM十四讲学习笔记】第三讲——旋转矩阵
    kotlin coroutine源码解析之coroutineContext篇
    yolox小计
    第三方支付接口响应超时处理方法【杭州多测师】【杭州多测师_王sir】
    YOLOv8推理详解及部署实现
    2023NOIP A层联测10-最小生成树
    html5期末大作业 基于HTML+CSS制作dr钻戒官网5个页面 企业网站制作
    LLM评估标准有哪些?
    C#:实现二路归并排序算法(附完整源码)
    Vue+elementUI 导出word打印
  • 原文地址:https://blog.csdn.net/carefree2005/article/details/125068985