forked from enarx/enarx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse-trace.sh
executable file
·77 lines (63 loc) · 1.64 KB
/
parse-trace.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
#!/usr/bin/env bash
SHIM="$1"
PAYLOAD="$2"
if [[ -z $SHIM ]]; then
echo "Usage: $0 <shim> [<exec>]"
fi
strstr() { [[ $1 = *"$2"* ]]; }
unset ADDR2LINE
while read line; do
if [[ $line = "panicked at"* ]]; then
printf -- "%s\n" "$line"
continue
fi
if [[ $line = "TRACE:"* ]]; then
printf -- "%s\n" "$line"
ADDR2LINE="TRACE"
continue
fi
if [[ $line = "Error: Shutdown"* ]] || [[ $line = "Error: MmioRead"* ]]; then
ADDR2LINE="REGS"
continue
fi
if ! [[ $ADDR2LINE ]]; then
printf -- "%s\n" "$line"
continue
fi
if ! [[ $line ]]; then
continue
fi
if [[ $line = ")" ]]; then
unset ADDR2LINE
fi
if [[ $ADDR2LINE = "REGS" ]]; then
if [[ $line = *"rflags:"* ]] || [[ $line = *"rsp:"* ]] || [[ $line = *"rbp:"* ]] || [[ $line = *"rbx:"* ]]; then
continue
fi
line=${line%,}
read _ line <<< "$line"
line=${line/ffffff8}
fi
if [[ $ADDR2LINE = "TRACE" ]] && [[ $line = "E "* ]]; then
if [[ $PAYLOAD ]]; then
addr2line -apiCf -e "$PAYLOAD" $line | grep -F -v '??' | \
while read line; do
printf -- "Exec: %s\n" "$line"
done
continue
else
printf -- "Exec: %s\n" "$line"
continue
fi
fi
if [[ $SHIM ]]; then
addr2line -apiCf -e "$SHIM" $line | grep -F -v '??' | \
while read line; do
printf -- "Shim: %s\n" "$line"
done
continue
else
printf -- "Shim: %s\n" "$line"
continue
fi
done