CentOSでcrashコマンドを試してみる

CentOSでcrashコマンドでカーネルデバッグできる環境を構築する手順例を示す。


まず何も考えずcrashコマンドを叩いてみる。   

# crash

crash 4.0-5.0.3.el5.centos
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008  Red Hat, Inc.
Copyright (C) 2004, 2005, 2006  IBM Corporation
Copyright (C) 1999-2006  Hewlett-Packard Co
Copyright (C) 2005, 2006  Fujitsu Limited
Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Copyright (C) 2005  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.

crash: cannot find booted kernel -- please enter namelist argument

Usage:
  crash [-h [opt]][-v][-s][-i file][-d num] [-S] [mapfile] [namelist] [dumpfile]

Enter "crash -h" for details.
#

なにもエラーが出なければ既に設定はされており、手順はここで終了。

上記の様にエラーがでるなら、http://debuginfo.centos.org/からkernel-debuginfoをダウンロードしてくる。

例では以下をダウンロードしたした。※現在動作中のカーネル版数と同じにすること。

インストールから動作確認まで、以下手順で行う。

# rpm -ihv kernel-debuginfo-common-2.6.18-92.1.1.el5.i686.rpm
# rpm -ihv kernel-debuginfo-2.6.18-92.1.22.el5.i686.rpm
# crash

crash 4.0-5.0.3.el5.centos
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008  Red Hat, Inc.
Copyright (C) 2004, 2005, 2006  IBM Corporation
Copyright (C) 1999-2006  Hewlett-Packard Co
Copyright (C) 2005, 2006  Fujitsu Limited
Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Copyright (C) 2005  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 6.1
Copyright 2004 Free Software Foundation, Inc.
GDB 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.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...

      KERNEL: /usr/lib/debug/lib/modules/2.6.18-92.1.22.el5/vmlinux
    DUMPFILE: /dev/crash
        CPUS: 1
        DATE: Thu Mar  5 12:22:00 2009
      UPTIME: 02:24:35
LOAD AVERAGE: 2.14, 0.97, 0.65
       TASKS: 159
    NODENAME: localhost.localdomain
     RELEASE: 2.6.18-92.1.22.el5
     VERSION: #1 SMP Tue Dec 16 12:03:43 EST 2008
     MACHINE: i686  (1728 Mhz)
      MEMORY: 256 MB
         PID: 7203
     COMMAND: "crash"
        TASK: c75ef550  [THREAD_INFO: c6d1a000]
         CPU: 0
       STATE: TASK_RUNNING (ACTIVE)

crash>

完了。

コメント