Skip to content

Commit c45963c

Browse files
committed
ci: Collect core files on NetBSD and OpenBSD
Support for NetBSD and OpenBSD operating systems have been added to CI in the prior commit. Now add support for collect core files and generating backtraces using for all core files. Author: Nazir Bilal Yavuz <byavuz81@gmail.com> Discussion: https://postgr.es/m/CAN55FZ32ySyYa06k9MFd+VY5vHhUyBpvgmJUZae5PihjzaurVg@mail.gmail.com
1 parent e291573 commit c45963c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.cirrus.tasks.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,13 @@ task:
232232
CCACHE_DIR: /home/postgres/cache
233233

234234
PATH: /usr/sbin:$PATH
235+
CORE_DUMP_DIR: /var/crash
235236

236237
matrix:
237238
- name: NetBSD - Meson
238239
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*netbsd.*'
239240
env:
241+
OS_NAME: netbsd
240242
IMAGE_FAMILY: pg-ci-netbsd-postgres
241243
PKGCONFIG_PATH: '/usr/lib/pkgconfig:/usr/pkg/lib/pkgconfig'
242244
# initdb fails with: 'invalid locale settings' error on NetBSD.
@@ -253,12 +255,15 @@ task:
253255
- name: OpenBSD - Meson
254256
only_if: $CIRRUS_CHANGE_MESSAGE !=~ '.*\nci-os-only:.*' || $CIRRUS_CHANGE_MESSAGE =~ '.*\nci-os-only:[^\n]*openbsd.*'
255257
env:
258+
OS_NAME: openbsd
256259
IMAGE_FAMILY: pg-ci-openbsd-postgres
257260
PKGCONFIG_PATH: '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig'
258261
UUID: -Duuid=e2fs
259262
TCL: -Dtcl_version=tcl86
260263
setup_additional_packages_script: |
261264
#pkg_add -I ...
265+
# Always core dump to ${CORE_DUMP_DIR}
266+
set_core_dump_script: sysctl -w kern.nosuidcoredump=2
262267
<<: *openbsd_task_template
263268

264269
sysinfo_script: |
@@ -276,6 +281,10 @@ task:
276281
chown -R postgres:users /home/postgres
277282
mkdir -p ${CCACHE_DIR}
278283
chown -R postgres:users ${CCACHE_DIR}
284+
setup_core_files_script: |
285+
mkdir -p ${CORE_DUMP_DIR}
286+
chmod -R 770 ${CORE_DUMP_DIR}
287+
chown -R postgres:users ${CORE_DUMP_DIR}
279288
280289
# -Duuid=bsd is not set since 'bsd' uuid option
281290
# is not working on NetBSD & OpenBSD. See
@@ -306,6 +315,12 @@ task:
306315
307316
on_failure:
308317
<<: *on_failure_meson
318+
cores_script: |
319+
# Although we try to configure the OS to core dump inside
320+
# ${CORE_DUMP_DIR}, they may not obey this. So, move core files to the
321+
# ${CORE_DUMP_DIR} directory.
322+
find build/ -type f -name '*.core' -exec mv '{}' ${CORE_DUMP_DIR} \;
323+
src/tools/ci/cores_backtrace.sh ${OS_NAME} ${CORE_DUMP_DIR}
309324
310325
311326
# configure feature flags, shared between the task running the linux tests and

src/tools/ci/cores_backtrace.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ os=$1
99
directory=$2
1010

1111
case $os in
12-
freebsd|linux|macos)
12+
freebsd|linux|macos|netbsd|openbsd)
1313
;;
1414
*)
1515
echo "unsupported operating system ${os}"
@@ -26,7 +26,7 @@ for corefile in $(find "$directory" -type f) ; do
2626
echo -e '\n\n'
2727
fi
2828

29-
if [ "$os" = 'macos' ]; then
29+
if [ "$os" = 'macos' ] || [ "$os" = 'openbsd' ]; then
3030
lldb -c $corefile --batch -o 'thread backtrace all' -o 'quit'
3131
else
3232
auxv=$(gdb --quiet --core ${corefile} --batch -ex 'info auxv' 2>/dev/null)
@@ -37,6 +37,8 @@ for corefile in $(find "$directory" -type f) ; do
3737

3838
if [ "$os" = 'freebsd' ]; then
3939
binary=$(echo "$auxv" | grep AT_EXECPATH | perl -pe "s/^.*\"(.*)\"\$/\$1/g")
40+
elif [ "$os" = 'netbsd' ]; then
41+
binary=$(echo "$auxv" | grep AT_SUN_EXECNAME | perl -pe "s/^.*\"(.*)\"\$/\$1/g")
4042
elif [ "$os" = 'linux' ]; then
4143
binary=$(echo "$auxv" | grep AT_EXECFN | perl -pe "s/^.*\"(.*)\"\$/\$1/g")
4244
else

0 commit comments

Comments
 (0)