-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparsevalgrind
executable file
·74 lines (70 loc) · 1.73 KB
/
parsevalgrind
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
#!/bin/bash
print_error=0
fileName=""
functionName=""
lineNumber=0
errorKind=""
errorDescription=""
frameCounter=0
# Declare array to store list of functions
declare -a frames=(
[0]=""
)
while read -r line args
do
if [ "${line:0:7}" = "<error>" ]
then
print_error=1
fi
if [ "$print_error" -eq 1 ]
then
if [ "${line:0:8}" = "</frame>" ]
then
statement=" $functionName at line number $lineNumber in $fileName"
frames[frameCounter]=$statement
frameCounter=$((frameCounter+1))
fi
if [ "${line:0:6}" = "<file>" ]
then
fileName=${line:6:-7}
fi
if [ "${line:0:4}" = "<fn>" ]
then
functionName=${line:4:-5}
fi
if [ "${line:0:6}" = "<line>" ]
then
lineNumber=${line:6:-7}
fi
if [ "${line:0:6}" = "<kind>" ]
then
errorKind=${line:6:-7}
fi
if [ "${line:0:6}" = "<text>" ]
then
errorDescription=${line:6:2}
errorDescription+=${args:0:-7}
fi
if [ "${line:0:8}" = "</error>" ]
then
print_error=0
echo "In file: $fileName . With call stack:"
for frameItr in "${frames[@]}"
do
echo "$frameItr"
done
# Deleting the frame eleemnts
for delFrameItr in ${!frames[@]}
do
unset frames[delFrameItr]
done
frameCounter=0
echo "Type of Error: $errorKind"
if [ -n "$errorDescription" ]
then
echo "Error: $errorDescription"
fi
echo
fi
fi
done < $1