Linux gdb调试的时候没有对应的c调试信息库怎么办?

简介: Linux gdb调试的时候没有对应的c调试信息库怎么办?

gdb 调试报错:Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.6.x86_64

在centos7上面gdb调试程序时候,报错信息是:

Missing separate debuginfos, use: debuginfo-install glibc-2.17-157.el7_3.5.x86_64

解决方案:

1 先修改"/etc/yum.repos.d/CentOS-Debuginfo.repo"文件的 enable=1;有时候该文件不存在,则需要手工创建此文件并加入以下内容:

[debug]
name=CentOS-7 - Debuginfo
baseurl=http://debuginfo.centos.org/7/$basearch/ 
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7 
enabled=1

2 执行 sudo yum install -y glibc

3 执行 debuginfo-install glibc

[root@master Code]# gdb ./a.out 
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
Copyright (C) 2013 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 "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/Code/a.out...done.
(gdb) set args 9191
(gdb) r
Starting program: /root/Code/./a.out 9191
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff6fd2700 (LWP 13317)]
[Thread 0x7ffff6fd2700 (LWP 13317) exited]
[New Thread 0x7ffff6fd2700 (LWP 13318)]
[New Thread 0x7ffff67d1700 (LWP 13319)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6fd2700 (LWP 13318)]
0x00007ffff706ced7 in __strcpy_sse2_unaligned () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.5.x86_64 libgcc-4.8.5-39.el7.x86_64 libstdc++-4.8.5-39.el7.x86_64

这里就说明了没有对应的调试信息库

安装实录
[root@master Code]# cat /etc/yum.repos.d/CentOS-Debuginfo.repo 
# CentOS-Debug.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#

# All debug packages from all the various CentOS-7 releases
# are merged into a single repo, split by BaseArch
#
# Note: packages in the debuginfo repo are currently not signed
#

[base-debuginfo]
name=CentOS-7 - Debuginfo
baseurl=http://debuginfo.centos.org/7/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
enabled=0
#
[root@master Code]# vi /etc/yum.repos.d/CentOS-Debuginfo.repo 
[root@master Code]# cat /etc/yum.repos.d/CentOS-Debuginfo.repo 
# CentOS-Debug.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#

# All debug packages from all the various CentOS-7 releases
# are merged into a single repo, split by BaseArch
#
# Note: packages in the debuginfo repo are currently not signed
#

[base-debuginfo]
name=CentOS-7 - Debuginfo
baseurl=http://debuginfo.centos.org/7/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
enabled=1
#
[root@master Code]# yum install -y glibc
Loaded plugins: fastestmirror
base                                                    | 3.6 kB     00:00     
base-debuginfo                                          | 2.5 kB     00:00     
clickhouse-stable/signature                             |  821 B     00:00     
clickhouse-stable/signature                             | 1.4 kB     00:00 !!! 
docker-ce-stable                                        | 3.5 kB     00:00     
emqx-stable                                             | 2.9 kB     00:00     
epel/x86_64/metalink                                    | 9.9 kB     00:00     
epel                                                    | 4.7 kB     00:00     
extras                                                  | 2.9 kB     00:00     
kubernetes                                              | 1.4 kB     00:00     
updates                                                 | 2.9 kB     00:00     
(1/7): epel/x86_64/updateinfo                             | 1.1 MB   00:00     
(2/7): epel/x86_64/primary_db                             | 7.0 MB   00:00     
(3/7): docker-ce-stable/x86_64/primary_db                 |  80 kB   00:00     
(4/7): kubernetes/primary                                 | 111 kB   00:00     
(5/7): updates/7/x86_64/primary_db                        |  16 MB   00:00     
(6/7): clickhouse-stable/primary                          |  17 kB   00:01     
(7/7): base-debuginfo/x86_64/primary_db                   | 2.7 MB   00:03     
Determining fastest mirrors
 * base: mirrors.bupt.edu.cn
 * epel: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
