在 CentOS 6.4 下用 gdb 除錯,執行 bt(backtrace)時跳出提示:
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.107.el6.i686
隔天再試,版本號又變成 glibc-2.12-1.132.el6.i686——因為系統更新過了,符號檔必須與當下的 glibc 版本完全對應。
直接執行 debuginfo-install glibc-2.12-1.132.el6.i686,結果是:
No debuginfo packages available to install
改用 yum 明確指定來源:
sudo yum --nogpgcheck --enablerepo=debug install glibc-debuginfo
又得到:
glibc-debuginfo-common-2.12-1.132.el6.i686: failure ... [Errno 256] No more mirrors to try.
而 yum install glibc 只會裝基本函式庫,不含 debuginfo。
問題根源是 /etc/yum.repos.d/CentOS-Debuginfo.repo 預設沒有啟用。編輯該檔,把 [debug] 區段的 enabled 改為 1:
[debug] name=CentOS-6 - Debuginfo baseurl=https://debuginfo.centos.org/6/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-6 enabled=1
存檔後再執行一次:
debuginfo-install glibc-2.12-1.132.el6.i686
這次就會看到正常的依賴解析與下載流程,一口氣裝上 glibc-debuginfo、glibc-debuginfo-common、nss-softokn-debuginfo 與 yum-plugin-auto-update-debug-info,結尾出現 Complete!,gdb 的 backtrace 就有完整符號可用了。
/etc/yum.repos.d/CentOS-Debuginfo.repo,設 enabled=1。sudo yum install glibc 確保基礎函式庫在位。debuginfo-install glibc-<對應版本> 安裝符號。核心觀念只有一句:debuginfo 的版本必須與執行中的 glibc 完全一致,版本對不上,符號就永遠裝不進來。