diff options
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/tool/memleak2.awk')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/tool/memleak2.awk | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/tool/memleak2.awk b/libraries/sqlite/unix/sqlite-3.5.1/tool/memleak2.awk new file mode 100644 index 0000000..5d81b70 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/tool/memleak2.awk | |||
@@ -0,0 +1,29 @@ | |||
1 | # This AWK script reads the output of testfixture when compiled for memory | ||
2 | # debugging. It generates SQL commands that can be fed into an sqlite | ||
3 | # instance to determine what memory is never freed. A typical usage would | ||
4 | # be as follows: | ||
5 | # | ||
6 | # make -f memleak.mk fulltest 2>mem.out | ||
7 | # awk -f ../sqlite/tool/memleak2.awk mem.out | ./sqlite :memory: | ||
8 | # | ||
9 | # The job performed by this script is the same as that done by memleak.awk. | ||
10 | # The difference is that this script uses much less memory when the size | ||
11 | # of the mem.out file is huge. | ||
12 | # | ||
13 | BEGIN { | ||
14 | print "CREATE TABLE mem(loc INTEGER PRIMARY KEY, src);" | ||
15 | } | ||
16 | /[0-9]+ malloc / { | ||
17 | print "INSERT INTO mem VALUES(" strtonum($6) ",'" $0 "');" | ||
18 | } | ||
19 | /[0-9]+ realloc / { | ||
20 | print "INSERT INTO mem VALUES(" strtonum($10) \ | ||
21 | ",(SELECT src FROM mem WHERE loc=" strtonum($8) "));" | ||
22 | print "DELETE FROM mem WHERE loc=" strtonum($8) ";" | ||
23 | } | ||
24 | /[0-9]+ free / { | ||
25 | print "DELETE FROM mem WHERE loc=" strtonum($6) ";" | ||
26 | } | ||
27 | END { | ||
28 | print "SELECT src FROM mem;" | ||
29 | } | ||