clickhouse-stable                                                      131/131
kubernetes                                                             823/823
Resolving Dependencies
--> Running transaction check
---> Package glibc.x86_64 0:2.17-260.el7_6.5 will be updated
--> Processing Dependency: glibc = 2.17-260.el7_6.5 for package: glibc-headers-2.17-260.el7_6.5.x86_64
--> Processing Dependency: glibc = 2.17-260.el7_6.5 for package: glibc-devel-2.17-260.el7_6.5.x86_64
--> Processing Dependency: glibc = 2.17-260.el7_6.5 for package: glibc-common-2.17-260.el7_6.5.x86_64
---> Package glibc.x86_64 0:2.17-326.el7_9 will be an update
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-260.el7_6.5 will be updated
---> Package glibc-common.x86_64 0:2.17-326.el7_9 will be an update
---> Package glibc-devel.x86_64 0:2.17-260.el7_6.5 will be updated
---> Package glibc-devel.x86_64 0:2.17-326.el7_9 will be an update
---> Package glibc-headers.x86_64 0:2.17-260.el7_6.5 will be updated
---> Package glibc-headers.x86_64 0:2.17-326.el7_9 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================
 Package              Arch          Version               Repository      Size
===============================================================================
Updating:
 glibc                x86_64        2.17-326.el7_9        updates        3.6 M
Updating for dependencies:
 glibc-common         x86_64        2.17-326.el7_9        updates         12 M
 glibc-devel          x86_64        2.17-326.el7_9        updates        1.1 M
 glibc-headers        x86_64        2.17-326.el7_9        updates        691 k

Transaction Summary
===============================================================================
Upgrade  1 Package (+3 Dependent packages)

Total download size: 17 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/4): glibc-2.17-326.el7_9.x86_64.rpm                    | 3.6 MB   00:00     
(2/4): glibc-devel-2.17-326.el7_9.x86_64.rpm              | 1.1 MB   00:00     
(3/4): glibc-common-2.17-326.el7_9.x86_64.rpm             |  12 MB   00:00     
(4/4): glibc-headers-2.17-326.el7_9.x86_64.rpm            | 691 kB   00:00     
-------------------------------------------------------------------------------
Total                                              22 MB/s |  17 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : glibc-2.17-326.el7_9.x86_64                                 1/8 
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
  Updating   : glibc-common-2.17-326.el7_9.x86_64                          2/8 
  Updating   : glibc-headers-2.17-326.el7_9.x86_64                         3/8 
  Updating   : glibc-devel-2.17-326.el7_9.x86_64                           4/8 
  Cleanup    : glibc-devel-2.17-260.el7_6.5.x86_64                         5/8 
  Cleanup    : glibc-headers-2.17-260.el7_6.5.x86_64                       6/8 
  Cleanup    : glibc-2.17-260.el7_6.5.x86_64                               7/8 
  Cleanup    : glibc-common-2.17-260.el7_6.5.x86_64                        8/8 
  Verifying  : glibc-common-2.17-326.el7_9.x86_64                          1/8 
  Verifying  : glibc-2.17-326.el7_9.x86_64                                 2/8 
  Verifying  : glibc-devel-2.17-326.el7_9.x86_64                           3/8 
  Verifying  : glibc-headers-2.17-326.el7_9.x86_64                         4/8 
  Verifying  : glibc-devel-2.17-260.el7_6.5.x86_64                         5/8 
  Verifying  : glibc-headers-2.17-260.el7_6.5.x86_64                       6/8 
  Verifying  : glibc-common-2.17-260.el7_6.5.x86_64                        7/8 
  Verifying  : glibc-2.17-260.el7_6.5.x86_64                               8/8 

Updated:
  glibc.x86_64 0:2.17-326.el7_9                                                

Dependency Updated:
  glibc-common.x86_64 0:2.17-326.el7_9    glibc-devel.x86_64 0:2.17-326.el7_9  
  glibc-headers.x86_64 0:2.17-326.el7_9  

Complete!
[root@master Code]# debuginfo-install glibc
Loaded plugins: fastestmirror
enabling epel-debuginfo
enabling docker-ce-stable-debuginfo
docker-ce-stable-debuginfo                              | 3.5 kB     00:00     
epel-debuginfo/x86_64/metalink                          | 9.6 kB     00:00     
epel-debuginfo                                          | 3.0 kB     00:00     
(1/3): epel-debuginfo/x86_64/primary_db                   | 902 kB   00:00     
(2/3): docker-ce-stable-debuginfo/x86_64/primary_db       | 6.4 kB   00:00     
(3/3): docker-ce-stable-debuginfo/x86_64/updateinfo       |   55 B   00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * epel: mirrors.bfsu.edu.cn
 * epel-debuginfo: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
