Blame README

Packit Service 501009
Packit Service 501009
Packit Service 501009
                         CORE ANALYSIS SUITE
Packit Service 501009
Packit Service 501009
  The core analysis suite is a self-contained tool that can be used to
Packit Service 501009
  investigate either live systems, kernel core dumps created from dump
Packit Service 501009
  creation facilities such as kdump, kvmdump, xendump, the netdump and
Packit Service 501009
  diskdump packages offered by Red Hat, the LKCD kernel patch, the mcore
Packit Service 501009
  kernel patch created by Mission Critical Linux, as well as other formats
Packit Service 501009
  created by manufacturer-specific firmware.
Packit Service 501009
Packit Service 501009
  o  The tool is loosely based on the SVR4 crash command, but has been
Packit Service 501009
     completely integrated with gdb in order to be able to display 
Packit Service 501009
     formatted kernel data structures, disassemble source code, etc.
Packit Service 501009
     
Packit Service 501009
  o  The current set of available commands consist of common kernel core
Packit Service 501009
     analysis tools such as a context-specific stack traces, source code
Packit Service 501009
     disassembly, kernel variable displays, memory display, dumps of 
Packit Service 501009
     linked-lists, etc.  In addition, any gdb command may be entered,
Packit Service 501009
     which in turn will be passed onto the gdb module for execution.  
Packit Service 501009
Packit Service 501009
  o  There are several commands that delve deeper into specific kernel
Packit Service 501009
     subsystems, which also serve as templates for kernel developers
Packit Service 501009
     to create new commands for analysis of a specific area of interest.
Packit Service 501009
     Adding a new command is a simple affair, and a quick recompile
Packit Service 501009
     adds it to the command menu.
Packit Service 501009
Packit Service 501009
  o  The intent is to make the tool independent of Linux version dependencies,
Packit Service 501009
     building in recognition of major kernel code changes so as to adapt to 
Packit Service 501009
     new kernel versions, while maintaining backwards compatibility.
Packit Service 501009
Packit Service 501009
  A whitepaper with complete documentation concerning the use of this utility
Packit Service 501009
  can be found here:
Packit Service 501009
 
Packit Service 420355
         https://crash-utility.github.io/crash_whitepaper.html
Packit Service 420355
         
Packit Service 501009
 
Packit Service 501009
  These are the current prerequisites: 
Packit Service 501009
Packit Service 501009
  o  At this point, x86, ia64, x86_64, ppc64, ppc, arm, arm64, alpha, mips,
Packit Service 501009
     s390 and s390x-based kernels are supported.  Other architectures may be
Packit Service 501009
     addressed in the future.
Packit Service 501009
Packit Service 501009
  o  One size fits all -- the utility can be run on any Linux kernel version
Packit Service 501009
     version dating back to 2.2.5-15.  A primary design goal is to always
Packit Service 501009
     maintain backwards-compatibility.
Packit Service 501009
Packit Service 501009
  o  In order to contain debugging data, the top-level kernel Makefile's CFLAGS
Packit Service 501009
     definition must contain the -g flag.  Typically distributions will contain
Packit Service 501009
     a package containing a vmlinux file with full debuginfo data.  If not, the
Packit Service 501009
     kernel must be rebuilt:
Packit Service 501009
Packit Service 501009
     For 2.2 kernels that are not built with -g, change the following line:
Packit Service 501009
Packit Service 501009
        CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
Packit Service 501009
Packit Service 501009
     to:
Packit Service 501009
Packit Service 501009
        CFLAGS = -g -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
Packit Service 501009
Packit Service 501009
     For 2.4 kernels that are not built with -g, change the following line:
Packit Service 501009
Packit Service 501009
        CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing
Packit Service 501009
Packit Service 501009
     to:
Packit Service 501009
Packit Service 501009
        CFLAGS := -g $(CPPFLAGS) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing
Packit Service 501009
Packit Service 501009
     For 2.6 and later kernels that are not built with -g, the kernel should
Packit Service 501009
     be configured with CONFIG_DEBUG_INFO enabled, which in turn will add
Packit Service 501009
     the -g flag to the CFLAGS setting in the kernel Makefile.
Packit Service 501009
 
Packit Service 501009
     After the kernel is re-compiled, the uncompressed "vmlinux" kernel
Packit Service 501009
     that is created in the top-level kernel build directory must be saved.
Packit Service 501009
Packit Service 501009
  To build the crash utility: 
