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
目录
相关文章
|
11天前
|
缓存 监控 Linux
|
29天前
|
Linux API 开发工具
FFmpeg开发笔记(五十九)Linux编译ijkplayer的Android平台so库
ijkplayer是由B站研发的移动端播放器,基于FFmpeg 3.4,支持Android和iOS。其源码托管于GitHub,截至2024年9月15日,获得了3.24万星标和0.81万分支,尽管已停止更新6年。本文档介绍了如何在Linux环境下编译ijkplayer的so库,以便在较新的开发环境中使用。首先需安装编译工具并调整/tmp分区大小,接着下载并安装Android SDK和NDK,最后下载ijkplayer源码并编译。详细步骤包括环境准备、工具安装及库编译等。更多FFmpeg开发知识可参考相关书籍。
81 0
FFmpeg开发笔记(五十九)Linux编译ijkplayer的Android平台so库
|
18天前
|
缓存 监控 Linux
Python 实时获取Linux服务器信息
Python 实时获取Linux服务器信息
|
3月前
|
NoSQL Linux C语言
Linux GDB 调试
Linux GDB 调试
62 10
|
2月前
|
NoSQL
gdb中获取进程收到的最近一个信号的信息
gdb中获取进程收到的最近一个信号的信息
|
3月前
|
NoSQL Linux C语言
嵌入式GDB调试Linux C程序或交叉编译(开发板)
【8月更文挑战第24天】本文档介绍了如何在嵌入式环境下使用GDB调试Linux C程序及进行交叉编译。调试步骤包括:编译程序时加入`-g`选项以生成调试信息;启动GDB并加载程序;设置断点;运行程序至断点;单步执行代码;查看变量值;继续执行或退出GDB。对于交叉编译,需安装对应架构的交叉编译工具链,配置编译环境,使用工具链编译程序,并将程序传输到开发板进行调试。过程中可能遇到工具链不匹配等问题,需针对性解决。
|
3月前
|
NoSQL Linux 编译器
内核实验(一):使用QEMU+GDB断点调试Linux内核代码
如何配置环境并使用QEMU虚拟机结合GDB进行Linux内核代码的断点调试,包括安装QEMU、交叉编译工具链,编译内核以及通过GDB远程连接进行调试的详细步骤。
135 0
内核实验(一):使用QEMU+GDB断点调试Linux内核代码
|
2月前
|
Linux API 开发工具
Linux内核开发流程指南 - 8. 获取更多信息【ChatGPT】
Linux内核开发流程指南 - 8. 获取更多信息【ChatGPT】
|
3月前
|
NoSQL
技术分享:如何使用GDB调试不带调试信息的可执行程序
【8月更文挑战第27天】在软件开发和调试过程中,我们有时会遇到需要调试没有调试信息的可执行程序的情况。这可能是由于程序在编译时没有加入调试信息,或者调试信息被剥离了。然而,即使面对这样的挑战,GDB(GNU Debugger)仍然提供了一些方法和技术来帮助我们进行调试。以下将详细介绍如何使用GDB调试不带调试信息的可执行程序。
99 0
|
Linux Perl
LINUX获取当前用户及信息的命令
LINUX获取当前用户及信息的命令
132 0