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