Packit Service 501009
Packit Service 501009
    $ tar -xf crash-7.2.8.tar.gz
Packit Service 501009
    $ cd crash-7.2.8
Packit Service 501009
    $ make
Packit Service 501009
Packit Service 501009
  The initial build will take several minutes  because the embedded gdb module
Packit Service 501009
  must be configured and built.  Alternatively, the crash source RPM file
Packit Service 501009
  may be installed and built, and the resultant crash binary RPM file installed.
Packit Service 501009
Packit Service 501009
  The crash binary can only be used on systems of the same architecture as
Packit Service 501009
  the host build system.  There are a few optional manners of building the
Packit Service 501009
  crash binary:
Packit Service 501009
Packit Service 501009
  o  On an x86_64 host, a 32-bit x86 binary that can be used to analyze
Packit Service 501009
     32-bit x86 dumpfiles may be built by typing "make target=X86".
Packit Service 501009
  o  On an x86 or x86_64 host, a 32-bit x86 binary that can be used to analyze
Packit Service 501009
     32-bit arm dumpfiles may be built by typing "make target=ARM".
Packit Service 501009
  o  On an x86 or x86_64 host, a 32-bit x86 binary that can be used to analyze
Packit Service 501009
     32-bit mips dumpfiles may be built by typing "make target=MIPS".
Packit Service 501009
  o  On an ppc64 host, a 32-bit ppc binary that can be used to analyze
Packit Service 501009
     32-bit ppc dumpfiles may be built by typing "make target=PPC".
Packit Service 501009
  o  On an x86_64 host, an x86_64 binary that can be used to analyze
Packit Service 501009
     arm64 dumpfiles may be built by typing "make target=ARM64".
Packit Service 501009
  o  On an x86_64 host, an x86_64 binary that can be used to analyze
Packit Service 501009
     ppc64le dumpfiles may be built by typing "make target=PPC64".
Packit Service 501009
Packit Service 501009
  Traditionally when vmcores are compressed via the makedumpfile(8) facility
Packit Service 501009
  the libz compression library is used, and by default the crash utility
Packit Service 501009
  only supports libz.  Recently makedumpfile has been enhanced to optionally
Packit Service 501009
  use either the LZO or snappy compression libraries.  To build crash with
Packit Service 501009
  either or both of those libraries, type "make lzo" or "make snappy".
Packit Service 501009
Packit Service 501009
  All of the alternate build commands above are "sticky" in that the
Packit Service 501009
  special "make" targets only have to be entered one time; all subsequent
Packit Service 501009
  builds will follow suit.
Packit Service 501009
Packit Service 501009
  If the tool is run against a kernel dumpfile, two arguments are required, the
Packit Service 501009
  uncompressed kernel name and the kernel dumpfile name.  
Packit Service 501009
Packit Service 501009
  If run on a live system, only the kernel name is required, because /dev/mem 
Packit Service 501009
  will be used as the "dumpfile".  On Red Hat or Fedora kernels where the
Packit Service 501009
  /dev/mem device is restricted, the /dev/crash memory driver will be used.
Packit Service 501009
  If neither /dev/mem or /dev/crash are available, then /proc/kcore will be
Packit Service 501009
  be used as the live memory source.  If /proc/kcore is also restricted, then
Packit Service 501009
  the Red Hat /dev/crash driver may be compiled and installed; its source
Packit Service 501009
  is included in the crash-7.2.8/memory_driver subdirectory.
Packit Service 501009
Packit Service 501009
  If the kernel file is stored in /boot, /, /boot/efi, or in any /usr/src
Packit Service 501009
  or /usr/lib/debug/lib/modules subdirectory, then no command line arguments
Packit Service 501009
  are required -- the first kernel found that matches /proc/version will be
Packit Service 501009
  used as the namelist.
Packit Service 501009
  
Packit Service 501009
  For example, invoking crash on a live system would look like this:
Packit Service 501009
Packit Service 501009
    $ crash
Packit Service 501009
    
Packit Service 501009
    crash 7.2.8
Packit Service 501009
    Copyright (C) 2002-2020  Red Hat, Inc.
Packit Service 501009
    Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
Packit Service 501009
    Copyright (C) 1999-2006  Hewlett-Packard Co
Packit Service 501009
    Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
Packit Service 501009
    Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Packit Service 501009
    Copyright (C) 2005, 2011  NEC Corporation
Packit Service 501009
    Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
