crash extension modules | ||
---|---|---|
|
||
module | commands | comments |
echo.c | echo |
|
snap.c
snap.mk |
snap |
|
eppic.c eppic.mk |
load unload edit sclass sdebug sname |
|
dminfo.c | dminfo |
|
crash-trace | trace |
|
crash-gcore | gcore |
|
spu.c |
spuctx spus spurq |
|
pykdump |
epython crashinfo xportshow |
|
qemu-vtop.c |
qemu-vtop |
|
ipcs.c |
ipcs |
|
pstruct.c |
pstruct |
|
lscgroup.c |
lscgroup |
|
cgget.c |
cgget |
|
swap_usage.c |
pswap |
|
memutils.c |
memutils |
|
ksm.c |
ksm |
|
sockq.c |
sockq |
|
fp.c fp.mk |
fp |
$ cp <path-to>/fp.c <path-to>/fp.mk extensions $ make extensions |
vz.c |
vzlist vzps ctid |
|
ptdump-1.0.7.tar.gz |
ptdump |
|
proccgroup.c |
showcg |
|
cacheutils.c |
ccat cls cfind |
|
page_owner.c | owner |
|
crash EPPIC scripts | ||
EPPIC scripts require no compilation, but they do require that the eppic.so extension module be pre-loaded with extend, because eppic.so provides the load command required to load EPPIC scripts. To add the module to a running crash session, enter: crash> extend <path-to>/eppic.so The module can be installed automatically if the extend command above is entered in either ./.crashrc or $HOME/.crashrc. EPPIC scripts may be located anywhere. However, upon loading the eppic.so module, EPPIC scripts located in the /usr/share/eppic/crash or $HOME/.eppic directories will be loaded automatically. The command(s) contained in loaded EPPIC script(s) will appear in the crash help menu. The EPPIC README and README.code files contain information regarding the format of eppic scripts. The EPPIC sources contain a sample ipcs2 command, similar in nature to the built-in ipcs command. The ipcs2 script files will be located in the extensions/eppic/applications/crash/code directory, and the directory's contents should be copied to either /usr/share/eppic/crash or $HOME/.eppic. For example:
$ make extensions Having done the above, upon loading the eppic.so module, the ipcs2 EPPIC command will be automatically loaded. The EPPIC package website is here: https://github.com/lucchouina/eppic Author: Luc Chouinard <lucchouina@gmail.com>
|
||
crashdc: Crash Dump Data Collector | ||
The crashdc data collector is a script that can be used in conjunction with the crash utility to automatically generate a text file containing major information about a newly generated crash dump. The package website is here: http://crashdc.sourceforge.net Author: Louis Bouchard <louis.bouchard@canonical.com>
|
||
Python scripts | ||
Author: Alexey Dobriyan <adobriyan@gmail.com>
This an example of how to run crash utility commands from a Python script: #!/usr/bin/python2 import hashlib import os import subprocess import tempfile # create "vmlinux" and "core" symlinks before running #CRASH='/usr/bin/crash' CRASH=os.path.join(os.path.expanduser('~'), 'bin', 'crash') # split() without empty strings def xsplit(s, c): i = 0 while True: j = s.find(c, i) if j == -1: if i == len(s): return yield s[i:] return elif i == j: i = i + 1 continue else: yield s[i:j] i = j + 1 _CRASH_CACHE_DIR='.crash' def crash(cmd): idx = cmd.find('\n') if idx >= 0: print 'CRASH "%s" ...' % cmd[:idx] else: print 'CRASH "%s"' % cmd try: os.mkdir(_CRASH_CACHE_DIR) except OSError: pass cache_filename = os.path.join(_CRASH_CACHE_DIR, hashlib.sha1(cmd).hexdigest()) if os.path.isfile(cache_filename): with open(cache_filename, 'r') as f: return f.read() fd, filename = tempfile.mkstemp() f = os.fdopen(fd, 'w') f.write(cmd) if cmd[-1] != '\n': f.write('\n') f.write('q\n') f.close() with open(filename, 'r') as f: x = subprocess.check_output([CRASH, '-s', 'vmlinux', 'core'], stdin=f) os.unlink(filename) with open(cache_filename, 'w+') as f: f.write(x) return x def make_cmd(fmt, it): return '\n'.join(map(lambda x: fmt % x, it)) #def struct_inode(): # cmd = 'list -H super_blocks super_block.s_list' # x = crash(cmd) # list_sb = map(lambda x: int(x, 16), xsplit(x, '\n')) # # cmd = 'struct super_block.s_inodes' # x = crash(cmd) # s = [line for line in xsplit(x, '\n')] # OFFSETOF_STRUCT_INODE_S_INODES = int(s[1].split()[0][1:-1]) # ## set_inode = set() ## for sb in list_sb: ## cmd = 'list -H %x inode.i_sb_list' % (sb + OFFSETOF_STRUCT_INODE_S_INODES) ## x = crash(cmd) ## set_inode.update(map(lambda x: int(x, 16), xsplit(x, '\n'))) ## print len(set_inode) # # set_inode = set() # cmd = make_cmd('list -H %x inode.i_sb_list', map(lambda x: x + OFFSETOF_STRUCT_INODE_S_INODES, list_sb)) # x = crash(cmd) # set_inode = set(map(lambda x: int(x, 16), xsplit(x, '\n'))) # print len(set_inode) # #struct_inode() |
||
Pykdump scripts | ||
Pykdump scripts require no Python installed, but they do require the mpykdump.so extension module pre-loaded with extend. mpykdump.so provides built-in Python interpreter and needed pure Python libraries as well as Python bindings to crash. Loading the extension registers 'epython' command which can be used to execute Python programs. To minimize the extension size, only parts of Python standard library are included in the extension file. If you need anything extra (e.g. XML/RPC) please contact the author. The mpykdump.so extension file is a shared library with ZIP-archive appended at the end of it. You can use standard ZIP command to view the contents of it and add your own Python programs. In addition to generic epython command, two useful programs are included in the extension (see Wiki documentation on SF site for more details). The package website is here: http://pykdump.sourceforge.net Author: Alex Sidorenko <asid@hp.com>
|
||
crashinfo |
|
|
xportshow |
|
|
crash-extscript | ||
At times it may be necessary to execute a series of crash commands to arrive at a result. For example, the output of a crash command may be parsed for a particular element, which is then used in a subsequent command, and so on. There are cases when this may take several steps, and this utility can be used to automate those steps. Another use can be to execute a series of pre-defined crash commands, parse the output to get relevant information, and generate a bug report. These are the components in contained in this package:
The external script is not executed as-is, but rather it is invoked by running the extscript command from the crash prompt. The external script is essentially run as a "server" by the crash utility when the extscript command is issued; the external script serves the crash utility by issuing crash commands. To build the extension module from the top-level crash-<version> directory, enter: $ cp extscript.c extensions$ make extensions $ cp perlfc.pl . Then from the crash prompt: crash> extend extensions/extscript.socrash> extscript -f perl -a perl -a ./perlfc.pl crash> extscript -b vmallocinfo The first command loads the extscript.so module, which adds the extscript command to crash utility. The second command sets up the execution format similar to how arguments are passed to execlp(), passing the executable command's filename and the command arguments. The third command is the "bypass" command, which executes the specified command that is encoded in the perlfc.pl script. In this case vmallocinfo is one of the commands that is defined in perlfc.pl; its output will be similar to /proc/vmallocinfo, displayed on crash console. The help command shows all the commands supported by the script and its usage: crash> extscript -b helpThe perlfc.pl script is an example of how to write quick automation scripts to use the extscript extension of crash utility. More details can be found in the README of the package The package website is here: https://github.com/vinayakmenon/crash-extscript Author: Vinayak Menon <vinayakm.list@gmail.com>
|