/tools/Linux/xbmc.sh.in

https://github.com/tmacreturns/XBMC_wireless_setup · Autoconf · 135 lines · 103 code · 9 blank · 23 comment · 16 complexity · 3a9dc82aa89178361e388caa71e0c1cf MD5 · raw file

  1. #!/bin/sh
  2. # Copyright (C) 2008-2010 Team XBMC
  3. # http://www.xbmc.org
  4. #
  5. # This Program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9. #
  10. # This Program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with XBMC; see the file COPYING. If not, write to
  17. # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. # http://www.gnu.org/copyleft/gpl.html
  19. SAVED_ARGS="$@"
  20. prefix="@prefix@"
  21. exec_prefix="@exec_prefix@"
  22. datarootdir="@datarootdir@"
  23. LIBDIR="@libdir@"
  24. # Check for some options used by this script
  25. while [ "$#" -gt "0" ]
  26. do
  27. case "$1" in
  28. --setlibdir)
  29. LIBDIR="$2"
  30. shift; shift
  31. ;;
  32. *)
  33. shift
  34. ;;
  35. esac
  36. done
  37. single_stacktrace()
  38. {
  39. # core filename is either "core.$PID" or "core"
  40. find "$1" -maxdepth $2 -name 'core*' | while read core; do
  41. LC_ALL=C gdb --core="$core" --batch 2> /dev/null | grep -q "^Core was generated by \`$LIBDIR/xbmc/xbmc.bin" || continue
  42. echo "=====> Core file: "$core" ($(stat -c%y "$core"))" >> $FILE
  43. echo " =========================================" >> $FILE
  44. gdb "$LIBDIR/xbmc/xbmc.bin" --core="$core" --batch -ex "thread apply all bt" 2> /dev/null >> $FILE
  45. rm -f "$core"
  46. done
  47. }
  48. print_crash_report()
  49. {
  50. FILE="$HOME/xbmc_crashlog-`date +%Y%m%d_%H%M%S`.log"
  51. echo "############## XBMC CRASH LOG ###############" >> $FILE
  52. echo >> $FILE
  53. echo "################ SYSTEM INFO ################" >> $FILE
  54. echo -n " Date: " >> $FILE
  55. date >> $FILE
  56. echo " XBMC Options: $*" >> $FILE
  57. echo -n " Arch: " >> $FILE
  58. uname -m >> $FILE
  59. echo -n " Kernel: " >> $FILE
  60. uname -rvs >> $FILE
  61. echo -n " Release: " >> $FILE
  62. if which lsb_release > /dev/null; then
  63. echo >> $FILE
  64. lsb_release -a 2> /dev/null | sed -e 's/^/ /' >> $FILE
  65. else
  66. echo "lsb_release not available" >> $FILE
  67. fi
  68. echo "############## END SYSTEM INFO ##############" >> $FILE
  69. echo >> $FILE
  70. echo "############### STACK TRACE #################" >> $FILE
  71. single_stacktrace "$PWD" 1
  72. # Find in plugins directories
  73. if [ $XBMC_HOME ]; then
  74. BASEDIR=$XBMC_HOME
  75. else
  76. BASEDIR="$LIBDIR/xbmc/"
  77. fi
  78. single_stacktrace "$BASEDIR" 5
  79. # find in user xbmc dir
  80. single_stacktrace $HOME/.xbmc/ 5
  81. echo "############# END STACK TRACE ###############" >> $FILE
  82. echo >> $FILE
  83. echo "################# LOG FILE ##################" >> $FILE
  84. echo >> $FILE
  85. if [ -f ~/.xbmc/temp/xbmc.log ]
  86. then
  87. cat ~/.xbmc/temp/xbmc.log >> $FILE
  88. echo >> $FILE
  89. else
  90. echo "Logfile not found in the usual place." >> $FILE
  91. echo "Please attach it seperately." >> $FILE
  92. echo "Use pastebin.com or similar for forums or IRC." >> $FILE
  93. fi
  94. echo >> $FILE
  95. echo "############### END LOG FILE ################" >> $FILE
  96. echo >> $FILE
  97. echo "############ END XBMC CRASH LOG #############" >> $FILE
  98. echo "Crash report available at $FILE"
  99. }
  100. python @datadir@/xbmc/FEH.py $SAVED_ARGS
  101. RET=$?
  102. if [ $RET -ne 0 ]; then
  103. exit $RET
  104. fi
  105. if which gdb >/dev/null 2>&1; then
  106. # Output warning in case ulimit is unsupported by shell
  107. eval ulimit -c unlimited
  108. if [ ! $? = "0" ]; then
  109. echo "xbmc: ulimit is unsupported by this shell" 1>&2
  110. fi
  111. fi
  112. LOOP=1
  113. while [ $(( $LOOP )) = "1" ]
  114. do
  115. LOOP=0
  116. "$LIBDIR/xbmc/xbmc.bin" $SAVED_ARGS
  117. RET=$?
  118. if [ $(( $RET == 65 )) = "1" ]
  119. then # User requested to restart app
  120. LOOP=1
  121. elif [ $(( ($RET >= 131 && $RET <= 136) || $RET == 139 )) = "1" ]
  122. then # Crashed with core dump
  123. print_crash_report
  124. fi
  125. done
  126. exit $RET