@ -1,12 +1,18 @@
#! /bin/sh
#! /bin/sh
if [ $# -ne 2 ] ; then
os = $1
directory = $2
executable_directory = $3
if [ " $os " != 'openbsd' ] && [ $# -ne 2 ] ; then
echo "cores_backtrace.sh <os> <directory>"
echo "cores_backtrace.sh <os> <directory>"
exit 1
exit 1
fi
fi
os = $1
if [ " $os " = 'openbsd' ] && [ $# -ne 3 ] ; then
directory = $2
echo "cores_backtrace.sh <os> <core_directory> <executable_directory>"
exit 1
fi
case $os in
case $os in
freebsd| linux| macos| netbsd| openbsd)
freebsd| linux| macos| netbsd| openbsd)
@ -17,6 +23,10 @@ case $os in
; ;
; ;
esac
esac
if [ " $os " = 'openbsd' ] ; then
export PATH = " ${ executable_directory } : ${ PATH } "
fi
first = 1
first = 1
for corefile in $( find " $directory " -type f) ; do
for corefile in $( find " $directory " -type f) ; do
if [ " $first " -eq 1 ] ; then
if [ " $first " -eq 1 ] ; then
@ -26,8 +36,21 @@ for corefile in $(find "$directory" -type f) ; do
echo -e '\n\n'
echo -e '\n\n'
fi
fi
if [ " $os " = 'macos' ] || [ " $os " = 'openbsd' ] ; then
if [ " $os " = 'macos' ] ; then
lldb -c $corefile --batch -o 'thread backtrace all' -o 'quit'
lldb -c $corefile --batch -o 'thread backtrace all' -o 'quit'
elif [ " $os " = 'openbsd' ] ; then
# OpenBSD's ELF format doesn't include executable information, so we
# search for the executable manually in <executable_directory>.
filename = $( basename " $corefile " )
base = $( echo " $filename " | sed 's/\.core.*$//' )
binary = $( which " ${ base } " )
if [ -z " $binary " ] ; then
echo " executable ${ base } not found in ${ PATH } , running 'lldb' without debug information "
lldb -c " $corefile " --batch -o 'thread backtrace all' -o 'quit'
else
lldb " $binary " -c " $corefile " --batch -o 'thread backtrace all' -o 'quit'
fi
else
else
auxv = $( gdb --quiet --core ${ corefile } --batch -ex 'info auxv' 2>/dev/null)
auxv = $( gdb --quiet --core ${ corefile } --batch -ex 'info auxv' 2>/dev/null)
if [ $? -ne 0 ] ; then
if [ $? -ne 0 ] ; then