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
目录
相关文章
|
1天前
|
Linux 编译器 C语言
Linux中的pkg-config:简化库依赖管理的利器
**pkg-config**是Linux下管理库依赖的工具,它通过读取库的`.pc`文件提供编译和链接参数。使用`pkg-config --cflags --libs &lt;library&gt;`获取编译和链接选项,例如`gcc -o test test.c $(pkg-config --cflags --libs glib-2.0)`。能进行版本检查、参数提取、依赖管理和路径搜索。列出所有包用`pkg-config --list-all`。最佳实践包括确保库正确安装、检查版本、配置`PKG_CONFIG_PATH`及使用构建工具。
|
1天前
|
域名解析 网络协议 程序员
程序员必知:【转】adns解析库——域名解析实例(C++、linux)
程序员必知:【转】adns解析库——域名解析实例(C++、linux)
|
1天前
|
域名解析 网络协议 程序员
程序员必知:【转】adns解析库——域名解析实例(C++、linux)
程序员必知:【转】adns解析库——域名解析实例(C++、linux)
|
2天前
|
安全 Linux Shell
深入探索Linux命令pinentry:安全处理敏感信息的利器
`pinentry`是GnuPG的安全工具,用于安全获取密码等敏感信息,它在终端中显示隐藏输入的提示,确保信息安全。支持交互式操作、多种输入方式,且有丰富的选项,如`--tty`和`--window-title`。示例脚本展示了如何在bash中使用它获取密码。使用时注意环境安全,勿明文显示密码,结合其他工具增强安全性,熟悉参数选项,并考虑备份相关配置。
|
2天前
|
NoSQL 编译器 Linux
【Linux】--- Linux编译器-gcc/g++、调试器-gdb、项目自动化构建工具-make/Makefile 使用
【Linux】--- Linux编译器-gcc/g++、调试器-gdb、项目自动化构建工具-make/Makefile 使用
7 0
|
6天前
|
NoSQL Linux C语言
Linux gdb调试的时候没有对应的c调试信息库怎么办?
Linux gdb调试的时候没有对应的c调试信息库怎么办?
11 0
|
Linux Perl
LINUX获取当前用户及信息的命令
LINUX获取当前用户及信息的命令
120 0
|
3天前
|
Linux
Linux如何快速执行历史命令
Linux如何快速执行历史命令
16 8
|
19小时前
|
安全 Linux Shell
Linux中SSH命令介绍
Linux中SSH命令介绍
9 2
|
21小时前
|
NoSQL 关系型数据库 MySQL
linux服务器重启php,nginx,redis,mysql命令
linux服务器重启php,nginx,redis,mysql命令
6 1