--> Running transaction check
---> Package glibc-debuginfo.x86_64 0:2.17-326.el7_9 will be installed
--> Processing Dependency: glibc-debuginfo-common = 2.17-326.el7_9 for package: glibc-debuginfo-2.17-326.el7_9.x86_64
---> Package nss-softokn-debuginfo.x86_64 0:3.28.3-6.el7 will be installed
---> Package yum-plugin-auto-update-debug-info.noarch 0:1.1.31-54.el7_8 will be installed
--> Running transaction check
---> Package glibc-debuginfo-common.x86_64 0:2.17-326.el7_9 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================
 Package                           Arch   Version         Repository      Size
===============================================================================
Installing:
 glibc-debuginfo                   x86_64 2.17-326.el7_9  base-debuginfo 9.5 M
 nss-softokn-debuginfo             x86_64 3.28.3-6.el7    base-debuginfo 1.9 M
 yum-plugin-auto-update-debug-info noarch 1.1.31-54.el7_8 base            29 k
Installing for dependencies:
 glibc-debuginfo-common            x86_64 2.17-326.el7_9  base-debuginfo 9.7 M

Transaction Summary
===============================================================================
Install  3 Packages (+1 Dependent package)

Total download size: 21 M
Installed size: 119 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/base-debuginfo/packages/glibc-debuginfo-2.17-326.el7_9.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID b6792c39: NOKEY
Public key for glibc-debuginfo-2.17-326.el7_9.x86_64.rpm is not installed
(1/4): glibc-debuginfo-2.17-326.el7_9.x86_64.rpm          | 9.5 MB   00:06     
(2/4): yum-plugin-auto-update-debug-info-1.1.31-54.el7_8. |  29 kB   00:00     
(3/4): nss-softokn-debuginfo-3.28.3-6.el7.x86_64.rpm      | 1.9 MB   00:00     
(4/4): glibc-debuginfo-common-2.17-326.el7_9.x86_64.rpm   | 9.7 MB   01:46     
-------------------------------------------------------------------------------
Total                                             203 kB/s |  21 MB  01:46     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
Importing GPG key 0xB6792C39:
 Userid     : "CentOS-7 Debug (CentOS-7 Debuginfo RPMS) <security@centos.org>"
 Fingerprint: 759d 690f 6099 2d52 6a35 8cbd d0f2 5a3c b679 2c39
 Package    : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
Is this ok [y/N]: y

Key imported successfully
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : glibc-debuginfo-common-2.17-326.el7_9.x86_64                1/4 
  Installing : glibc-debuginfo-2.17-326.el7_9.x86_64                       2/4 
  Installing : yum-plugin-auto-update-debug-info-1.1.31-54.el7_8.noarch    3/4 
  Installing : nss-softokn-debuginfo-3.28.3-6.el7.x86_64                   4/4 
  Verifying  : nss-softokn-debuginfo-3.28.3-6.el7.x86_64                   1/4 
  Verifying  : yum-plugin-auto-update-debug-info-1.1.31-54.el7_8.noarch    2/4 
  Verifying  : glibc-debuginfo-common-2.17-326.el7_9.x86_64                3/4 
  Verifying  : glibc-debuginfo-2.17-326.el7_9.x86_64                       4/4 

Installed:
  glibc-debuginfo.x86_64 0:2.17-326.el7_9                                      
  nss-softokn-debuginfo.x86_64 0:3.28.3-6.el7                                  
  yum-plugin-auto-update-debug-info.noarch 0:1.1.31-54.el7_8                   

Dependency Installed:
  glibc-debuginfo-common.x86_64 0:2.17-326.el7_9                               

Complete!
[root@master Code]# 
[root@master Code]# 


分享一个有趣的 学习链接:https://xxetb.xet.tech/s/HY8za