Packit Service 501009
    Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
Packit Service 501009
    This program is free software, covered by the GNU General Public License,
Packit Service 501009
    and you are welcome to change it and/or distribute copies of it under
Packit Service 501009
    certain conditions.  Enter "help copying" to see the conditions.
Packit Service 501009
    This program has absolutely no warranty.  Enter "help warranty" for details.
Packit Service 501009
     
Packit Service 501009
    GNU gdb 7.6
Packit Service 501009
    Copyright 2013 Free Software Foundation, Inc.
Packit Service 501009
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
Packit Service 501009
    This is free software: you are free to change and redistribute it.
Packit Service 501009
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
Packit Service 501009
    and "show warranty" for details.
Packit Service 501009
    This GDB was configured as "i686-pc-linux-gnu"...
Packit Service 501009
     
Packit Service 501009
          KERNEL: /boot/vmlinux
Packit Service 501009
        DUMPFILE: /dev/mem
Packit Service 501009
            CPUS: 1
Packit Service 501009
            DATE: Thu Jan 30 13:58:56 2020
Packit Service 501009
          UPTIME: 10 days, 22:55:18
Packit Service 501009
    LOAD AVERAGE: 0.08, 0.03, 0.01
Packit Service 501009
           TASKS: 42
Packit Service 501009
        NODENAME: ha2.mclinux.com
Packit Service 501009
         RELEASE: 2.4.0-test10
Packit Service 501009
         VERSION: #11 SMP Thu Nov 4 15:09:25 EST 2000
Packit Service 501009
         MACHINE: i686  (447 MHz)
Packit Service 501009
	  MEMORY: 128 MB
Packit Service 501009
             PID: 3621                                  
Packit Service 501009
         COMMAND: "crash"
Packit Service 501009
            TASK: c463c000  
Packit Service 501009
             CPU: 0
Packit Service 501009
           STATE: TASK_RUNNING (ACTIVE)
Packit Service 501009
Packit Service 501009
    crash> help
Packit Service 501009
Packit Service 501009
    *              extend         log            rd             task           
Packit Service 501009
    alias          files          mach           repeat         timer          
Packit Service 501009
    ascii          foreach        mod            runq           tree           
Packit Service 501009
    bpf            fuser          mount          search         union          
Packit Service 501009
    bt             gdb            net            set            vm             
Packit Service 501009
    btop           help           p              sig            vtop           
Packit Service 501009
    dev            ipcs           ps             struct         waitq          
Packit Service 501009
    dis            irq            pte            swap           whatis         
Packit Service 501009
    eval           kmem           ptob           sym            wr             
Packit Service 501009
    exit           list           ptov           sys            q              
Packit Service 501009
    
Packit Service 501009
    crash version: 7.2.8    gdb version: 7.6
Packit Service 501009
    For help on any command above, enter "help <command>".
Packit Service 501009
    For help on input options, enter "help input".
Packit Service 501009
    For help on output options, enter "help output".
Packit Service 501009
Packit Service 501009
    crash> 
Packit Service 501009
 
Packit Service 501009
  When run on a dumpfile, both the kernel namelist and dumpfile must be 
Packit Service 501009
  entered on the command line.  For example, when run on a core dump created
Packit Service 501009
  by the Red Hat netdump or diskdump facilities:
Packit Service 501009
Packit Service 501009
    $ crash vmlinux vmcore
Packit Service 501009
 
Packit Service 501009
    crash 7.2.8
Packit Service 501009
    Copyright (C) 2002-2020  Red Hat, Inc.
Packit Service 501009
    Copyright (C) 2004, 2005, 2006, 2010  IBM Corporation
Packit Service 501009
    Copyright (C) 1999-2006  Hewlett-Packard Co
Packit Service 501009
    Copyright (C) 2005, 2006, 2011, 2012  Fujitsu Limited
Packit Service 501009
    Copyright (C) 2006, 2007  VA Linux Systems Japan K.K.
Packit Service 501009
    Copyright (C) 2005, 2011  NEC Corporation
Packit Service 501009
    Copyright (C) 1999, 2002, 2007  Silicon Graphics, Inc.
Packit Service 501009
    Copyright (C) 1999, 2000, 2001, 2002  Mission Critical Linux, Inc.
Packit Service 501009
    This program is free software, covered by the GNU General Public License,
Packit Service 501009
    and you are welcome to change it and/or distribute copies of it under
