Skip to content

Commit b498af4

Browse files
committed
ci: Improve OpenBSD core dump backtrace handling.
Since OpenBSD core dumps do not embed executable paths, the script now searches for the corresponding binary manually within the specified directory before invoking LLDB. This is imperfect but should find the right executable in practice, as needed for meaningful backtraces. Author: Nazir Bilal Yavuz <[email protected]> Discussion: https://postgr.es/m/CAN55FZ36R74TZ8RKsFueYwLxGKDAm3LU2FHM_ZUCSB6imd3vYA@mail.gmail.com Backpatch-through: 18
1 parent d6c132d commit b498af4

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

.cirrus.tasks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ task:
328328
OS_NAME: openbsd
329329
IMAGE_FAMILY: pg-ci-openbsd-postgres
330330
PKGCONFIG_PATH: '/usr/lib/pkgconfig:/usr/local/lib/pkgconfig'
331+
CORE_DUMP_EXECUTABLE_DIR: $CIRRUS_WORKING_DIR/build/tmp_install/usr/local/pgsql/bin
331332

332333
MESON_FEATURES: >-
333334
-Dbsd_auth=enabled
@@ -396,7 +397,7 @@ task:
396397
# ${CORE_DUMP_DIR}, they may not obey this. So, move core files to the
397398
# ${CORE_DUMP_DIR} directory.
398399
find build/ -type f -name '*.core' -exec mv '{}' ${CORE_DUMP_DIR} \;
399-
src/tools/ci/cores_backtrace.sh ${OS_NAME} ${CORE_DUMP_DIR}
400+
src/tools/ci/cores_backtrace.sh ${OS_NAME} ${CORE_DUMP_DIR} ${CORE_DUMP_EXECUTABLE_DIR}
400401
401402
402403
# configure feature flags, shared between the task running the linux tests and

src/tools/ci/cores_backtrace.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#! /bin/sh
22

3-
if [ $# -ne 2 ]; then
3+
os=$1
4+
directory=$2
5+
executable_directory=$3
6+
7+
if [ "$os" != 'openbsd' ] && [ $# -ne 2 ]; then
48
echo "cores_backtrace.sh <os> <directory>"
59
exit 1
610
fi
711

8-
os=$1
9-
directory=$2
12+
if [ "$os" = 'openbsd' ] && [ $# -ne 3 ]; then
13+
echo "cores_backtrace.sh <os> <core_directory> <executable_directory>"
14+
exit 1
15+
fi
1016

1117
case $os in
1218
freebsd|linux|macos|netbsd|openbsd)
@@ -17,6 +23,10 @@ case $os in
1723
;;
1824
esac
1925

26+
if [ "$os" = 'openbsd' ]; then
27+
export PATH="${executable_directory}:${PATH}"
28+
fi
29+
2030
first=1
2131
for corefile in $(find "$directory" -type f) ; do
2232
if [ "$first" -eq 1 ]; then
@@ -26,8 +36,21 @@ for corefile in $(find "$directory" -type f) ; do
2636
echo -e '\n\n'
2737
fi
2838

29-
if [ "$os" = 'macos' ] || [ "$os" = 'openbsd' ]; then
39+
if [ "$os" = 'macos' ]; then
3040
lldb -c $corefile --batch -o 'thread backtrace all' -o 'quit'
41+
elif [ "$os" = 'openbsd' ]; then
42+
# OpenBSD's ELF format doesn't include executable information, so we
43+
# search for the executable manually in <executable_directory>.
44+
filename=$(basename "$corefile")
45+
base=$(echo "$filename" | sed 's/\.core.*$//')
46+
binary=$(which "${base}")
47+
48+
if [ -z "$binary" ]; then
49+
echo "executable ${base} not found in ${PATH}, running 'lldb' without debug information"
50+
lldb -c "$corefile" --batch -o 'thread backtrace all' -o 'quit'
51+
else
52+
lldb "$binary" -c "$corefile" --batch -o 'thread backtrace all' -o 'quit'
53+
fi
3154
else
3255
auxv=$(gdb --quiet --core ${corefile} --batch -ex 'info auxv' 2>/dev/null)
3356
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)