-
Notifications
You must be signed in to change notification settings - Fork 2
/
d
executable file
·70 lines (65 loc) · 1.41 KB
/
d
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
#!/bin/bash
PORT=4000
GDBPORT=1234
SOCAT="/usr/bin/socat"
STRACE="/usr/bin/strace"
GDBSERVER="/opt/bin/gdbserver"
WRAPPER="command-wrapper" # clean up ENV
SOCAT_OPTION=""
STRACE_OPTION="-ivf -s 4096 -x"
for OPT in $*
do
case $OPT in
-p)
PORT=$2
shift 2
;;
-n)
NOSTRACE=1
shift
;;
-e)
# event: d -e execve,read,write
STRACE_OPTION="$STRACE_OPTION -e'$2'"
shift 2
;;
-w)
NOWRAPPER=1
shift
;;
-q)
SOCAT_OPTION="$SOCAT_OPTION,pty,raw,echo=0"
#SOCAT_OPTION="$SOCAT_OPTION,pty,raw,echo=0,stderr"
shift
;;
-l)
# ltrace mode
STRACE="/usr/bin/ltrace"
STRACE_OPTION="-ifC -s 100"
shift
;;
-g)
WITH_GDBSERVER=1
NOSTRACE=1
shift
;;
--) shift
break
;;
esac
done
if [ $WITH_GDBSERVER ]; then
CMD="$GDBSERVER localhost\:$GDBPORT $@"
else
if [ $NOWRAPPER ]; then
CMD="$@"
else
CMD="$WRAPPER $@"
fi
fi
echo "listening on :$PORT"
if [ $NOSTRACE ]; then
$SOCAT tcp-l:"$PORT,reuseaddr,fork" exec:"$CMD"$SOCAT_OPTION
else
$SOCAT tcp-l:"$PORT,reuseaddr,fork" exec:"$STRACE $STRACE_OPTION '$CMD'"$SOCAT_OPTION
fi