[Linux] 安裝正確的 kernel-debuginfo 解決 vmlinx 和 vmcore 版本不合

[Linux] 安裝正確的 kernel-debuginfo 解決 vmlinx 和 vmcore 版本不合

今天一樣是在準備公司 Debug Hacks 的讀書會報告,

想說用 crash 指令來分析一下剛剛用 sysrq-trigger 作出來的 kernel dump

crash 指令卻說我的 vmlinux 和 vmcore 的版本不符合:

[root@localhost 127.0.0.1-2015.09.29-23:44:24]# crash /usr/lib/debug/lib/modules/3.10.0-229.14.1.el7.x86_64/vmlinux vmcore
crash 7.0.9-5.el7_1
crash: invalid kernel virtual address: 1fd1  type: "possible"
WARNING: cannot read cpu_possible_map
crash: invalid kernel virtual address: 200000002  type: "present"
WARNING: cannot read cpu_present_map
crash: invalid kernel virtual address: dc  type: "online"
WARNING: cannot read cpu_online_map
crash: invalid kernel virtual address: 1e9b  type: "active"
WARNING: cannot read cpu_active_map
crash: /usr/lib/debug/lib/modules/3.10.0-229.14.1.el7.x86_64/vmlinux and vmcore do not match!
Usage:
crash [OPTION]... NAMELIST MEMORY-IMAGE[@ADDRESS]	(dumpfile form)
crash [OPTION]... [NAMELIST]             		(live system form)
Enter "crash -h" for details.

 

真奇怪,我的 kernel-debuginfo 是用 yum 裝的,

看一下版本是 3.10.0-229.14.1.el7:

[root@localhost ~]# yum info kernel-debuginfo
Installed Packages
Name        : kernel-debuginfo
Arch        : x86_64
Version     : 3.10.0
Release     : 229.14.1.el7
Size        : 1.2 G
Repo        : installed
From repo   : base-debuginfo
Summary     : Debug information for package kernel
URL         : http://www.kernel.org/
License     : GPLv2
Description : This package provides debug information for package kernel.
: This is required to use SystemTap with kernel-3.10.0-229.14.1.el7.x86_64.

 

再對照一下 kernel version,沒想到不太一樣,少了中間的 14.1:

[root@localhost ~]# uname -r
3.10.0-229.el7.x86_64

 

看來是我從 yum 裝到了最新版本的 kernel debug info,

但我的 kernel 還不是最新版本的…

解決方法也很簡單,先移除現有的 kernel-debuginfo,

(連 kernel-debuginfo-common-x86_64 也一併移除掉,

不然沒辦法裝另一版本的 kernel-debuginfo)

再裝符合目前 kernel 版本的 debug info 就行囉~

yum remove kernel-debuginfo kernel-debuginfo-common-x86_64
yum install kernel-debuginfo-$(uname -r)

 

如果沒辦法使用 yum 自動從網路下載安裝的話,也可以到 debuginfo 下載頁

找到適合的 kernel-debuginfo 和 kernel-debuginfo-common-86_64,例如:

kernel-debuginfo-common-x86_64-3.10.0-229.el7.x86_64.rpm

kernel-debuginfo-3.10.0-229.el7.x86_64.rpm

下載下來之後,再用 rpm 指令依序安裝就行了~

 

正確版本的 kernl-debuginfo 裝好後,

crash 指令就能正確的分析 kdump 產生的 vmcore 檔案了:

[root@localhost 127.0.0.1-2015.09.29-23:44:24]# crash /usr/lib/debug/lib/modules/3.10.0-229.el7.x86_64/vmlinux vmcore
crash 7.0.9-5.el7_1
KERNEL: /usr/lib/debug/lib/modules/3.10.0-229.el7.x86_64/vmlinux
DUMPFILE: vmcore  [PARTIAL DUMP]
CPUS: 1
UPTIME: 00:07:38
LOAD AVERAGE: 0.01, 0.11, 0.08
TASKS: 106
NODENAME: localhost.localdomain
RELEASE: 3.10.0-229.el7.x86_64
VERSION: #1 SMP Fri Mar 6 11:36:42 UTC 2015
MACHINE: x86_64  (2893 Mhz)
MEMORY: 1 GB
PANIC: "Oops: 0002 [#1] SMP " (check log for details)
PID: 3512
COMMAND: "bash"
TASK: ffff88003b04b8e0  [THREAD_INFO: ffff88003cf58000]
CPU: 0
STATE: TASK_RUNNING (PANIC)
crash>

 

(本頁面已被瀏覽過 1,882 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料