Automated submission of kernel panic reports

Benjamin Lee ben at b1c1l1.com
Sun Nov 3 00:18:57 UTC 2013


On Tue, 29 Oct 2013 03:32:19 -0700, Colin Percival <cperciva at freebsd.org> wrote:
> Hi all,
> 
> I've written some code for automatically submitting kernel panic reports,
> and I'd like some feedback before I place it into the ports tree.

Just a style question, any reason not to place the file names into
variables?  Something like:

--- panicmail.orig      2013-11-02 16:47:42.117858435 -0700
+++ panicmail   2013-11-02 17:06:15.388951568 -0700
@@ -38,19 +38,23 @@
 panicmail_gather()
 {
        local tmpfile=`mktemp` || exit 1
+       local kernel_file=`sysctl -n kern.bootfile` || exit 1
+       local info_file="${dumpdir}/info.$1"
+       local vmcore_file="${dumpdir}/vmcore.$1"
+       local panicmail_file="${dumpdir}/panicmail.$1"
 
        # We want the dump header.
-       cat "${dumpdir}/info.$1" > "${dumpdir}/panicmail.$1"
-       echo >> "${dumpdir}/panicmail.$1"
+       cat "${info_file}" > "${panicmail_file}"
+       echo >> "${panicmail_file}"
 
        # And we want a backtrace (we should be able to pipe the commands
        # directly into kgdb, but that doesn't work with our /bin/sh):
-       echo "Backtrace:" >> "${dumpdir}/panicmail.$1"
+       echo "Backtrace:" >> "${panicmail_file}"
        echo bt > ${tmpfile}
        echo quit >> ${tmpfile}
-       kgdb -q `sysctl -n kern.bootfile` "${dumpdir}/vmcore.$1" \
-           < ${tmpfile} >> "${dumpdir}/panicmail.$1" 2> /dev/null
-       echo >> "${dumpdir}/panicmail.$1"
+       kgdb -q "${kernel_file}" "${vmcore_file}" \
+           < ${tmpfile} >> "${panicmail_file}" 2> /dev/null
+       echo >> "${panicmail_file}"
        rm ${tmpfile}
 }
 


-- 
Benjamin Lee
http://www.b1c1l1.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20131102/59095ef8/attachment.sig>


More information about the freebsd-hackers mailing list