tools/trace-malloc/merge.pl
author Gregory Szorc <gps@mozilla.com>
Tue, 15 Jan 2013 22:21:21 -0800
changeset 119046 ec072cee05025335f0637de7e1dab95623fe8a56
parent 94475 f4157e8c410708d76703f19e4dfb61859bfe32d8
permissions -rwxr-xr-x
Bug 784841 - Part 2: Implement sandboxing for Python build files; r=ted,glandium This is the beginning of Mozilla's new build system. In this patch, we have a Python sandbox tailored for execution of Python scripts which will define the build system. We also have a build reader that traverses a linked set of scripts. More details are available in the thorough README.rst files as part of this patch. * * * Bug 784841 - Part 2b: Option to not descend into child moz.build files; r=ted

#!/usr/bin/perl
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


$argv = $ARGV[0];
open( bloatFile, $argv ) or die "Can't open $argv: $!\n";
while (<bloatFile>) {
    if (/name=/) {
        ($td,$name,$func,$a,$ntd) = split(/>/, $_);
        ($fname, $memSize) = split( /&nbsp;/, $func );
        ($trash, $linkName) = split( /"/, $name );
        $namesLinks{$fname} = $linkName;
        if ($namesSizes{$fname}) {
            $namesSizes{$fname} = $namesSizes{$fname} + $memSize;
        }
        else {
            $namesSizes{$fname} = $memSize;
        }
    }
}

$argv = $ARGV[1];
if ($argv)
{
    open( bloatFile, $argv ) or die "Can't open $argv: $!\n";
    while (<bloatFile>) {
        if (/name=/) {
            ($td,$name,$func,$a,$ntd) = split(/>/, $_);
            ($fname, $memSize) = split( /&nbsp;/, $func );
            $namesSizes{$fname} = $namesSizes{$fname} - $memSize;
        }
    }
}

sub byvalue { $namesSizes{$b} <=> $namesSizes{$a} }


print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">';
print "\n<html><head>\n";
print "<title>Bloat Blame Delta</title>\n";
print '<link rel="stylesheet" type="text/css" href="blame.css">';
print "\n</head>\n<body>\n<table>\n";
print "<thead><tr><td>Memory Allocated</td><td>Function Name</td><td>Link</td></tr></thead>\n";

foreach $key (sort byvalue keys %namesSizes) {
    if ($namesSizes{$key}) 
    {
        print "<tr>\n";
        print '  <td>', $namesSizes{$key},"</td>\n"; 
        print "  <td> <a href=\"$ARGV[0]#$namesLinks{$key}\">", $key,  "</a></td>\n";
        print "</tr>\n"
    }
}

print "</table>\n</body></html>";