ubuntu 上的故障转储:vmlinuz 或故障文件不受支持的文件格式

Posted

技术标签:

【中文标题】ubuntu 上的故障转储:vmlinuz 或故障文件不受支持的文件格式【英文标题】:crash dump on ubuntu: vmlinuz or crash file not a supported file format 【发布时间】:2015-05-28 17:40:18 【问题描述】:

我正在尝试使用crash 实用程序分析我的 ubuntu 机器上的故障转储,如下所示

$ sudo crash /boot/System.map-3.2.0-23-generic-pae /boot/vmlinuz-3.2.0-23-generic-pae _usr_sbin_ietd.0.crash

但它返回错误为

crash: /boot/vmlinuz-3.2.0-23-generic-pae: not a supported file format

根据崩溃实用程序语法,我已正确提供参数

crash <system-map-file> <vmlinux-file> coredump

我在这里做错了什么?

更新:

引导目录中的 vmlinuz 文件似乎是 bzimage 压缩的

$ file vmlinuz-3.2.0-23-generic-pae 
vmlinuz-3.2.0-23-generic-pae: Linux kernel x86 boot executable bzImage, version 3.2.0-23-generic-pae (buildd@palmer) #36-Ubuntu SMP Tue Apr 10 , RO-rootFS, swap_dev 0x4, Normal VGA
$ 

【问题讨论】:

vmlinuz 是压缩图像。也许crash 需要未压缩(vmlinux)。你可以试试gunzip /boot/vmlinuz-3.2.0-23-generic-pae(先保存原图,并确保分区中有未压缩图像的空间)。 好的,它是压缩的,但是是 bzImage 格式 OK 同样的想法。我只是有错误的减压程序。您可能会发现 this question/answer 很有帮助。 现在我遇到了同样的崩溃文件错误。 crash: /var/crash/_usr_sbin_ietd.0.crash: not a supported file format 另一个悬而未决的问题是内核是如何构建的。它在crash 的文档中说(在prerequisites 下):一个vmlinux 内核对象文件,在本文档中通常称为名称列表,必须使用-g C 构建flag 以便包含符号调试所需的调试数据。 是这种情况吗? 【参考方案1】:

根据@lurker 的 cmets vmlinuz 已压缩,可以使用以下命令解压缩(来自Extract vmlinux from vmlinuz or bzImage)

$ sudo dd if=vmlinuz-3.2.0-23-generic-pae skip=`grep -a -b -o -m 1 -P '\x1f\x8b\x08\x00' vmlinuz-3.2.0-23-generic-pae| cut -d: -f 1` bs=1 | zcat > /tmp/vmlinux
    4998324+0 records in
    4998324+0 records out
    4998324 bytes (5.0 MB) copied, 201.859 s, 24.8 kB/s

    gzip: stdin: decompression OK, trailing garbage ignored

现在出错

崩溃:/var/crash/_usr_sbin_ietd.0.crash:不支持的文件格式

我们还需要使用apport-unpack 从崩溃报告中提取核心转储文件,如下所示 (from here)

@ubuntu:/tmp$ sudo apport-unpack 
Usage: /usr/bin/apport-unpack <report> <target directory>

@ubuntu:/tmp$ sudo apport-unpack /var/crash/_usr_sbin_ietd.0.crash /var/crash/
ERROR: Destination directory exists and is not empty.
@ubuntu:/tmp$ 

@ubuntu:/tmp$ sudo mkdir coretest

@ubuntu:/tmp$ sudo apport-unpack /var/crash/_usr_sbin_ietd.0.crash /tmp/coretest/
@ubuntu:/tmp$ cd coretest/
@ubuntu:/tmp/coretest$ 

@ubuntu:/tmp/coretest$ ls
Architecture  Date           ExecutablePath       ProblemType  ProcCwd      ProcMaps    Signal  UserGroups
CoreDump      DistroRelease  ExecutableTimestamp  ProcCmdline  ProcEnviron  ProcStatus  Uname

