forked from signalwire/freeswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfscore_pb
executable file
·183 lines (148 loc) · 4.16 KB
/
fscore_pb
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/sh
arg=$1
shift
if [ -f "config.status" ] ; then
prefix=$(cat config.status | grep @prefix@ | awk -F, '{print $3}')
fi
if [ -f "config.status" -a -z "$prefix" ] ; then
prefix=$(cat config.status | grep '"prefix"' | awk -F\" '{print $4}')
fi
if [ -z "$prefix" -a -d "/usr/local/freeswitch" ] ; then
prefix="/usr/local/freeswitch"
fi
if [ -z "$prefix" -a -d "/opt/freeswitch" ] ; then
prefix="/opt/freeswitch"
fi
if [ -z "$prefix" ] ; then
prefix=$FS_PREFIX
fi
if [ -z "$prefix" -a -f "./bin/freeswitch" ] ; then
prefix=`pwd`
fi
if [ -z "$prefix" ] ; then
echo "Unable to locate freeswitch prefix directory."
exit 255
fi
if [ "$arg" = "gcore" ] ; then
user=$1
shift
fspid=`cat $prefix/run/freeswitch.pid`
echo "pulling gcore $fspid"
gcore -o core $fspid
else
user=$arg
fi
core=`ls -1t core* | head -1 2> /dev/null`
if [ -z "$core" ] ; then
core=`ls -1 core 2> /dev/null`
fi
if [ -z "$core" ] ; then
core=`ls -1 freeswitch.core 2> /dev/null`
fi
if [ -z "$core" ] ; then
echo "You must be in the current directory with a core file from FreeSWITCH!"
exit 255
fi
if [ -x `which gdb` ] ; then
echo "Found gdb"
else
echo "Unable to locate gdb, is it installed?"
exit 255
fi
echo "core is $core"
line="--------------------------------------------------------------------------------"
mypwd=`pwd`
tmpdir=/tmp/fscore_pb.tmp
post_file=$mypwd/fscore_pb.post
if [ -z $user ] ; then
user=$SUDO_USER
fi
if [ -z $user ] ; then
user=$USER
fi
if [ -z $user ] ; then
user="anon"
fi
post_cmd=""
#command -v wget >/dev/null 2>&1
#if [ $? -eq 0 ]; then
# post_cmd="curl -d name=fscore_pb --data-urlencode text@$post_file https://newpastebin.freeswitch.org/api/create"
# 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"
# echo -n "paste=Send&remember=0&poster=$user&format=none&expiry=f&code2=" > $post_file
#fi
if [ -z "$post_cmd" ]; then
command -v curl >/dev/null 2>&1
if [ $? -eq 0 ]; then
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"
# 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"
fi
fi
if [ -z "$post_cmd" ]; then
echo "Unable to locate curl."
exit 255
fi
echo "Gathering Data Please Wait........."
UNAME=`uname`;
#Linux
if [ "${UNAME}" = "Linux" ]; then
echo "LSB RELEASE:" >> $post_file
echo $line >> $post_file
if [ -f /etc/redhat-release ]; then
cat /etc/redhat-release >> $post_file
else
lsb_release -a >> $post_file
fi
echo "CPU INFO:" >> $post_file
echo $line >> $post_file
cat /proc/cpuinfo >> $post_file
#Mac
elif [ "${UNAME}" = "Darwin" ]; then
system_profiler SPSoftwareDataType SPHardwareDataType >> $post_file
fi;
echo "GIT INFO:" >> $post_file
echo $line >> $post_file
echo -n "Revision: " >> $post_file
if [ -d ".git" ] ; then
git log -1 | cat >> $post_file
printf "\n\n\n" >> $post_file
git status >> $post_file
else
echo "Not run from an git managed directory." >> $post_file
fi
echo "GDB BACKTRACE:" >> $post_file
echo $line >> $post_file
cat > fscore_pb.$$.gdb <<EOF
echo \n\n
set pagination off
echo Thread Info\n
echo $line\n
info threads
echo Stack Trace\n
echo $line
bt
echo \n\n\n\n Stack Trace (full)\n
echo $line\n
bt full
echo \n\n\n\n Stack Trace (all threads)\n
echo $line\n
thread apply all bt
echo \n\n\n\n Stack Trace (all threads) (full)\n
echo $line\n
thread apply all bt full
quit
EOF
gdb $prefix/bin/freeswitch `echo $core | tail -n1` -x fscore_pb.$$.gdb 1 >> $post_file 2>/dev/null
rm fscore_pb.$$.gdb
rm -fr $tmpdir
mkdir -p $tmpdir
cd $tmpdir
echo $post_cmd
$post_cmd
mv $post_file $tmpdir
echo "Finished."
if [ -e /tmp/fscore_pb.tmp/pb_out ]; then
pb=`cat /tmp/fscore_pb.tmp/pb_out`
echo "Please report $pb to the developers."
else
echo "Please check recent posts on http://pastebin.freeswitch.org/ and find your issue to report to the developers."
fi