From b498af4204bd832e11ffc87fe1999f113cc29a87 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Thu, 6 Nov 2025 17:25:04 +1300 Subject: 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 Discussion: https://postgr.es/m/CAN55FZ36R74TZ8RKsFueYwLxGKDAm3LU2FHM_ZUCSB6imd3vYA@mail.gmail.com Backpatch-through: 18 --- src/tools/ci/cores_backtrace.sh | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/tools/ci/cores_backtrace.sh b/src/tools/ci/cores_backtrace.sh index 54607415258..cb325f21156 100755 --- a/src/tools/ci/cores_backtrace.sh +++ b/src/tools/ci/cores_backtrace.sh @@ -1,12 +1,18 @@ #! /bin/sh -if [ $# -ne 2 ]; then +os=$1 +directory=$2 +executable_directory=$3 + +if [ "$os" != 'openbsd' ] && [ $# -ne 2 ]; then echo "cores_backtrace.sh " exit 1 fi -os=$1 -directory=$2 +if [ "$os" = 'openbsd' ] && [ $# -ne 3 ]; then + echo "cores_backtrace.sh " + exit 1 +fi case $os in freebsd|linux|macos|netbsd|openbsd) @@ -17,6 +23,10 @@ case $os in ;; esac +if [ "$os" = 'openbsd' ]; then + export PATH="${executable_directory}:${PATH}" +fi + first=1 for corefile in $(find "$directory" -type f) ; do if [ "$first" -eq 1 ]; then @@ -26,8 +36,21 @@ for corefile in $(find "$directory" -type f) ; do echo -e '\n\n' fi - if [ "$os" = 'macos' ] || [ "$os" = 'openbsd' ]; then + if [ "$os" = 'macos' ]; then 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 . + 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 auxv=$(gdb --quiet --core ${corefile} --batch -ex 'info auxv' 2>/dev/null) if [ $? -ne 0 ]; then -- cgit v1.2.3