bump product version to 6.4.0.3
[LibreOffice.git] / solenv / bin / gdb-core-bt.sh
blob2216e2aba5e588fbaa1d69f151591c03047021f5
1 #!/bin/sh
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/.
12 EXECUTABLE=${1}
13 COREDIR=${2}
14 EXITCODE=${3}
16 if test -n "$(which gdb)"
17 then
18 found=
19 for COREFILE in "$COREDIR"/core*
21 if [ -f "$COREFILE" ]
22 then
23 printf '\nIt looks like %s generated %s\nBacktraces:\n' \
24 "$EXECUTABLE" "$COREFILE"
25 GDBCOMMANDFILE=$(mktemp)
26 printf "info registers\nthread apply all backtrace full\n" \
27 >"$GDBCOMMANDFILE"
28 guess=$(file "$COREFILE")
29 guess=${guess#* execfn: \'}
30 guess=${guess%%\'*}
31 if [ ! -x "$guess" ]; then guess=$EXECUTABLE; fi
32 gdb -iex "add-auto-load-safe-path ${INSTDIR?}" -x "$GDBCOMMANDFILE" --batch "$guess" \
33 "$COREFILE" && found=x
34 rm "$GDBCOMMANDFILE"
35 echo
37 done
38 if [ -z "$found" -a "$EXITCODE" -ge 128 ]; then
39 echo
40 echo "No core file identified in directory ${COREDIR}"
41 echo "To show backtraces for crashes during test execution,"
42 echo "enable core files with:"
43 echo
44 echo " ulimit -c unlimited"
45 echo
46 exit 1
48 else
49 echo "You need gdb in your path to show backtraces"
50 exit 1