rsyslog/tools/coreanalysis.sh
Andre Lorbach 338cf9ed7f Tools: Added helper script to automatically search/select and analyze coredumps
The script uses GDB to output an analysis of a rsyslog coredump using the
installed binaries (/sbin/rsyslogd).
2015-08-27 03:25:16 -07:00

43 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
#
# this shell script provides automatic coredump analysis with gdb.
# begun 2015-10-14 by alorbach
# This file is part of the rsyslog project, released under ASL 2.0
echo "----------------------------------"
echo "--- Coredump Analysis with GDB ---"
echo "----------------------------------"
read -p "Where are the core files localed (default /)?" DIRECTORY
if [ "$DIRECTORY" == "" ]; then
DIRECTORY="/"
fi
COREFILES=`ls $DIRECTORY/core* 2> /dev/null`
# &> /dev/null`
select COREFILE in $COREFILES
do
echo "Which coredump do you want to analyse? "
break;
done
# Check for found core files
if [ "$COREFILE" == "" ]; then
echo "Failed to find any coredump files in $DIRECTORY or invalid selection."
exit;
fi
# generating tmp commandfile
echo "Trying to analyze core for main rsyslogd binary"
echo "set pagination off" >gdb.in
echo "core $COREFILE" >>gdb.in
echo "info thread" >> gdb.in
echo "thread apply all bt full" >> gdb.in
echo "q" >> gdb.in
# Run GDB with commandfile
gdb /usr/sbin/rsyslogd < gdb.in
# rm tmp commandfile
rm gdb.in