blob: 7e96b8ace2802684a2ce29c470121f951dc5423a [file] [log] [blame]
Theodore Ts'o3839e651997-04-26 13:21:57 +00001#!/usr/bin/awk -f
2#
3# Awk program to analyze mtrace.c output.
4#
5$1 == "+" { if (allocated[$2] != "")
6 print "+", $2, "Alloc", NR, "duplicate:", allocated[$2];
7 else
8 allocated[$2] = $3;
9 }
10$1 == "-" { if (allocated[$2] != "") {
11 allocated[$2] = "";
12 if (allocated[$2] != "")
13 print "DELETE FAILED", $2, allocated[$2];
14 } else
15 print "-", $2, "Free", NR, "was never alloc'd";
16 }
17$1 == "<" { if (allocated[$2] != "")
18 allocated[$2] = "";
19 else
20 print "-", $2, "Realloc", NR, "was never alloc'd";
21 }
22$1 == ">" { if (allocated[$2] != "")
23 print "+", $2, "Realloc", NR, "duplicate:", allocated[$2];
24 else
25 allocated[$2] = $3;
26 }
27
28# Ignore "= Start"
29$1 == "=" { }
30# Ignore failed realloc attempts for now
31$1 == "!" { }
32
33
34END { for (x in allocated)
35 if (allocated[x] != "")
36 print "+", x, allocated[x];
37 }