2 # Awk program to analyze mtrace.c output.
13 if (allocated
[$
(n
+1)] != "")
14 print "+", $
(n
+1), "Alloc", NR, "duplicate:", allocated
[$
(n
+1)], wherewas
[$
(n
+1)], where
;
16 wherewas
[$
(n
+1)] = where
;
17 allocated
[$
(n
+1)] = $
(n
+2);
19 } else if ($n ==
"-") {
20 if (allocated
[$
(n
+1)] != "") {
21 wherewas
[$
(n
+1)] =
"";
22 allocated
[$
(n
+1)] =
"";
23 if (allocated
[$
(n
+1)] != "")
24 print "DELETE FAILED", $
(n
+1), allocated
[$
(n
+1)];
26 print "-", $
(n
+1), "Free", NR, "was never alloc'd", where
;
27 } else if ($n ==
"<") {
28 if (allocated
[$
(n
+1)] != "") {
29 wherewas
[$
(n
+1)] =
"";
30 allocated
[$
(n
+1)] =
"";
32 print "-", $
(n
+1), "Realloc", NR, "was never alloc'd", where
;
33 } else if ($n ==
">") {
34 if (allocated
[$
(n
+1)] != "")
35 print "+", $
(n
+1), "Realloc", NR, "duplicate:", allocated
[$
(n
+1)], where
;
37 wherewas
[$
(n
+1)] = $
(n
+2);
38 allocated
[$
(n
+1)] = $
(n
+2);
40 } else if ($n ==
"=") {
42 } else if ($n ==
"!") {
43 # Ignore failed realloc attempts for now
48 if (allocated
[x
] != "")
49 print "+", x
, allocated
[x
], wherewas
[x
];