postgresql/src/tools/ci/cores_backtrace.sh
Andres Freund 93d9734946 ci: Add continuous integration for github repositories via cirrus-ci.
Currently FreeBSD, Linux, macOS and Windows (Visual Studio) are tested.

The main goal of this integration is to make it easier to test in-development
patches across multiple platforms. This includes improving the testing done
automatically by cfbot [1] for commitfest entries.  It is *not* the goal to
supersede the buildfarm.

cirrus-ci [2] was chosen because it was already in use for cfbot, allows using
full VMs, has good OS coverage and allows accessing the full test results
without authentication (like a github account).  It might be worth adding
support for further CI providers, particularly ones supporting other git
forges, in the future.

To keep CI times tolerable, most platforms use pre-generated images. Some
platforms use containers, others use full VMs.

For instructions on how to enable the CI integration in a repository and
further details, see src/tools/ci/README

[1] http://cfbot.cputube.org/
[2] https://cirrus-ci.org/

Author: Andres Freund <andres@anarazel.de>
Author: Thomas Munro <tmunro@postgresql.org>
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-By: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-By: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-By: Thomas Munro <tmunro@postgresql.org>
Reviewed-By: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://postgr.es/m/20211001222752.wrz7erzh4cajvgp6@alap3.anarazel.de
2021-12-30 19:02:44 -08:00

50 lines
1.2 KiB
Bash
Executable file

#! /bin/sh
if [ $# -ne 2 ]; then
echo "cores_backtrace.sh <os> <directory>"
exit 1
fi
os=$1
directory=$2
case $os in
freebsd|linux|macos)
;;
*)
echo "unsupported operating system ${os}"
exit 1
;;
esac
first=1
for corefile in $(find "$directory" -type f) ; do
if [ "$first" -eq 1 ]; then
first=0
else
# to make it easier to separate the different crash reports
echo -e '\n\n'
fi
if [ "$os" = 'macos' ]; then
lldb -c $corefile --batch -o 'thread backtrace all' -o 'quit'
else
auxv=$(gdb --quiet --core ${corefile} --batch -ex 'info auxv' 2>/dev/null)
if [ $? -ne 0 ]; then
echo "could not process ${corefile}"
continue
fi
if [ "$os" = 'freebsd' ]; then
binary=$(echo "$auxv" | grep AT_EXECPATH | perl -pe "s/^.*\"(.*)\"\$/\$1/g")
elif [ "$os" = 'linux' ]; then
binary=$(echo "$auxv" | grep AT_EXECFN | perl -pe "s/^.*\"(.*)\"\$/\$1/g")
else
echo 'should not get here'
exit 1
fi
echo "dumping ${corefile} for ${binary}"
gdb --batch --quiet -ex "thread apply all bt full" -ex "quit" "$binary" "$corefile" 2>/dev/null
fi
done