track_memory.awk: option to disable source line display

This commit is contained in:
Stefan Frederik 2021-11-17 04:06:36 +01:00
parent dfc8031786
commit f7fa39a975
1 changed files with 6 additions and 3 deletions

View File

@ -6,6 +6,7 @@
# and the allocation that was not freed, with the source code line. # and the allocation that was not freed, with the source code line.
# total and leak should indicate same amount of bytes, it is a cross check for the script. # total and leak should indicate same amount of bytes, it is a cross check for the script.
BEGIN{ BEGIN{
show_source = 1
max = 0 max = 0
total = 0 total = 0
malloc = 0 malloc = 0
@ -73,9 +74,11 @@ END{
stale++ stale++
leak+= address[i] leak+= address[i]
print " address[ " i ", " idx[i] " ]= " address[i] print " address[ " i ", " idx[i] " ]= " address[i]
pipe = "egrep -n 'my_(malloc|calloc|realloc|free)\(" idx[i] ",' *.c xschem.h" if(show_source) {
while( pipe | getline a) print " " a pipe = "egrep -n 'my_(malloc|calloc|realloc|free)\(" idx[i] ",' *.c xschem.h"
close(pipe) while( pipe | getline a) print " " a
close(pipe)
}
} }
print "Number of unfreed pointers = " stale print "Number of unfreed pointers = " stale
# as a crosscheck 'leak' should be equal to 'total'. # as a crosscheck 'leak' should be equal to 'total'.