On Mon, 31 May 2004, Davide Libenzi wrote:

> 
> I setup an XMail leak tracing infrastructure for Linux. I was hoping that 
> valgrind was doing the job fine, but it turned out not to be the case. The 
> thing lives as an external patch:
> 
> http://www.xmailserver.org/xmail-memtracer-0.1.diff
> 
> You get the patch and the XMail .tar.gz, and:
> 
> $ tar xvzf xmail-?.??.tar.gz
> $ cd xmail-?.??
> $ patch -p1 < ../xmail-memtracer-0.1.diff
> $ export XMAIL_DEBUG=1
> $ make -f Makefile.lnx
> 
> Then you copy the XMail binary from inside the "bin" directory to your 
> XMail's binary folder, and you restart XMail. To get clean memory leak 
> reports, XMail must be shutdown cleanly:
> 
> $ touch $MAIL_ROOT/.shutdown
> 
> Then you have to wait (ps) that the last XMail process vanished, and the 
> report will be available in /tmp/XMail.memleaks. You need to send the 
> report to me together with the *exact* copy of the binary that generated 
> the report. Note that XMail uses a little bit more memory when traced, but 
> nothing close to the amount that valgrind uses. I am running it by 24 
> hours, and I can say that it has zero leaks here.

You don't have actually to send me the binary image and the trace file. It 
is sufficent that you drop the Perl script below in xmtrace.pl and:

$ cat /tmp/XMail.memleaks | ./xmtrace.pl $MAIL_ROOT/bin/XMail

and send me the result ...



- Davide



#!/usr/bin/perl
#
# xmtrace.pl by Davide Libenzi ( XMail Perl memory trace decoder )
# Copyright (C) 2004  Davide Libenzi
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Davide Libenzi <[EMAIL PROTECTED]>
#

use strict;

my $binimage;
my %cache;

if ($#ARGV < 0) {
        print STDERR "use: ${0} binary < trace-file\n";
        exit(1);
}

$binimage = $ARGV[0];


sub get_sym {
        my ($hexn) = @_;
        my $ln;

        if (defined($cache{$hexn})) {
                return $cache{$hexn};
        }
        if (open(ADDR, "addr2line -e $binimage $hexn|")) {
                $ln = <ADDR>;
                close(ADDR);
                $ln =~ s/([^\r\n]*)[\r\n]+/$1/;
                if ($ln ne '??:0') {
                        $cache{$hexn} = $ln;
                        return $cache{$hexn};
                }
        }
        return $hexn;
}

while (<STDIN>) {
        my $ln;
        my ($hexn, $sym);

        ($ln = $_) =~ s/([^\r\n]*)[\r\n]+/$1/;
        if ($ln !~ /from=0x[0-9a-zA-Z]+/) {
                print $ln . "\n";
                next;
        }
        ($hexn = $ln) =~ s/.*from=0x([0-9a-zA-Z]+).*/$1/;
        $sym = get_sym($hexn);
        $ln =~ s/(.*from=)0x([0-9a-zA-Z]+)(.*)/${1}${sym}${3}/;
        print $ln . "\n";
}

exit(0);

-
To unsubscribe from this list: send the line "unsubscribe xmail" in
the body of a message to [EMAIL PROTECTED]
For general help: send the line "help" in the body of a message to
[EMAIL PROTECTED]

Reply via email to