Update.
[glibc.git] / malloc / mtrace.awk
blob06844d1a4b421a5d6cf54430e35a44a5ac411b1c
2 # Awk program to analyze mtrace.c output.
5 if ($1 == "@") {
6 where = " (" $2 ")"
7 n = 3
8 } else {
9 where = ""
10 n = 1
12 if ($n == "+") {
13 if (allocated[$(n+1)] != "")
14 print "+", $(n+1), "Alloc", NR, "duplicate:", allocated[$(n+1)], wherewas[$(n+1)], where;
15 else {
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)];
25 } else
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)] = "";
31 } else
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;
36 else {
37 wherewas[$(n+1)] = $(n+2);
38 allocated[$(n+1)] = $(n+2);
40 } else if ($n == "=") {
41 # Ignore "= Start"
42 } else if ($n == "!") {
43 # Ignore failed realloc attempts for now
46 END {
47 for (x in allocated)
48 if (allocated[x] != "")
49 print "+", x, allocated[x], wherewas[x];