-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtrace.sh
More file actions
executable file
·66 lines (52 loc) · 1.59 KB
/
trace.sh
File metadata and controls
executable file
·66 lines (52 loc) · 1.59 KB
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
#!/usr/bin/env bash
set -euo pipefail
if [ $# -lt 1 ]; then
echo "usage: qemu_cmd"
exit 1
fi
qemu_bin=$(readlink -f $1)
qemu_src_dir=$(dirname $qemu_bin)/../
uftrace_plugin=$qemu_src_dir/build/contrib/plugins/libuftrace.so
uftrace_symbols=$qemu_src_dir/contrib/plugins/uftrace_symbols.py
if [ -z "$(which tee)" ]; then
echo "trace.sh: coreutils (tee) needs to be installed on your machine"
exit 1
fi
if [ -z "$(which ts)" ]; then
echo "trace.sh: moreutils (ts) needs to be installed on your machine"
exit 1
fi
if [ ! -f $uftrace_plugin ]; then
echo "trace.sh: can't find QEMU uftrace plugin ($uftrace_plugin)"
exit 1
fi
if [ ! -f $uftrace_symbols ]; then
echo "trace.sh: can't find QEMU uftrace symbols script ($uftrace_symbols)"
exit 1
fi
get_binaries()
{
cat gdbinit | grep '^add-symbol-file' | sed -e 's/add-symbol-file\s*//' |
while read line; do
line="$line "
path=$(echo "$line" | cut -f 1 -d ' ')
# use canonical path to avoid symlinks in debug info
path=$(readlink -f "$path")
offset=$(echo "$line" | cut -f 2 -d ' ')
if [ "$offset" != "" ]; then
offset=":$offset"
fi
echo $path$offset
done
}
binaries=$(get_binaries)
set -x
rm -rf ./uftrace.data
./container.sh $uftrace_symbols --prefix-symbols $binaries
qemu_cmd=$*
./run.sh $qemu_cmd -plugin $uftrace_plugin,trace-privilege-level=on |&
ts "%.s" | tee ./uftrace.data/exec.log
echo >> ./uftrace.data/exec.log
set +x
echo "----------------------------------------"
echo "execution log is available in ./uftrace.data/exec.log"