Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / solenv / bin / gdb-core-bt.sh
blobec21fb1f37c4e549ae1134afc64756ac289f8f5e
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 if test "$(find "$COREDIR" -name "core*" | wc -l)" -eq 1
19 then
20 COREFILE=$(ls "$COREDIR"/core*)
21 echo
22 echo "It looks like ${EXECUTABLE} generated a core file at ${COREFILE}"
23 echo "Backtraces:"
24 GDBCOMMANDFILE=$(mktemp)
25 printf "info registers\nthread apply all backtrace full\n" > "$GDBCOMMANDFILE"
26 gdb -x "$GDBCOMMANDFILE" --batch "$EXECUTABLE" "$COREFILE"
27 rm "$GDBCOMMANDFILE"
28 echo
29 exit 0
30 elif [ "$EXITCODE" -ge 128 ]; then
31 echo
32 echo "No core file identified in directory ${COREDIR}"
33 echo "To show backtraces for crashes during test execution,"
34 echo "enable core files with:"
35 echo
36 echo " ulimit -c unlimited"
37 echo
38 exit 1
40 else
41 echo "You need gdb in your path to show backtraces"
42 exit 1