Author: jhb
Date: Mon Jul 23 18:08:56 2018
New Revision: 336645
URL: https://svnweb.freebsd.org/changeset/base/336645

Log:
  Support compressed crash dumps in crashinfo(8).
  
  Temporarily decompress a copy of a crash dump compressed with either
  gzip or zstd and run various tools against the decompressed copy while
  generating the crash information.  The uncompressed copy is deleted when
  the script exits.
  
  Note that crashinfo is enabled by default, so this will attempt to
  decompress the most recent compressed crash dump after a crash that
  generates a compressed crash dump.  Users who wish to only do offline
  analysis of compressed crash dumps can disable crashinfo in rc.conf.
  
  Tested by:    ler
  Reviewed by:  markj
  MFC after:    2 weeks

Modified:
  head/usr.sbin/crashinfo/crashinfo.sh

Modified: head/usr.sbin/crashinfo/crashinfo.sh
==============================================================================
--- head/usr.sbin/crashinfo/crashinfo.sh        Mon Jul 23 17:38:35 2018        
(r336644)
+++ head/usr.sbin/crashinfo/crashinfo.sh        Mon Jul 23 18:08:56 2018        
(r336645)
@@ -38,6 +38,13 @@ usage()
        exit 1
 }
 
+# Remove an uncompressed copy of a dump
+cleanup()
+{
+
+       [ -e $VMCORE ] && rm -f $VMCORE
+}
+
 # Find a gdb binary to use and save the value in GDB.
 find_gdb()
 {
@@ -133,7 +140,7 @@ if [ $# -eq 1 ]; then
 
        # Figure out the crash directory and number from the vmcore name.
        CRASHDIR=`dirname $1`
-       DUMPNR=$(expr $(basename $1) : 'vmcore\.\([0-9]*\)$')
+       DUMPNR=$(expr $(basename $1) : 'vmcore\.\([0-9]*\)')
        if [ -z "$DUMPNR" ]; then
                echo "Unable to determine dump number from vmcore file $1."
                exit 1
@@ -174,8 +181,16 @@ if [ -z "$GDB" ]; then
 fi
 
 if [ ! -e $VMCORE ]; then
-       echo "$VMCORE not found"
-       exit 1
+       if [ -e $VMCORE.gz ]; then
+               trap cleanup EXIT HUP INT QUIT TERM
+               gzcat $VMCORE.gz > $VMCORE
+       elif [ -e $VMCORE.zst ]; then
+               trap cleanup EXIT HUP INT QUIT TERM
+               zstdcat $VMCORE.zst > $VMCORE
+       else
+               echo "$VMCORE not found"
+               exit 1
+       fi
 fi
 
 if [ ! -e $INFO ]; then
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to