aboutsummaryrefslogtreecommitdiff
path: root/tools/Linux/xbmc.sh.in
blob: 9ccad4eaa5a39965b480ab985caa302ebec2ff3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/sh

#      Copyright (C) 2008-2010 Team XBMC
#      http://www.xbmc.org
#
#  This Program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with XBMC; see the file COPYING.  If not, write to
#  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#  http://www.gnu.org/copyleft/gpl.html

SAVED_ARGS="$@"
LIBDIR="@prefix@/lib"

# Check for some options used by this script
while [ "$#" -gt "0" ]
do
    case "$1" in
        --setlibdir)
            LIBDIR="$2"
            shift; shift
            ;;
        *)
            shift
            ;;
    esac
done

single_stacktrace()
{
  find $1 -maxdepth $2 -name 'core*' -exec \
      echo "=====>  Core file: {}" 2> /dev/null >> $FILE \; -exec \
      echo "        ========================================= " 2> /dev/null >> $FILE \; -exec \
      gdb "$LIBDIR/xbmc/xbmc.bin" --core={} --batch -ex "thread apply all bt" 2> /dev/null >> $FILE \; -exec \
      rm -f {} \;
}

print_crash_report()
{
  FILE="$HOME/xbmc_crashlog-`date +%Y%m%d_%H%M%S`.log"
  echo "############## XBMC CRASH LOG ###############" >> $FILE
  echo >> $FILE
  echo "################ SYSTEM INFO ################" >> $FILE
  echo -n " Date: " >> $FILE
  date >> $FILE
  echo " XBMC Options: $*" >> $FILE
  echo -n " Arch: " >> $FILE
  uname -m >> $FILE
  echo -n " Kernel: " >> $FILE
  uname -rvs >> $FILE
  echo -n " Release: " >> $FILE
  if which lsb_release > /dev/null; then
    echo >> $FILE
    lsb_release -a 2> /dev/null | sed -e 's/^/    /' >> $FILE
  else
    echo "lsb_release not available" >> $FILE
  fi
  echo "############## END SYSTEM INFO ##############" >> $FILE
  echo >> $FILE
  echo "############### STACK TRACE #################" >> $FILE
  single_stacktrace $PWD 1
  # Find in plugins directories
  if [ $XBMC_HOME ]; then
    BASEDIR=$XBMC_HOME
  else
    BASEDIR="$LIBDIR/xbmc/"
  fi
  single_stacktrace $BASEDIR 5
  # find in user xbmc dir
  single_stacktrace $HOME/.xbmc/ 5
  echo "############# END STACK TRACE ###############" >> $FILE
  echo >> $FILE
  echo "################# LOG FILE ##################" >> $FILE
  echo >> $FILE
  if [ -f ~/.xbmc/temp/xbmc.log ]
  then
    cat ~/.xbmc/temp/xbmc.log >> $FILE
    echo >> $FILE
  else
    echo "Logfile not found in the usual place." >> $FILE
    echo "Please attach it seperately." >> $FILE
    echo "Use pastebin.com or similar for forums or IRC." >> $FILE
  fi
  echo >> $FILE
  echo "############### END LOG FILE ################" >> $FILE
  echo >> $FILE
  echo "############ END XBMC CRASH LOG #############" >> $FILE
  echo "Crash report available at $FILE"
}

python @prefix@/share/xbmc/FEH.py "$SAVED_ARGS"
RET=$?
if [ $RET -ne 0 ]; then
  exit $RET
fi

# Output warning in case ulimit is unsupported by shell
eval ulimit -c unlimited
if [ ! $? = "0" ]; then
  echo "xbmc: ulimit is unsupported by this shell" 1>&2
fi

LOOP=1
while [ $(( $LOOP )) = "1" ]
do
  LOOP=0
  "$LIBDIR/xbmc/xbmc.bin" "$SAVED_ARGS"
  RET=$?
  if [ $(( $RET == 65 )) = "1" ]
  then # User requested to restart app
    LOOP=1
  elif [ $(( ($RET >= 131 && $RET <= 136) || $RET == 139 )) = "1" ]
  then # Crashed with core dump
    print_crash_report
  fi
done

exit $RET