-
Notifications
You must be signed in to change notification settings - Fork 1
/
strace-wrapper
executable file
·67 lines (57 loc) · 1.2 KB
/
strace-wrapper
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
#!/bin/bash -
die()
{
echo "$*" >&2
exit 1
}
options=(-yy -f -s 1024)
dump_options=false
record_env=true
trace="execve,vfork"
wrapper_opts_ended=false
prog_arguments=()
while [ "$#" -ne 0 ]
do
$wrapper_opts_ended && break
case "$1" in
-d|--dump*)
dump_options=true
;;
--noenv)
record_env=false
;;
--full)
# TODO: I think %file should include chdir (check).
trace="$trace,%file,%desc,chdir,%%stat,%network,%ipc,%process"
;;
--all)
trace="all"
;;
--)
wrapper_opts_ended=true
;;
*)
die "$0: unknown option $1"
;;
esac
shift
done
$record_env && options+=(-v)
options+=(-e trace="$trace")
if $dump_options; then
echo "strace ${options[*]}"
exit
fi
! $wrapper_opts_ended && die "$0: end wrapper's options with a --"
while [ "$#" -ne 0 ]
do
prog_arguments+=("$1")
shift
done
logname="/tmp/strace-$(ls /tmp/strace-* 2>/dev/null | wc -l)"
options+=(-o "$logname" "$@")
strace "${options[@]}" "${prog_arguments[@]}"
retcode=$?
echo "$logname"
strace-treeify "$logname"
exit $retcode