memleak.pl revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson#!/usr/bin/perl
d3498432822fb487e58f8f72bb5f880dd8307d7dMichael Sawyer#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 1999, 2000 Internet Software Consortium.
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# purpose with or without fee is hereby granted, provided that the above
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# copyright notice and this permission notice appear in all copies.
d3498432822fb487e58f8f72bb5f880dd8307d7dMichael Sawyer#
6c6ccd6b330fa92d62136ec1062cc07a790a7165Automatic Updater# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
0e9dcd548051a8ec34744bfa18b4e09fea742a39Andreas Gustafsson# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
490b05960c9956cc37f52f5fd4443829d75ce7d6Mark Andrews# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrews# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
fae66f41c548a8cd4ef2496bc83ab3a28fa125a4Mark Andrews
ecc06cbc32c5a2b91a17e65c1820c9c66313d35cMukund Sivaraman# $Id: memleak.pl,v 1.9 2000/08/01 01:33:29 tale Exp $
553197e28833ed2d8bf26f8112eaa137dbaa040aMark Andrews
214836c18496e0d2630df1cda5eeee13c38b9068Evan Hunt# Massage the output from ISC_MEM_DEBUG to extract mem_get() calls
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews# with no corresponding mem_put().
8bd6c39d5e49c6ad0a82fdd8901fc6019b602de3Andreas Gustafsson
8bd6c39d5e49c6ad0a82fdd8901fc6019b602de3Andreas Gustafsson$mem_stats = '';
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrews
553197e28833ed2d8bf26f8112eaa137dbaa040aMark Andrewswhile (<>) {
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrews $gets{$1.$2} = $_ if (/mem_get\((?:0x)?([0-9a-f]+), (?:0x)?[0-9a-f]+\) -> (?:0x)?([0-9a-f]+)/);
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrews delete $gets{$1.$2} if /mem_put\((?:0x)?([0-9a-f]+), (?:0x)?([0-9a-f]+), (?:0x)?[0-9a-f]+\)/;
ecc06cbc32c5a2b91a17e65c1820c9c66313d35cMukund Sivaraman $mem_stats .= $_ if /\d+ gets, +(\d+) rem/ && $1 > 0;
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrews}
a1e2170ad5c5018fbe8f7b8449d8885d5d298e88Mark Andrewsprint join('', values %gets);
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrewsprint $mem_stats;
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrews
47d837a49967a6a1b290024f5efb0669276013b1Mukund Sivaramanexit(0);
f9da4a8e543cf895b6171773e75d343b2914a7e7Mark Andrews