@ubuntu:/tmp/coretest$ ls -lt
total 384
-rw-r--r-- 1 root root      4 May 29 00:13 Architecture
-rw-r--r-- 1 root root     24 May 29 00:13 Date
-rw-r--r-- 1 root root     12 May 29 00:13 DistroRelease
-rw-r--r-- 1 root root     10 May 29 00:13 ExecutableTimestamp
-rw-r--r-- 1 root root 339968 May 29 00:13 CoreDump
-rw-r--r-- 1 root root      5 May 29 00:13 ProblemType
-rw-r--r-- 1 root root     66 May 29 00:13 ProcEnviron
-rw-r--r-- 1 root root    969 May 29 00:13 ProcMaps
-rw-r--r-- 1 root root    737 May 29 00:13 ProcStatus
-rw-r--r-- 1 root root      2 May 29 00:13 Signal
-rw-r--r-- 1 root root     31 May 29 00:13 Uname
-rw-r--r-- 1 root root     14 May 29 00:13 ExecutablePath
-rw-r--r-- 1 root root     14 May 29 00:13 ProcCmdline
-rw-r--r-- 1 root root      1 May 29 00:13 ProcCwd
-rw-r--r-- 1 root root      0 May 29 00:13 UserGroups
@ubuntu:/tmp/coretest$ cd CoreDump
bash: cd: CoreDump: Not a directory
@ubuntu:/tmp/coretest$ sudo crash /tmp/vmlinux /boot/System.map-3.2.0-23-generic-pae /tmp/coretest/CoreDump 

crash 6.1.6
Copyright (C) 2002-2013  Red Hat, Inc.
Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
Copyright (C) 1999-2006  Hewlett-Packard Co
Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Copyright (C) 2005, 2011  NEC Corporation
Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
This program is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions.  Enter "help copying" to see the conditions.
This program has absolutely no warranty.  Enter "help warranty" for details.

GNU gdb (GDB) 7.3.1
Copyright (C) 2011 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 "i686-pc-linux-gnu"...

crash: /tmp/vmlinux: no debugging data available

@ubuntu:/tmp/coretest$ 

对于“没有可用的调试数据”,需要按照this link 和这个one 安装一些调试信息包(programname-dbg 或 progname-dbgsym)

问题https://askubuntu.com/questions/197016/how-to-install-a-package-that-contains-ubuntu-kernel-debug-symbols中提到了为内核下载调试信息包的步骤

但是,添加 GPG 密钥的步骤(如下)对于下载工作至关重要

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01

你应该收到消息

public key "Ubuntu 调试符号存档自动签名密钥 " 导入

而不是“未更改”状态。如果在此步骤中显示“未更改”,则您将无法下载 debuginfo 包。

在这种情况下,尝试使用 http 80 端口作为 (here) 导入 GPG 密钥

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

【讨论】:

很高兴你把所有的东西都整理好了!您可以在 SO 上接受您自己的答案。 :) @lurker 工作现在我也下载了 debuginfo 包。谢谢【参考方案2】:

vmlinuz是一个压缩文件,但是crash需要一个未压缩文件vmlinux,它是用-g选项编译的。 确保你的内核是用 -g 选项编译的,然后你可以从压缩的 vmlinuz 中得到一个未压缩的 vmlinux 文件,方法如下: 1.od -t x1 -A d vmlinuz | grep "1f 8b 08" 例如你得到一个输出: 0018352 ac fe ff ff 1f 8b 08 00 00 00 00 00 02 03 ec fd 2. 计算“1f 8b 08”的偏移量:0018352 + 4 = 0018356。 3. 使用 dd 解压你的 vmlinuz:dd if=vmlinuz bs=1 skip=18356 | zcat &gt; vmlinux 现在你得到了未压缩的内核文件 vmlinux。恭喜!

【讨论】:

以上是关于ubuntu 上的故障转储:vmlinuz 或故障文件不受支持的文件格式的主要内容,如果未能解决你的问题,请参考以下文章

如何读取故障转储文件(我有源代码和 .pdb 文件)

python OpenCV分段故障(核心转储)

查找 C# 应用程序的故障转储文件

在 Visual Studio 中分析故障转储

windows故障转储文件详细内存使用分析?

在 Windows 上调试 linux 故障转储