Packit Service 501009
    certain conditions.  Enter "help copying" to see the conditions.
Packit Service 501009
    This program has absolutely no warranty.  Enter "help warranty" for details.
Packit Service 501009
     
Packit Service 501009
    GNU gdb 7.6
Packit Service 501009
    Copyright 2013 Free Software Foundation, Inc.
Packit Service 501009
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
Packit Service 501009
    This is free software: you are free to change and redistribute it.
Packit Service 501009
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
Packit Service 501009
    and "show warranty" for details.
Packit Service 501009
    This GDB was configured as "i686-pc-linux-gnu"...
Packit Service 501009
    
Packit Service 501009
          KERNEL: vmlinux
Packit Service 501009
        DUMPFILE: vmcore
Packit Service 501009
            CPUS: 4
Packit Service 501009
            DATE: Tue Mar  2 13:57:09 2004
Packit Service 501009
          UPTIME: 00:02:40
Packit Service 501009
    LOAD AVERAGE: 2.24, 0.96, 0.37
Packit Service 501009
           TASKS: 70
Packit Service 501009
        NODENAME: pro1.lab.boston.redhat.com
Packit Service 501009
         RELEASE: 2.6.3-2.1.214.11smp
Packit Service 501009
         VERSION: #1 SMP Tue Mar 2 10:58:27 EST 2004
Packit Service 501009
         MACHINE: i686  (2785 Mhz)
Packit Service 501009
          MEMORY: 512 MB
Packit Service 501009
           PANIC: "Oops: 0002 [#1]" (check log for details)
Packit Service 501009
             PID: 0
Packit Service 501009
         COMMAND: "swapper"
Packit Service 501009
            TASK: 22fa200  (1 of 4)  [THREAD_INFO: 2356000]
Packit Service 501009
             CPU: 0
Packit Service 501009
           STATE: TASK_RUNNING (PANIC)
Packit Service 501009
    
Packit Service 501009
    crash> 
Packit Service 501009
Packit Service 501009
  The tool's environment is context-specific.  On a live system, the default
Packit Service 501009
  context is the command itself; on a dump the default context will be the
Packit Service 501009
  task that panicked.  The most commonly-used commands are:
Packit Service 501009
Packit Service 501009
    set     - set a new task context by pid, task address, or cpu.
Packit Service 501009
    bt      - backtrace of the current context, or as specified with arguments.
Packit Service 501009
    p       - print the contents of a kernel variable.
Packit Service 501009
    rd      - read memory, which may be either kernel virtual, user virtual, or
Packit Service 501009
              physical.
Packit Service 501009
    ps      - simple process listing.
Packit Service 501009
    log     - dump the kernel log_buf.
Packit Service 501009
    struct  - print the contents of a structure at a specified address.
Packit Service 501009
    foreach - execute a command on all tasks, or those specified, in the system.
Packit Service 501009
 
Packit Service 501009
  Detailed help concerning the use of each of the commands in the menu above 
Packit Service 501009
  may be displayed by entering "help command", where "command" is one of those 
Packit Service 501009
  listed above.  Rather than getting bogged down in details here, simply
Packit Service 501009
  run the help command on each of the commands above.  Note that many commands
Packit Service 501009
  have multiple options so as to avoid the proliferation of command names.
Packit Service 501009
Packit Service 501009
  Command output may be piped to external commands or redirected to files.
Packit Service 501009
  Enter "help output" for details.
Packit Service 501009
Packit Service 501009
  The command line history mechanism allows for command-line recall and 
Packit Service 501009
  command-line editing.  Input files containing a set of crash commands may 
Packit Service 501009
  be substituted for command-line input.  Enter "help input" for details.
Packit Service 501009
Packit Service 501009
  Note that a .crashrc file (or .<your-command-name>rc if the name has been 
Packit Service 501009
  changed), may contain any number of "set" or "alias" commands -- see the
Packit Service 501009
  help pages on those two commands for details.
Packit Service 501009
 
Packit Service 501009
  Lastly, if a command is entered that is not recognized, it is checked
Packit Service 501009
  against the kernel's list of variables, structure, union or typedef names, 
Packit Service 501009
  and if found, the command is passed to "p", "struct", "union" or "whatis".
Packit Service 501009
  That being the case, as long as a kernel variable/structure/union name is 
Packit Service 501009
  different than any of the current commands.
Packit Service 501009
Packit Service 501009
  (1) A kernel variable can be dumped by simply entering its name:
