2
0

fscore_pb 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #!/bin/sh
  2. arg=$1
  3. shift
  4. if [ -f "config.status" ] ; then
  5. prefix=$(cat config.status | grep @prefix@ | awk -F, '{print $3}')
  6. fi
  7. if [ -f "config.status" -a -z "$prefix" ] ; then
  8. prefix=$(cat config.status | grep '"prefix"' | awk -F\" '{print $4}')
  9. fi
  10. if [ -z "$prefix" -a -d "/usr/local/freeswitch" ] ; then
  11. prefix="/usr/local/freeswitch"
  12. fi
  13. if [ -z "$prefix" -a -d "/opt/freeswitch" ] ; then
  14. prefix="/opt/freeswitch"
  15. fi
  16. if [ -z "$prefix" ] ; then
  17. prefix=$FS_PREFIX
  18. fi
  19. if [ -z "$prefix" -a -f "./bin/freeswitch" ] ; then
  20. prefix=`pwd`
  21. fi
  22. if [ -z "$prefix" ] ; then
  23. echo "Unable to locate freeswitch prefix directory."
  24. exit 255
  25. fi
  26. if [ "$arg" = "gcore" ] ; then
  27. user=$1
  28. shift
  29. fspid=`cat $prefix/run/freeswitch.pid`
  30. echo "pulling gcore $fspid"
  31. gcore -o core $fspid
  32. else
  33. user=$arg
  34. fi
  35. core=`ls -1t core* | head -1 2> /dev/null`
  36. if [ -z "$core" ] ; then
  37. core=`ls -1 core 2> /dev/null`
  38. fi
  39. if [ -z "$core" ] ; then
  40. core=`ls -1 freeswitch.core 2> /dev/null`
  41. fi
  42. if [ -z "$core" ] ; then
  43. echo "You must be in the current directory with a core file from FreeSWITCH!"
  44. exit 255
  45. fi
  46. if [ -x `which gdb` ] ; then
  47. echo "Found gdb"
  48. else
  49. echo "Unable to locate gdb, is it installed?"
  50. exit 255
  51. fi
  52. echo "core is $core"
  53. line="--------------------------------------------------------------------------------"
  54. mypwd=`pwd`
  55. tmpdir=/tmp/fscore_pb.tmp
  56. post_file=$mypwd/fscore_pb.post
  57. if [ -z $user ] ; then
  58. user=$SUDO_USER
  59. fi
  60. if [ -z $user ] ; then
  61. user=$USER
  62. fi
  63. if [ -z $user ] ; then
  64. user="anon"
  65. fi
  66. post_cmd=""
  67. command -v wget >/dev/null 2>&1
  68. if [ $? -eq 0 ]; then
  69. post_cmd="wget --output-file=/dev/null --output-document=/tmp/fscore_pb.tmp/pb_out --http-user=pastebin --http-password=freeswitch https://pastebin.freeswitch.org --post-file=$post_file"
  70. echo -n "paste=Send&remember=0&poster=$user&format=none&expiry=f&code2=" > $post_file
  71. fi
  72. if [ -z "$post_cmd" ]; then
  73. command -v curl >/dev/null 2>&1
  74. if [ $? -eq 0 ]; then
  75. post_cmd="curl -o /tmp/fscore_pb.tmp/pb_out --user pastebin:freeswitch http://pastebin.freeswitch.org -d paste=Send -d remember=0 -d poster=$user -d format=none -d expiry=f --data-urlencode code2@$post_file"
  76. fi
  77. fi
  78. if [ -z "$post_cmd" ]; then
  79. echo "Unable to locate wget or curl."
  80. exit 255
  81. fi
  82. echo "Gathering Data Please Wait........."
  83. UNAME=`uname`;
  84. #Linux
  85. if [ "${UNAME}" = "Linux" ]; then
  86. echo "LSB RELEASE:" >> $post_file
  87. echo $line >> $post_file
  88. if [ -f /etc/redhat-release ]; then
  89. cat /etc/redhat-release >> $post_file
  90. else
  91. lsb_release -a >> $post_file
  92. fi
  93. echo "CPU INFO:" >> $post_file
  94. echo $line >> $post_file
  95. cat /proc/cpuinfo >> $post_file
  96. #Mac
  97. elif [ "${UNAME}" = "Darwin" ]; then
  98. system_profiler SPSoftwareDataType SPHardwareDataType >> $post_file
  99. fi;
  100. echo "GIT INFO:" >> $post_file
  101. echo $line >> $post_file
  102. echo -n "Revision: " >> $post_file
  103. if [ -d ".git" ] ; then
  104. git log -1 | cat >> $post_file
  105. printf "\n\n\n" >> $post_file
  106. git status >> $post_file
  107. else
  108. echo "Not run from an git managed directory." >> $post_file
  109. fi
  110. echo "GDB BACKTRACE:" >> $post_file
  111. echo $line >> $post_file
  112. cat > fscore_pb.$$.gdb <<EOF
  113. echo \n\n
  114. set pagination off
  115. echo Thread Info\n
  116. echo $line\n
  117. info threads
  118. echo Stack Trace\n
  119. echo $line
  120. bt
  121. echo \n\n\n\n Stack Trace (full)\n
  122. echo $line\n
  123. bt full
  124. echo \n\n\n\n Stack Trace (all threads)\n
  125. echo $line\n
  126. thread apply all bt
  127. echo \n\n\n\n Stack Trace (all threads) (full)\n
  128. echo $line\n
  129. thread apply all bt full
  130. quit
  131. EOF
  132. gdb $prefix/bin/freeswitch `echo $core | tail -n1` -x fscore_pb.$$.gdb 1 >> $post_file 2>/dev/null
  133. rm fscore_pb.$$.gdb
  134. rm -fr $tmpdir
  135. mkdir -p $tmpdir
  136. cd $tmpdir
  137. echo $post_cmd
  138. $post_cmd
  139. mv $post_file $tmpdir
  140. echo "Finished."
  141. if [ -e /tmp/fscore_pb.tmp/pb_out ]; then
  142. pb=`cat /tmp/fscore_pb.tmp/pb_out | grep parent_pid | awk -F \" '{print $6}'`
  143. echo "Please report http://pastebin.freeswitch.org/$pb to the developers."
  144. else
  145. echo "Please check recent posts on http://pastebin.freeswitch.org/ and find your issue to report to the developers."
  146. fi