Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 178 lines (148 sloc) 3.912 kB
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
1 #!/bin/sh
2
c4d1e57 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1589 5dc97367-9…
alobbs authored
3 # Actions for Cherokee-Panic:
4 # mail - mail the error. You need a working MTA in the system.
5 # stdout - just print it
6 #
7 if test "x$CHEROKEE_PANIC_OUTPUT" != "x"; then
8 action="$CHEROKEE_PANIC_OUTPUT"
8daf1d1 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@556 5dc97367-97…
alobbs authored
9 else
c4d1e57 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1589 5dc97367-9…
alobbs authored
10 if [ -x /usr/sbin/sendmail ]; then
11 action=mail
12 else
13 action=stdout
14 fi
8daf1d1 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@556 5dc97367-97…
alobbs authored
15 fi
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
16
937a4da @alobbs Couple of misc improvements: 1.- redirect stderr to stdout, so error
alobbs authored
17 # Redirect stderr to stdout
18 exec 2>&1
19
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
20 # Redirect all output to our mail command
21 (
22 # Check the OS
23 os=`uname`
24
25 # We must be given a pid to look at
fa88098 @alobbs Fixes a couple of 'bashisms'
alobbs authored
26 if [ x$1 = x ]; then
27 echo "$0 called with no arguments."
28 exit 1
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
29 else
30 pid=$1
31 fi
32
33 # Check for a second argument
34 if [ -n "$2" ]; then
35 action="$2"
36 fi
37
180408c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@918 5dc97367-97…
alobbs authored
38 # Mail header
39 if [ x$action = xmail ]; then
40 echo "To: root"
41 echo "Subject: Segfault in Cherokee"
42 echo
43 fi
44
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
45 if [ $os = "Linux" ]; then
c4d1e57 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1589 5dc97367-9…
alobbs authored
46 BINARYNAME=`readlink "/proc/$pid/exe"`
47 known_os=yes
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
48 elif [ $os = "SunOS" ]; then
c4d1e57 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1589 5dc97367-9…
alobbs authored
49 BINARYNAME=`perl -e "print readlink(\"/proc/$pid/path/a.out\");"`
50 known_os=yes
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
51 fi
52
180408c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@918 5dc97367-97…
alobbs authored
53 # Generic header for the report
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
54 echo "The Cherokee 'panic action' script, $0,"
55 echo "was called for pid $pid ($BINARYNAME)."
56 echo
c4d1e57 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1589 5dc97367-9…
alobbs authored
57
58 # Ensure /proc/$pid exists if it should
59 if test "x${known_os}" = "xyes"; then
60 if [ ! -d "/proc/$pid" ]; then
61 echo "$0: No such process: $pid"
62 exit 1
63 fi
7cf418f @alobbs Removes a lingering space character.
alobbs authored
64 if test "x${BINARYNAME}" = "x"; then
c4d1e57 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1589 5dc97367-9…
alobbs authored
65 echo "This means there was a problem with the program, such as a segfault."
66 echo "However, the executable could not be found for process $pid."
67 echo "It may have died unexpectedly, or you may not have permission to"
68 echo "debug the process."
69 exit 1
70 fi
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
71 fi
72
73 # Check the debugger
d41af52 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1618 5dc97367-9…
alobbs authored
74 gdb=`which gdb`
75 dbx=`which dbx`
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
76
77 if [ x$gdb != x ]; then
78 debugger=$gdb
79 elif [ x$dbx != x ]; then
80 debugger=$dbx
81 else
82 # No debugger
83 echo "This means there was a problem with the program, such as a segfault."
84 echo "However, gdb was not found on your system, so the error could not be"
85 echo "debugged. Please install the gdb package so that debugging information is"
86 echo "available the next time such a problem occurs."
87 exit 1
88 fi
89
90 echo "Below is a backtrace for this process generated with gdb, which shows"
91 echo "the state of the program at the time the error occured. You are"
92 echo "encouraged to submit this information as a bug report in the Cherokee"
e8c75f5 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@438 5dc97367-97…
alobbs authored
93 echo "bug traq system: http://bugs.cherokee-project.com"
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
94 echo
95 echo "Operating System: `uname -a`"
96 echo "Debugger: $debugger"
97 echo
98
99 # Get the backtrace
100 if [ x$debugger = x$gdb ]; then
937a4da @alobbs Couple of misc improvements: 1.- redirect stderr to stdout, so error
alobbs authored
101
102 # Use /dev/shm as temp dir
103 test -d /dev/shm && \
104 TMPDIR=/dev/shm || \
105 TMPDIR=/var/tmp
106
107 tmp_cmd=`mktemp "$TMPDIR/chrk.XXXXXX"` || (
108 echo "ERROR: Couldn't create temp file in ${TMPDIR}"
109 exit 1
110 )
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
111
937a4da @alobbs Couple of misc improvements: 1.- redirect stderr to stdout, so error
alobbs authored
112 ( echo "set height 0"
113 echo "print cherokee_version"
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
114 echo "thread apply all bt full"
115 echo "quit" ) >> $tmp_cmd
116
fa88098 @alobbs Fixes a couple of 'bashisms'
alobbs authored
117 if [ x$BINARYNAME = x ]; then
c4d1e57 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1589 5dc97367-9…
alobbs authored
118 $gdb -x $tmp_cmd -batch --pid=$pid
119 else
120 $gdb -x $tmp_cmd -batch "$BINARYNAME" "$pid"
121 fi
937a4da @alobbs Couple of misc improvements: 1.- redirect stderr to stdout, so error
alobbs authored
122
123 rm -f $tmp_cmd
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
124
125 elif [ x$debugger = x$dbx ]; then
be9cbb3 @alobbs Improves the Solaris support. Now it call a few Solaris utilities to
alobbs authored
126 #Solaris
127
128 echo "Related processes were:"
129 /usr/bin/ptree $pid
130 echo
131
132 echo "Stack(s) were:"
133 /usr/bin/pstack $pid
134 echo
135
136 echo "Flags were:"
137 /usr/bin/pflags $pid
138 echo
139
140 echo "Credentials were:"
141 /usr/bin/pcred $pid
142 echo
143
144 echo "Libraries used were:"
145 /usr/bin/pldd $pid
146 echo
147
148 echo "Signal-handler settings were:"
149 /usr/bin/psig $pid
150 echo
151
152 echo "Files and devices in use were:"
153 /usr/bin/pfiles $pid
154 echo
155
156 echo "Directory in use was:"
157 /usr/bin/pwdx $pid
158 echo
159
160 echo "Backtrace"
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
161 $dbx -c "print (char *)cherokee_version; where -v -l ; quit" "$BINARYNAME" "$pid"
be9cbb3 @alobbs Improves the Solaris support. Now it call a few Solaris utilities to
alobbs authored
162 echo
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
163 fi
164
165 ) | (
166 case "$action" in
167 mail)
180408c @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@918 5dc97367-97…
alobbs authored
168 /usr/sbin/sendmail -t
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
169 ;;
c4d1e57 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1589 5dc97367-9…
alobbs authored
170 stdout)
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
171 cat -
172 ;;
173 *)
b14a9eb @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@917 5dc97367-97…
alobbs authored
174 echo "ERROR: Wrong action: \"$action\""
ae9d971 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
alobbs authored
175 exit 1
176 esac;
177 )
Something went wrong with that request. Please try again.