Dap: fix several issues with the Disconnect operation (bgo#724656)
[banshee.git] / extras / banshee-gather-debug
blobaaf0cb7a97b82b57b6d78a2d64babb259163bcd3
1 #!/bin/bash
3 STRACE_DURATION=60
4 BANSHEE_PID=0
5 BANSHEE_CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/banshee-1"
6 BANSHEE_LOG_FILE="${BANSHEE_CONFIG_DIR}/log"
8 OUTPUT_FILE="banshee-debugging-$(date +%F-%H-%M-%S)"
9 [[ -d $HOME/Desktop ]] \
10 && OUTPUT_FILE="$HOME/Desktop/$OUTPUT_FILE" \
11 || OUTPUT_FILE="$HOME/$OUTPUT_FILE"
13 function bail () {
14 echo "ERROR: $1" 2>&1
15 exit 1
18 function begin_log () {
19 (echo
20 echo "*************************************************************"
21 echo "$1"
22 echo "*************************************************************"
23 echo)1>&2
26 function find_pid () {
27 BANSHEE_PID=`(pidof banshee 2>/dev/null ||
28 (ps -eo pid,cmd | awk '/mono.*banshee\/.*.exe/ { print $1 }')2>/dev/null) |
29 tr -d '[:space:]'`
31 [[ -z "$BANSHEE_PID" ]] && \
32 bail "Banshee does not appear to be running. Could not find PID"
35 function capture_mono_stack_trace () {
36 echo -n " - Sending SIGQUIT to Banshee to get a thread stack dump: "
37 begin_log "Sending SIGQUIT to ${BANSHEE_PID} get Mono thread stack dump"
38 kill -s QUIT $BANSHEE_PID 1>&2 && echo "success" || echo "error"
41 function capture_gdb_stack_trace () {
42 echo -n " - Running gdb to get a stack dump: "
43 begin_log "Running gdb (where, detach, quit)"
44 gdb --quiet --pid=$(pidof banshee) -ex where -ex detach -ex quit 1>&2 \
45 && echo "success" \
46 || echo "error"
49 function gather_open_files () {
50 echo -n " - Gathering a list of open files: "
51 begin_log "Gathering data from lsof against ${BANSHEE_PID}"
52 lsof -p $BANSHEE_PID 1>&2 && echo "success" || echo "error"
55 function pause_playback () {
56 echo -n " - Pausing playback for nicer strace: "
57 begin_log "Pausing playback"
58 dbus-send --session --print-reply \
59 --dest=org.bansheeproject.Banshee \
60 /org/bansheeproject/Banshee/PlayerEngine \
61 org.bansheeproject.Banshee.PlayerEngine.Pause 1>&2 \
62 && echo "success" \
63 || echo "error (maybe nothing was playing)"
66 function hide_window () {
67 echo -n " - Hiding window to for nicer strace: "
68 begin_log "Hiding window"
69 dbus-send --session --print-reply \
70 --dest=org.bansheeproject.Banshee \
71 /org/bansheeproject/Banshee/ClientWindow \
72 org.bansheeproject.Banshee.ClientWindow.Hide 1>&2 \
73 && echo "success" \
74 || echo "error"
77 function restore_window () {
78 echo -n " - Showing window: "
79 begin_log "Restoring window"
80 dbus-send --session --print-reply \
81 --dest=org.bansheeproject.Banshee \
82 /org/bansheeproject/Banshee/ClientWindow \
83 org.bansheeproject.Banshee.ClientWindow.Present 1>&2 \
84 && echo "success" \
85 || echo "error"
88 function capture_strace () {
89 STRACE_MSG=" - Gathering an strace dump for $STRACE_DURATION seconds: "
90 echo -n "$STRACE_MSG"
91 begin_log "strace (${STRACE_DURATION}s)"
92 ( strace -Tvi -p $BANSHEE_PID 1>&2 & \
93 STRACE_PID=$!
94 sleep 1; ps -p $STRACE_PID &>/dev/null && {
95 STRACE_REMAINING=$STRACE_DURATION
96 while [[ $STRACE_REMAINING -gt 0 ]]; do
97 STRACE_REMAINING=$(($STRACE_REMAINING - 1))
98 printf "\r$STRACE_MSG%d " $STRACE_REMAINING
99 sleep 1
100 done
101 printf "\r$STRACE_MSG"
102 kill $STRACE_PID &>/dev/null \
103 && echo "success" \
104 || echo "strace terminated early"
106 ) || echo "error"
109 function concat_log () {
110 echo -n " - Storing the Banshee log file: "
111 begin_log "Storing log file ${BANSHEE_LOG_FILE}"
112 cat "$BANSHEE_LOG_FILE" 1>&2 \
113 && echo "success" \
114 || echo "error"
117 function inspect_gstreamer () {
118 echo " - Gathering information about GStreamer"
120 begin_log "gst-inspect-0.10 --version"
121 echo -n " > gst-inspect-0.10 --version: "
122 gst-inspect-0.10 --version 1>&2 \
123 && echo "success" \
124 || echo "error"
126 begin_log "gst-inspect-0.10"
127 echo -n " > gst-inspect-0.10: "
128 gst-inspect-0.10 1>&2 \
129 && echo "success" \
130 || echo "error"
132 begin_log "pkg-config version probes"
133 (for path in /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib; do
134 echo "Checking: $path/pkgconfig"
135 for file in $(find $path/pkgconfig -name gstreamer\*.pc 2>/dev/null); do
136 pc_name=$(basename $file)
137 pc_command="pkg-config --modversion --libs --cflags ${pc_name%%.pc}"
138 echo "$pc_command"
139 $pc_command
140 echo
141 done
142 done) 1>&2
145 function inspect_mono () {
146 echo " - Gathering information about Mono"
148 begin_log "mono --version"
149 echo -n " > mono --version: "
150 mono --version 1>&2 \
151 && echo "success" \
152 || echo "error"
155 function inspect_distro () {
156 echo " - Gathering information about your distro"
157 begin_log "Distro Information"
160 echo "+ /etc/lsb-release"
161 cat /etc/lsb-release
163 for release_file in $(find /etc -name \*-release 2>/dev/null); do
164 echo "+ $release_file"
165 cat $release_file
166 done
168 echo "+ uname -a"
169 uname -a
170 ) 1>&2
173 find_pid
175 cat <<EOF
176 Inspecting Banshee Process ID: ${BANSHEE_PID}
178 NOTE: If you were listening to or watching anything that you would consider
179 embarrassing, please switch playback to something that would not be so first!
181 After data is collected about your running instance of Banshee, it is your
182 responsibility to review it before submitting to developers for review.
186 read -p "Press <enter> to continue... " || exit 1
187 echo "Running..."
188 echo
191 capture_mono_stack_trace &&
192 capture_gdb_stack_trace &&
193 gather_open_files &&
194 # these are to reduce noise from a working pipeline and input/redraw in the strace
195 pause_playback &&
196 hide_window &&
197 capture_strace &&
198 # restore the window since we're done stracing
199 restore_window &&
200 concat_log &&
201 inspect_mono &&
202 inspect_gstreamer &&
203 inspect_distro
204 ) 2>"$OUTPUT_FILE" || exit $?
206 cat <<EOF
208 Done.
210 A number of useful resources have been gathered to help debug
211 your Banshee issue. Please review the data file before you send
212 it to us. No sensitive user data is gathered, but path names of
213 of open files are provided, for example.
215 Please upload this file to the bug:
217 $OUTPUT_FILE
219 Thank you!