Hello World

行走即是圆梦,回望亦是前行。

0%

RedHat5升级安装gdb-7.12教程

前言

这里简单记录下RedHat5升级安装gdb-7.12教程

gnu.gdb

安装环境

VMware® Workstation 16 Pro(16.0.0 build-16894299) + Red Hat5 32位

1
2
3
4
5
内存: 1GB
磁盘: 40GB
处理器内核数: 2
系统版本: Linux linuxas5 2.6.18-194.el5 #1 SMP Mon Mar 29 20:06:41 EDT 2010 i686 i686 i386 GNU/Linux
gdb 版本: GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5)

离线安装

  1. 下载gdb-7.12.1源码
  2. 新建目录gdb-7.12.1,将源码上传至目录下
    1
    $ mkdir /opt/gdb-7.12.1
  3. 进入到/opt/gdb-7.12.1下,解压源码
    1
    2
    $ cd /opt/gdb-7.12.1
    $ tar -xzvf gdb-7.12.1.tar.gz
  4. 创建编译目录build,执行配置命令configure生成Makefile,如果失败,可以查看config.log日志文件定位问题

这里需要增加--disable-werror参数,否则后面make会编译失败,如果需要指定python版本--with-python='/usr/local/bin/python3.5'

1
2
$ mkdir build && cd build
$ ../gdb-7.12.1/configure --disable-werror
  1. 执行make -j8进行编译,编译过程较慢,至少半小时以上,耐心等待即可,或可适当调整虚拟机处理器核心数
    1
    $ make -j8
  2. 执行make install进行安装(需要root权限),安装目录为/usr/local/bin
    1
    $ make install
  3. 创建软链接,替换系统的gdb程序,系统旧版本gdb(/usr/bin/gdb),可以使用which gdb查看具体目录
    1
    2
    $ mv /usr/bin/gdb /usr/bin/gdb.bak
    $ ln -s /usr/local/bin/gdb /usr/bin/gdb

版本测试

1
2
3
4
5
6
7
8
$ gdb -v
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 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. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".

如出现如下报错,注释掉/usr/local/share/gdb/python/gdb/command/unwinders.py中89行和141行的print即可,这里我选择升级python版本Python-3.5.10,安装步骤与本教程一致,安装成功后,安装步骤4中指定python版本--with-python='/usr/local/bin/python3.5'

1
2
3
4
5
6
7
Traceback (most recent call last):
File "/usr/local/share/gdb/python/gdb/__init__.py", line 144, in auto_load_packages
__import__(modname)
File "/usr/local/share/gdb/python/gdb/command/unwinders.py", line 90
"" if unwinder.enabled else " [disabled]"))
^
SyntaxError: invalid syntax