1. 程式人生 > >使用gdb除錯時出現:Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6.i686的解決辦法

使用gdb除錯時出現:Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6.i686的解決辦法

        今天在redhat6.3(32位)下使用gdb除錯程式的時候,出現一段警告,在此總結出解決辦法,方便後來的學者:

提示需要使用debuginfo安裝glibc-2.12-1.212.el6.i686,但是這裡有個問題:linux系統下有debuginfo嗎?

我使用的是redhat6.3,用的是centos6的yum,是沒有debuginfo的,不信的話,我們試驗一下:

直接使用命令:debuginfo-install glibc-2.12-1.212.el6.i686 進行安裝

出現:command not found  說明的確是沒有debuginfo,那接下來問題變成如何安裝debuginfo。

首先需要下載兩個檔案:

kernel-debuginfo-common-xxxxx

kernel-debuginfo-xxxx 

用命令 :uname –r  查詢linux的版本號

我的版本號為2.6.32-431.el6.i686,在開源映象站查詢以下兩個檔案:

kernel-debuginfo-common-2.6.32-431.el6.i686

kernel-debuginfo-2.6.32-431.el6.i686

去http://debuginfo.centos.org尋找和你核心完全匹配的rpm包。

然後安裝兩個包,首先安裝kernel-debuginfo-common-2.6.32-431.el6.i686,然後安裝kernel-debuginfo-2.6.32-431.el6.i686

使用命令:rpm -ivh kernel-debuginfo-common-2.6.32-431.el6.i686

                    rpm -vh kernel-debuginfo-2.6.32-431.el6.i686

安裝完後更改配置檔案CentOS-Base-debuginfo.repo。

發現該本機沒有該配置檔案,裝完debuginfo後也沒有出現諸如CentOS-Base-debuginfo.repo的檔案,很明顯,redhat不可能安裝CentOS的配置檔案,這裡我們需要手動新增。

命令:vim /etc/yum.repos.d/CentOS-Base-debuginfo.repo

然後寫入:

[base-debuginfo] name=CentOS-$releasever - DebugInfo  baseurl=http://debuginfo.centos.org/$releasever/$basearch/ gpgcheck=0 enabled=1 protect=1 priority=1

注意,enabled=1,寫到這裡如果去執行debuginfo-install glibc,則會報出url錯誤!

如此,想起在配置CentOS的yum源時大家應該注意到將$releasever改成系統大版本號,所以(複製貼上即可)

[base-debuginfo] name=CentOS-6 - DebugInfo baseurl=http://debuginfo.centos.org/6/$basearch/ gpgcheck=0 enabled=1 protect=1 priority=1

儲存退出後執行 debuginfo-install glibc-2.12-1.212.el6.i686  發現問題:

這裡提示CentOS-Base-debuginfo.repo檔案第一行有錯誤,然後我又開啟看看,發現第一行寫錯了,掉了 [ 這個符號,加上之後就ok了。

然後就是使用debuginfo安裝glibc-2.12-1.212.el6.i686了。

最後使用gdb除錯程式碼,完美解決。