相关实践学习
阿里云图数据库GDB入门与应用
图数据库(Graph Database,简称GDB)是一种支持Property Graph图模型、用于处理高度连接数据查询与存储的实时、可靠的在线数据库服务。它支持Apache TinkerPop Gremlin查询语言,可以帮您快速构建基于高度连接的数据集的应用程序。GDB非常适合社交网络、欺诈检测、推荐引擎、实时图谱、网络/IT运营这类高度互连数据集的场景。 GDB由阿里云自主研发,具备如下优势: 标准图查询语言:支持属性图,高度兼容Gremlin图查询语言。 高度优化的自研引擎:高度优化的自研图计算层和存储层,云盘多副本保障数据超高可靠,支持ACID事务。 服务高可用:支持高可用实例,节点故障迅速转移,保障业务连续性。 易运维:提供备份恢复、自动升级、监控告警、故障切换等丰富的运维功能,大幅降低运维成本。 产品主页:https://www.aliyun.com/product/gdb
目录
相关文章
|
6月前
|
NoSQL Linux 编译器
GDB符号表概念和在Linux下获取符号表的方法
通过掌握这些关于GDB符号表的知识,你可以更好地管理和理解你的程序,希望这些知识可以帮助你更有效地进行调试工作。
290 16
|
5月前
|
NoSQL Linux 开发工具
Linux环境基础开发工具的使用(yum、vim、gcc、g++、gdb、make/Makefile)
本文介绍了yum 包管理工具、Vim 编辑器、gcc/g++ 编译器、gdb 调试器、编译原理及 Makefile 的使用,同时还配备了如何使用,以及图解。旨在帮助读者更好地理解和应用这些工具与技术。
312 0
|
12月前
|
NoSQL 编译器 C语言
C语言调试是开发中的重要技能,涵盖基本技巧如打印输出、断点调试和单步执行,以及使用GCC、GDB、Visual Studio和Eclipse CDT等工具。
C语言调试是开发中的重要技能,涵盖基本技巧如打印输出、断点调试和单步执行,以及使用GCC、GDB、Visual Studio和Eclipse CDT等工具。高级技巧包括内存检查、性能分析和符号调试。通过实践案例学习如何有效定位和解决问题,同时注意保持耐心、合理利用工具、记录过程并避免过度调试,以提高编程能力和开发效率。
379 1
|
NoSQL Linux C语言
Linux GDB 调试
Linux GDB 调试
199 10
gdb中获取进程收到的最近一个信号的信息
gdb中获取进程收到的最近一个信号的信息
|
NoSQL Linux 编译器
内核实验(一):使用QEMU+GDB断点调试Linux内核代码
如何配置环境并使用QEMU虚拟机结合GDB进行Linux内核代码的断点调试,包括安装QEMU、交叉编译工具链,编译内核以及通过GDB远程连接进行调试的详细步骤。
1210 0
内核实验(一):使用QEMU+GDB断点调试Linux内核代码
|
2月前
|
Linux 应用服务中间件 Shell
二、Linux文本处理与文件操作核心命令
熟悉了Linux的基本“行走”后,就该拿起真正的“工具”干活了。用grep这个“放大镜”在文件里搜索内容,用find这个“探测器”在系统中寻找文件,再用tar把东西打包带走。最关键的是要学会使用管道符|,它像一条流水线,能把这些命令串联起来,让简单工具组合出强大的功能,比如 ps -ef | grep 'nginx' 就能快速找出nginx进程。
385 1
二、Linux文本处理与文件操作核心命令
|
2月前
|
Linux
linux命令—stat
`stat` 是 Linux 系统中用于查看文件或文件系统详细状态信息的命令。相比 `ls -l`,它提供更全面的信息,包括文件大小、权限、所有者、时间戳(最后访问、修改、状态变更时间)、inode 号、设备信息等。其常用选项包括 `-f` 查看文件系统状态、`-t` 以简洁格式输出、`-L` 跟踪符号链接,以及 `-c` 或 `--format` 自定义输出格式。通过这些选项,用户可以灵活获取所需信息,适用于系统调试、权限检查、磁盘管理等场景。
284 137
|
2月前
|
安全 Ubuntu Unix
一、初识 Linux 与基本命令
玩转Linux命令行,就像探索一座新城市。首先要熟悉它的“地图”,也就是/根目录下/etc(放配置)、/home(住家)这些核心区域。然后掌握几个“生存口令”:用ls看周围,cd去别处,mkdir建新房,cp/mv搬东西,再用cat或tail看文件内容。最后,别忘了随时按Tab键,它能帮你自动补全命令和路径,是提高效率的第一神器。
642 57
|
1月前
|
存储 安全 Linux
Linux卡在emergency mode怎么办?xfs_repair 命令轻松解决
Linux虚拟机遇紧急模式?别慌!多因磁盘挂载失败。本文教你通过日志定位问题,用`xfs_repair`等工具修复文件系统,三步快速恢复。掌握查日志、修磁盘、验重启,轻松应对紧急模式,保障系统稳定运行。
342 2