diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:17:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:17:24 +0000 |
commit | 9d8085074991d5c0a42d6fc96a2d1a3ee918aad1 (patch) | |
tree | c85bca1e6c11eb872edfc64c524d20f2b7e3307b /lib/malloc/xleaktrace | |
parent | Initial commit. (diff) | |
download | bash-upstream/5.1.tar.xz bash-upstream/5.1.zip |
Adding upstream version 5.1.upstream/5.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | lib/malloc/xleaktrace | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/malloc/xleaktrace b/lib/malloc/xleaktrace new file mode 100755 index 0000000..d7e3cd5 --- /dev/null +++ b/lib/malloc/xleaktrace @@ -0,0 +1,47 @@ +#! /usr/bin/awk -f +# +# xleaktrace - print unfreed memory using input generated by compact malloc +# tracing (malloc_set_trace(1)) +# +# NOTE: we ignore `realloc' tags because they're just extra information +# +# Copyright (c) 2001 Chester Ramey +# Permission is hereby granted to deal in this Software without restriction. +# THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. +# +# Chet Ramey +# chet@po.cwru.edu +# +BEGIN { + FS=":"; +} + +$1 == "alloc" { + alloc[$2] = 1; + + size[$2] = $3; + file[$2] = $4; + line[$2] = $5; + +# printf "allocated: %s %d %d %s %d\n", $2, alloc[$2], size[$2], file[$2], line[$2]; + } + +$1 == "free" { + if ($2 in alloc) { + alloc[$2] = 0; +# printf "freed: %s %d\n", $2, alloc[$2]; + } else + printf "freeing unallocated pointer: %s\n", $2; + + } + +END { + printf "unfreed memory\n"; + for (ptr in alloc) { + if (alloc[ptr] == 1) { + printf "%s (%d) from %s:%d\n", ptr, size[ptr], file[ptr], line[ptr]; + } + } +} + + |