2
0

fscore_pb 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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="curl -d name=fscore_pb --data-urlencode text@$post_file https://newpastebin.freeswitch.org/api/create"
  70. # 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"
  71. # echo -n "paste=Send&remember=0&poster=$user&format=none&expiry=f&code2=" > $post_file
  72. #fi
  73. if [ -z "$post_cmd" ]; then
  74. command -v curl >/dev/null 2>&1
  75. if [ $? -eq 0 ]; then
  76. post_cmd="curl -o /tmp/fscore_pb.tmp/pb_out -d name=fscore_pb --data-urlencode text@$post_file https://pastebin.freeswitch.org/api/create"
  77. # 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"
  78. fi
  79. fi
  80. if [ -z "$post_cmd" ]; then
  81. echo "Unable to locate curl."
  82. exit 255
  83. fi
  84. echo "Gathering Data Please Wait........."
  85. UNAME=`uname`;
  86. #Linux
  87. if [ "${UNAME}" = "Linux" ]; then
  88. echo "LSB RELEASE:" >> $post_file
  89. echo $line >> $post_file
  90. if [ -f /etc/redhat-release ]; then
  91. cat /etc/redhat-release >> $post_file
  92. else
  93. lsb_release -a >> $post_file
  94. fi
  95. echo "CPU INFO:" >> $post_file
  96. echo $line >> $post_file
  97. cat /proc/cpuinfo >> $post_file
  98. #Mac
  99. elif [ "${UNAME}" = "Darwin" ]; then
  100. system_profiler SPSoftwareDataType SPHardwareDataType >> $post_file
  101. fi;
  102. echo "GIT INFO:" >> $post_file
  103. echo $line >> $post_file
  104. echo -n "Revision: " >> $post_file
  105. if [ -d ".git" ] ; then
  106. git log -1 | cat >> $post_file
  107. printf "\n\n\n" >> $post_file
  108. git status >> $post_file
  109. else
  110. echo "Not run from an git managed directory." >> $post_file
  111. fi
  112. echo "GDB BACKTRACE:" >> $post_file
  113. echo $line >> $post_file
  114. cat > fscore_pb.$$.gdb <<EOF
  115. echo \n\n
  116. set pagination off
  117. echo Thread Info\n
  118. echo $line\n
  119. info threads
  120. echo Stack Trace\n
  121. echo $line
  122. bt
  123. echo \n\n\n\n Stack Trace (full)\n
  124. echo $line\n
  125. bt full
  126. echo \n\n\n\n Stack Trace (all threads)\n
  127. echo $line\n
  128. thread apply all bt
  129. echo \n\n\n\n Stack Trace (all threads) (full)\n
  130. echo $line\n
  131. thread apply all bt full
  132. quit
  133. EOF
  134. gdb $prefix/bin/freeswitch `echo $core | tail -n1` -x fscore_pb.$$.gdb 1 >> $post_file 2>/dev/null
  135. rm fscore_pb.$$.gdb
  136. rm -fr $tmpdir
  137. mkdir -p $tmpdir
  138. cd $tmpdir
  139. echo $post_cmd
  140. $post_cmd
  141. mv $post_file $tmpdir
  142. echo "Finished."
  143. if [ -e /tmp/fscore_pb.tmp/pb_out ]; then
  144. pb=`cat /tmp/fscore_pb.tmp/pb_out`
  145. echo "Please report $pb to the developers."
  146. else
  147. echo "Please check recent posts on http://pastebin.freeswitch.org/ and find your issue to report to the developers."
  148. fi