]>
Commit | Line | Data |
---|---|---|
f73dda09 JA |
1 | #! /usr/bin/awk -f |
2 | # | |
3 | # xleaktrace - print unfreed memory using input generated by compact malloc | |
4 | # tracing (malloc_set_trace(1)) | |
5 | # | |
6 | # NOTE: we ignore `realloc' tags because they're just extra information | |
7 | # | |
0628567a JA |
8 | # Copyright (c) 2001 Chester Ramey |
9 | # Permission is hereby granted to deal in this Software without restriction. | |
10 | # THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. | |
11 | # | |
f73dda09 JA |
12 | # Chet Ramey |
13 | # chet@po.cwru.edu | |
14 | # | |
15 | BEGIN { | |
16 | FS=":"; | |
17 | } | |
18 | ||
19 | $1 == "alloc" { | |
20 | alloc[$2] = 1; | |
21 | ||
22 | size[$2] = $3; | |
23 | file[$2] = $4; | |
24 | line[$2] = $5; | |
25 | ||
26 | # printf "allocated: %s %d %d %s %d\n", $2, alloc[$2], size[$2], file[$2], line[$2]; | |
27 | } | |
28 | ||
29 | $1 == "free" { | |
30 | if ($2 in alloc) { | |
31 | alloc[$2] = 0; | |
32 | # printf "freed: %s %d\n", $2, alloc[$2]; | |
33 | } else | |
34 | printf "freeing unallocated pointer: %s\n", $2; | |
35 | ||
36 | } | |
37 | ||
38 | END { | |
39 | printf "unfreed memory\n"; | |
40 | for (ptr in alloc) { | |
41 | if (alloc[ptr] == 1) { | |
42 | printf "%s (%d) from %s:%d\n", ptr, size[ptr], file[ptr], line[ptr]; | |
43 | } | |
44 | } | |
45 | } | |
46 | ||
47 |