summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xusr.sbin/crashinfo/crashinfo.sh35
1 files changed, 27 insertions, 8 deletions
diff --git a/usr.sbin/crashinfo/crashinfo.sh b/usr.sbin/crashinfo/crashinfo.sh
index 557d810..2a8419d 100755
--- a/usr.sbin/crashinfo/crashinfo.sh
+++ b/usr.sbin/crashinfo/crashinfo.sh
@@ -35,6 +35,22 @@ usage()
exit 1
}
+# Run a single gdb command against a kernel file in batch mode.
+# The kernel file is specified as the first argument and the command
+# is given in the remaining arguments.
+gdb_command()
+{
+ local k
+
+ k=$1 ; shift
+
+ if [ -x /usr/local/bin/gdb ]; then
+ /usr/local/bin/gdb -batch -ex "$@" $k
+ else
+ echo -e "$@" | /usr/bin/gdb -x /dev/stdin -batch $k
+ fi
+}
+
find_kernel()
{
local ivers k kvers
@@ -55,8 +71,8 @@ find_kernel()
# Look for a matching kernel version.
for k in `sysctl -n kern.bootfile` $(ls -t /boot/*/kernel); do
- kvers=$(echo 'printf " Version String: %s", version' | \
- gdb -x /dev/stdin -batch $k 2>/dev/null)
+ kvers=$(gdb_command $k 'printf " Version String: %s", version' \
+ 2>/dev/null)
if [ "$ivers" = "$kvers" ]; then
KERNEL=$k
break
@@ -151,11 +167,10 @@ echo "Writing crash summary to $FILE."
umask 077
# Simulate uname
-ostype=$(echo -e printf '"%s", ostype' | gdb -x /dev/stdin -batch $KERNEL)
-osrelease=$(echo -e printf '"%s", osrelease' | gdb -x /dev/stdin -batch $KERNEL)
-version=$(echo -e printf '"%s", version' | gdb -x /dev/stdin -batch $KERNEL | \
- tr '\t\n' ' ')
-machine=$(echo -e printf '"%s", machine' | gdb -x /dev/stdin -batch $KERNEL)
+ostype=$(gdb_command $KERNEL 'printf "%s", ostype')
+osrelease=$(gdb_command $KERNEL 'printf "%s", osrelease')
+version=$(gdb_command $KERNEL 'printf "%s", version' | tr '\t\n' ' ')
+machine=$(gdb_command $KERNEL 'printf "%s", machine')
exec > $FILE 2>&1
@@ -174,7 +189,11 @@ file=`mktemp /tmp/crashinfo.XXXXXX`
if [ $? -eq 0 ]; then
echo "bt" >> $file
echo "quit" >> $file
- kgdb $KERNEL $VMCORE < $file
+ if [ -x /usr/local/bin/kgdb ]; then
+ /usr/local/bin/kgdb $KERNEL $VMCORE < $file
+ else
+ kgdb $KERNEL $VMCORE < $file
+ fi
rm -f $file
echo
fi
OpenPOWER on IntegriCloud