Packit Service 501009
 
Packit Service 501009
      crash> init_mm
Packit Service 501009
      init_mm = $2 = {
Packit Service 501009
        mmap = 0xc022d540, 
Packit Service 501009
        mmap_avl = 0x0, 
Packit Service 501009
        mmap_cache = 0x0, 
Packit Service 501009
        pgd = 0xc0101000, 
Packit Service 501009
        count = {
Packit Service 501009
          counter = 0x6
Packit Service 501009
        }, 
Packit Service 501009
        map_count = 0x1, 
Packit Service 501009
        mmap_sem = {
Packit Service 501009
          count = {
Packit Service 501009
            counter = 0x1
Packit Service 501009
          }, 
Packit Service 501009
          waking = 0x0, 
Packit Service 501009
          wait = 0x0
Packit Service 501009
        }, 
Packit Service 501009
        context = 0x0, 
Packit Service 501009
        start_code = 0xc0000000, 
Packit Service 501009
        end_code = 0xc022b4c8,
Packit Service 501009
        end_data = c0250388,
Packit Service 501009
        ...
Packit Service 501009
      
Packit Service 501009
  (2) A structure or can be dumped simply by entering its name and address:  
Packit Service 501009
Packit Service 501009
      crash> vm_area_struct c5ba3910
Packit Service 501009
      struct vm_area_struct {
Packit Service 501009
        vm_mm = 0xc3ae3210, 
Packit Service 501009
        vm_start = 0x821b000, 
Packit Service 501009
        vm_end = 0x8692000, 
Packit Service 501009
        vm_next = 0xc5ba3890, 
Packit Service 501009
        vm_page_prot = {
Packit Service 501009
          pgprot = 0x25
Packit Service 501009
        }, 
Packit Service 501009
        vm_flags = 0x77, 
Packit Service 501009
        vm_avl_height = 0x4, 
Packit Service 501009
        vm_avl_left = 0xc0499540, 
Packit Service 501009
        vm_avl_right = 0xc0499f40, 
Packit Service 501009
        vm_next_share = 0xc04993c0, 
Packit Service 501009
        vm_pprev_share = 0xc0499060, 
Packit Service 501009
        vm_ops = 0x0, 
Packit Service 501009
        vm_offset = 0x0, 
Packit Service 501009
        vm_file = 0x0, 
Packit Service 501009
        vm_pte = 0x0
Packit Service 501009
      }
Packit Service 501009
Packit Service 501009
Packit Service 501009
  The crash utility has been designed to facilitate the task of adding new 
Packit Service 501009
  commands.  New commands may be permanently compiled into the crash executable,
Packit Service 501009
  or dynamically added during runtime using shared object files.
Packit Service 501009
 
Packit Service 501009
  To permanently add a new command to the crash executable's menu:
Packit Service 501009
Packit Service 501009
    1. For a command named "xxx", put a reference to cmd_xxx() in defs.h.
Packit Service 501009
   
Packit Service 501009
    2. Add cmd_xxx into the base_command_table[] array in global_data.c. 
Packit Service 501009
Packit Service 501009
    3. Write cmd_xxx(), putting it in one of the appropriate files.  Look at 
Packit Service 501009
       the other commands for guidance on getting symbolic data, reading
Packit Service 501009
       memory, displaying data, etc...
Packit Service 501009
Packit Service 501009
    4. Recompile and run.
Packit Service 501009
Packit Service 501009
  Note that while the initial compile of crash, which configures and compiles
Packit Service 501009
  the gdb module, takes several minutes, subsequent re-compiles to do such
Packit Service 501009
  things as add new commands or fix bugs just takes a few seconds.
Packit Service 501009
Packit Service 501009
  Alternatively, you can create shared object library files consisting of
Packit Service 501009
  crash command extensions, that can be dynamically linked into the crash
Packit Service 501009
  executable during runtime or during initialization.  This will allow
Packit Service 501009
  the same shared object to be used with subsequent crash releases without
Packit Service 501009
  having to re-merge the command's code into each new set of crash sources.
Packit Service 501009
  The dynamically linked-in commands will automatically show up in the crash
Packit Service 501009
  help menu.  For details, enter "help extend" during runtime, or enter
Packit Service 501009
  "crash -h extend" from the shell command line.
Packit Service 501009
 
Packit Service 501009
Packit Service 501009
Packit Service 501009
Packit Service 501009