-
Notifications
You must be signed in to change notification settings - Fork 21
/
xdebug.sh
executable file
·159 lines (143 loc) · 4.59 KB
/
xdebug.sh
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
#!/usr/bin/env bash
debugger_default="b"
geo_default="800x600+0+0"
echo
xserver="Xephyr"
if [ `type $xserver &>/dev/null; echo $?` -ne 0 ]; then
xserver="Xnest"
if [ `type $xserver &>/dev/null; echo $?` -ne 0 ]; then
echo "Please install either Xephyr (recommended) or Xnest!"
exit 1
fi
fi
for arg in $@; do
option=`echo "'$arg'" | cut -d'=' -f1 | tr -d "'"`
value=`echo "'$arg'" | cut -d'=' -f2- | tr -d "'"`
if [ "$value" == "$option" ]; then
value=""
fi
case $option in
"--dbg-display")
if [ -z "$value" ]; then
echo "Missing value for $option= !"
exit 1
fi
dbg_display=$value
;;
"--dbg-geo")
if [ -z "$value" ]; then
echo "Missing value for $option= !"
exit 1
fi
dbg_geo=$value
;;
"--dbg-mode")
if [ -z "$value" ]; then
echo "Missing value for $option= !"
exit 1
fi
debugger=$value
;;
"--dbg-ecore-errors") export ECORE_ERROR_ABORT=1 ;;
"--dbg-ecore-noclean") export ECORE_NOCLEAN=1 ;;
"--dbg-redraw") export REDRAW_DEBUG=1 ;;
"--help")
echo "Usage: $0 [DEBUG-OPTION] ..."
echo " --dbg-display=<NUMBER> = set the used display number"
echo " --dbg-geo=<WxH+X+Y> = set xserver geometry"
echo " --dbg-mode=<CHAR> = b: text debugger with auto backtrace (gdb)"
echo " c: curses debugger (cgdb)"
echo " d: GUI debugger (ddd)"
echo " e: no debugging"
echo " g: text debugger (gdb)"
echo " l: leak check (valgrind)"
echo " m: memory check (valgrind)"
echo " p: memory profiling (memprof)"
echo " r: raster's memory profiling (memprof_raster)"
echo " s: show syscalls (strace)"
echo " v: GUI memory check (valkyrie)"
echo " u: run clouseau"
echo " --dbg-ecore-errors = to cause ecore to abort on errors"
echo " --dbg-ecore-noclean = to cause ecore to not unload modules"
echo " --dbg-redraw = to cause redraw to happen slovly and obviously"
echo " --help = wysiwyg"
echo
echo "Usage: $0 [ENLIGHTENMENT-OPTION] ..."
enlightenment --help
exit 0
;;
*) enlightenment_args="$enlightenment_args $arg" ;;
esac
done
if [ -z "$dbg_display" ]; then
if [ -z "$DISPLAY" ]; then
echo "Couldn't read your \$DISPLAY env variable, are you running X?"
exit 1
fi
dcnt=`echo "$DISPLAY" | tr -d ':' | cut -d '.' -f1`
dbg_display=$(($dcnt+1))
fi
if [ -z "$dbg_geo" ]; then
dbg_geo=$geo_default
fi
if [ -z "$debugger" ]; then
debugger=$debugger_default
fi
case $debugger in
"b")
tmpfile=`mktemp`
if [ -z "$tmpfile" ]; then
echo "Can't create tmp file!"
exit 1
fi
echo -e "run\nbt\nq\ny" > $tmpfile
debugcmd="gdb -x $tmpfile --args"
;;
"c") debugcmd="cgdb" ;;
"d") debugcmd="ddd -display $DISPLAY --args" ;;
"e") debugcmd="" ;;
"g") debugcmd="gdb --args" ;;
"l") debugcmd="valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --log-file=valgrind_log" ;;
"m") debugcmd="valgrind --tool=memcheck --log-file=valgrind_log" ;;
"p") debugcmd="memprof --display=$DISPLAY" ;;
"r") debugcmd="memprof_raster --display=$DISPLAY" ;;
"s") debugcmd="strace -F -o strace_log" ;;
"v") debugcmd="valkyrie -display $DISPLAY" ;;
"u") debugcmd="clouseau_start" ;;
esac
echo "- DISPLAY: $dbg_display"
echo "- XSERVER GEOMETRY: $dbg_geo"
echo -n "- DEBUGMODE: "
if [ "$debugcmd" ]; then
echo "$debugcmd"
else
echo "NONE"
fi
if [ "$enlightenment_args" ]; then
echo "- ENLIGHTENMENT ARGUMENTS: $enlightenment_args"
fi
if [ "$ECORE_ERROR_ABORT" ]; then
echo "- ECORE ERROR ABORT"
fi
if [ "$ECORE_NOCLEAN" ]; then
echo "- ECORE NOCLEAN"
fi
if [ "$REDRAW_DEBUG" ]; then
echo "- REDRAW DEBUG"
fi
echo "======================================================"
echo
sleep 1
case $xserver in
"Xephyr") $xserver :$dbg_display -ac -screen $dbg_geo & ;;
"Xnest") $xserver :$dbg_display -ac -geometry $dbg_geo & ;;
esac
sleep 2 # Someone reported that it starts E before X has started properly.
export DISPLAY=":$dbg_display"
export E_START="enlightenment_start"
$debugcmd enlightenment $enlightenment_args
if [ "$tmpfile" ]; then
rm "$tmpfile"
fi
killall -TERM $xserver
echo