diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-05-15 22:27:48 +0100 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-05-15 22:27:48 +0100 |
commit | b9fad1ab2ad3bd87bff05c4688c978d582ada438 (patch) | |
tree | 4a373f8dd867d20e67510de7cfe447a4b58c1a70 /misc/findleak.pl | |
parent | 65c26d26fb72cec0d43d199c72ed27513d17f4c9 (diff) | |
download | nasm-b9fad1ab2ad3bd87bff05c4688c978d582ada438.tar.gz nasm-b9fad1ab2ad3bd87bff05c4688c978d582ada438.tar.bz2 nasm-b9fad1ab2ad3bd87bff05c4688c978d582ada438.zip |
Upstream version 2.08rc7
Diffstat (limited to 'misc/findleak.pl')
-rwxr-xr-x | misc/findleak.pl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/misc/findleak.pl b/misc/findleak.pl new file mode 100755 index 0000000..dbb3367 --- /dev/null +++ b/misc/findleak.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl +# From: Ed Beroset <beroset@mindspring.com> + +my %mem = {}; +my %alloc = {}; +while(<>) +{ + if (/realloc\((0x[0-9a-f]+).*\).*returns \((0x[0-9a-f]+)/) + { + $mem{$1}--; + if ($mem{$1} != 0) { + print "free before alloc! $_"; + } + if ($mem{$2} != 0) { + print "memory leak! $_"; + } + $mem{$2}++; + $alloc{$2} = $_; + } + elsif (/free\((0x[0-9a-f]+)/) + { + $mem{$1}--; + if ($mem{$1} != 0) { + print "free before alloc! $_"; + } + } + elsif (m/returns (0x[0-9a-f]+)/) + { + if ($mem{$1} != 0) { + print "memory leak! $_"; + } + $mem{$1}++; + $alloc{$1} = $_; + } +} +foreach $goo (sort keys %mem) +{ + if ($mem{$goo}) + { + print "$mem{$goo} $alloc{$goo}"; + } +} |