4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
16 if test -n "$(which gdb)"
19 for COREFILE
in "$COREDIR"/core
*
23 guess
=$
(file "$COREFILE")
24 guess
=${guess#* execfn: \'}
26 if [ ! -x "$guess" ]; then guess
=$EXECUTABLE; fi
27 printf '\nIt looks like %s generated %s\nBacktraces:\n' \
29 GDBCOMMANDFILE
=$
(mktemp
)
30 printf "info registers\nthread apply all backtrace full\n" \
32 PYTHONWARNINGS
=default gdb
-iex "add-auto-load-safe-path ${INSTDIR?}" \
33 -x "$GDBCOMMANDFILE" --batch "$guess" "$COREFILE" && found
=x
38 if test -n "$WITH_COREDUMPCTL"; then
39 # Unfortunately `coredumpctl debug` only operates on the most recent core dump matching any
40 # given criteria, not on all core dumps matching those criteria; so get the PIDs of all core
41 # dumps matching the given COREDUMP_USER_UNIT (and for which a core dump is still present)
42 # first, and then iterate over them (though this introduces possibilities for some,
43 # hopefully unlikely and mostly harmless, races, like when core dumps disappear in between,
44 # or multiple matching core dumps have identical PIDs):
45 for i
in $
($COREDUMPCTL --json=short list COREDUMP_USER_UNIT
="$LIBO_TEST_UNIT".scope | \
46 $JQ -r 'map(select(.corefile=="present"))|map(.pid)|join(" ")')
48 GDBCOMMANDFILE
=$
(mktemp
)
49 printf 'info registers\nthread apply all backtrace full\n' >"$GDBCOMMANDFILE"
50 PYTHONWARNINGS
=default
$COREDUMPCTL debug \
51 COREDUMP_USER_UNIT
="$LIBO_TEST_UNIT".scope COREDUMP_PID
="$i" \
52 --debugger-arguments="-iex 'add-auto-load-safe-path ${INSTDIR?}' \
53 -x '$GDBCOMMANDFILE' --batch"
58 if [ -z "$found" -a "$EXITCODE" -ge 128 ]; then
60 echo "No core file identified in directory ${COREDIR}"
61 echo "To show backtraces for crashes during test execution,"
62 echo "enable core files with:"
64 echo " ulimit -c unlimited"
69 echo "You need gdb in your path to show backtraces"