17c478bd9Sstevel@tonic-gate# This AWK script reads the output of testfixture when compiled for memory 2*1da57d55SToomas Soome# debugging. It generates SQL commands that can be fed into an sqlite 37c478bd9Sstevel@tonic-gate# instance to determine what memory is never freed. A typical usage would 47c478bd9Sstevel@tonic-gate# be as follows: 57c478bd9Sstevel@tonic-gate# 67c478bd9Sstevel@tonic-gate# make -f memleak.mk fulltest 2>mem.out 77c478bd9Sstevel@tonic-gate# awk -f ../sqlite/tool/memleak2.awk mem.out | ./sqlite :memory: 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# The job performed by this script is the same as that done by memleak.awk. 107c478bd9Sstevel@tonic-gate# The difference is that this script uses much less memory when the size 117c478bd9Sstevel@tonic-gate# of the mem.out file is huge. 127c478bd9Sstevel@tonic-gate# 137c478bd9Sstevel@tonic-gateBEGIN { 147c478bd9Sstevel@tonic-gate print "CREATE TABLE mem(loc INTEGER PRIMARY KEY, src);" 157c478bd9Sstevel@tonic-gate} 167c478bd9Sstevel@tonic-gate/[0-9]+ malloc / { 177c478bd9Sstevel@tonic-gate print "INSERT INTO mem VALUES(" strtonum($6) ",'" $0 "');" 187c478bd9Sstevel@tonic-gate} 197c478bd9Sstevel@tonic-gate/[0-9]+ realloc / { 207c478bd9Sstevel@tonic-gate print "INSERT INTO mem VALUES(" strtonum($10) \ 217c478bd9Sstevel@tonic-gate ",(SELECT src FROM mem WHERE loc=" strtonum($8) "));" 227c478bd9Sstevel@tonic-gate print "DELETE FROM mem WHERE loc=" strtonum($8) ";" 237c478bd9Sstevel@tonic-gate} 247c478bd9Sstevel@tonic-gate/[0-9]+ free / { 257c478bd9Sstevel@tonic-gate print "DELETE FROM mem WHERE loc=" strtonum($6) ";" 267c478bd9Sstevel@tonic-gate} 277c478bd9Sstevel@tonic-gateEND { 287c478bd9Sstevel@tonic-gate print "SELECT src FROM mem;" 297c478bd9Sstevel@tonic-gate} 30