#!/bin/bash
if test $# == 2; then
	if test -f $1 && test -f $2; then
		gdb -batch-silent \
			-ex "set logging overwrite on" \
			-ex "set pagination off" \
			-ex "set print elements 0" \
			-ex "set print null-stop" \
			-ex "set print pretty on" \
			-ex "echo Program terminated with signal" \
			-ex "print $_siginfo.si_signo" \
			-ex "echo backtrace:\n" \
			-ex "bt" \
			-ex "echo backtrace full:\n" \
			-ex "bt full" \
			-ex "quit" \
			$1 $2 2>&1 |egrep -v "\[New LWP"
	else 
		echo "Either [$1] or [$2] could not be found"
	fi
else
	echo "$0"
	echo "-----------------------------"
	echo "Usage  : $0 [localtion asterisk executable] [core dump location]"
	echo "Example: $0 /usr/sbin/asterisk /tmp/core.astserv1-2012-02-02T11:16:43+0100"
fi

