#!/bin/bash
for CORE in *.core ; do
	if ! test -f ${CORE%.core}.gdbbt ; then
		# get package name
		COMMAND=$(gdb --core=$CORE </dev/null 2>/dev/null | sed -n 's/Core was generated by `\([^ '\'']*\).*$/\1/p')
		# install debuginfos
		gdb --core=$CORE </dev/null 2>&1 >/dev/null | eval zypper install $(sed -n 's/Try: zypper install//p')
		# generate backtraces
		gdb --core=$CORE -x ${0%.sh}.gdbcmd $COMMAND 2>/dev/null | sed -n '/^Core was generated/,$p' >${CORE%.core}.gdbbt
	fi
done
