Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / solenv / bin / gdb-core-bt.sh
blob0d21dda88ccf5328c710248bb63567c685de9af4
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 "$(ls "$COREDIR"/core* 2>/dev/null | 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 echo "thread apply all backtrace full" > "$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