From owner-svn-soc-all@FreeBSD.ORG Thu May 24 20:25:07 2012 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from socsvn.FreeBSD.org (unknown [IPv6:2001:4f8:fff6::2f]) by hub.freebsd.org (Postfix) with SMTP id BFBE410656D5 for ; Thu, 24 May 2012 20:25:05 +0000 (UTC) (envelope-from tzabal@FreeBSD.org) Received: by socsvn.FreeBSD.org (sSMTP sendmail emulation); Thu, 24 May 2012 20:25:05 +0000 Date: Thu, 24 May 2012 20:25:05 +0000 From: tzabal@FreeBSD.org To: svn-soc-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <20120524202505.BFBE410656D5@hub.freebsd.org> Cc: Subject: socsvn commit: r236317 - soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2012 20:25:07 -0000 Author: tzabal Date: Thu May 24 20:25:05 2012 New Revision: 236317 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236317 Log: Forgot to svn add usr.bin/crashreport in the previous commit. Added: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/ soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/Makefile soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh (contents, props changed) Added: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/Makefile Thu May 24 20:25:05 2012 (r236317) @@ -0,0 +1,3 @@ +SCRIPTS= crashreport.sh + +.include Added: soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2012/tzabal/client-side/akcrs-head/usr.sbin/crashreport/crashreport.sh Thu May 24 20:25:05 2012 (r236317) @@ -0,0 +1,71 @@ +#!/bin/sh + +print_usage() +{ + echo "usage: $(basename $0) [-d dumpdir] [-f file] [-e email]" +} + +# Default dump directory +DUMPDIR='/var/crash' + +dumpdir= +file= +email= + +while getopts "d:f:e:" opt; do + case "$opt" in + d) + dumpdir=$OPTARG + ;; + f) + file=$OPTARG + ;; + e) + email=$OPTARG + ;; + *) + print_usage + exit 1 + ;; + esac +done + + +if [ -z "${dumpdir}" ]; then + if [ -d "${DUMPDIR}" ]; then + dumpdir=${DUMPDIR} + else + echo "Dump directory does not exist." + exit 1 + fi +fi + + +BOUNDS="${dumpdir}/bounds" +CORETXT="${dumpdir}/core.txt" +TEXTDUMPTAR="${dumpdir}/textdump.tar" +X= + +if [ -z "`ls ${dumpdir}`" ]; then + echo "The dump directory is empty." + exit 2 +fi + + +if [ -z "${file}" ]; then + if [ -f "${BOUNDS}" ]; then + value=`head -n 1 ${BOUNDS}` + X=$((value - 1)) + if [ -f "${CORETXT}.${X}" ]; then + file=`basename "${CORETXT}.${X}"` + elif [ -f "${TEXTDUMPTAR}.${X}" ]; then + file=`basename "${TEXTDUMPTAR}.${X}"` + else + echo "Unable to locate generated debugging information." + exit 3 + fi + else + tmp=`ls | grep '[a-z]*\.[a-z]*\.\w*' | sort -n -t . -k 3 | tail -1` + file=`basename "${tmp}"` + fi +fi