зеркало из https://github.com/mozilla/pjs.git
Add leak logging for node info managers that can be added to leak-gauge. b=414704 r+sr=sicking a=schrep
This commit is contained in:
Родитель
3648ad5fbb
Коммит
d08d400dea
|
@ -53,6 +53,16 @@
|
|||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
|
||||
#ifdef MOZ_LOGGING
|
||||
// so we can get logging even in release builds
|
||||
#define FORCE_PR_LOG 1
|
||||
#endif
|
||||
#include "prlog.h"
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo* gNodeInfoManagerLeakPRLog;
|
||||
#endif
|
||||
|
||||
PLHashNumber
|
||||
nsNodeInfoManager::GetNodeInfoInnerHashValue(const void *key)
|
||||
{
|
||||
|
@ -91,6 +101,15 @@ nsNodeInfoManager::nsNodeInfoManager()
|
|||
{
|
||||
nsLayoutStatics::AddRef();
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (!gNodeInfoManagerLeakPRLog)
|
||||
gNodeInfoManagerLeakPRLog = PR_NewLogModule("NodeInfoManagerLeak");
|
||||
|
||||
if (gNodeInfoManagerLeakPRLog)
|
||||
PR_LOG(gNodeInfoManagerLeakPRLog, PR_LOG_DEBUG,
|
||||
("NODEINFOMANAGER %p created", this));
|
||||
#endif
|
||||
|
||||
mNodeInfoHash = PL_NewHashTable(32, GetNodeInfoInnerHashValue,
|
||||
NodeInfoInnerKeyCompare,
|
||||
PL_CompareValues, nsnull, nsnull);
|
||||
|
@ -105,6 +124,12 @@ nsNodeInfoManager::~nsNodeInfoManager()
|
|||
// Note: mPrincipal may be null here if we never got inited correctly
|
||||
NS_IF_RELEASE(mPrincipal);
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (gNodeInfoManagerLeakPRLog)
|
||||
PR_LOG(gNodeInfoManagerLeakPRLog, PR_LOG_DEBUG,
|
||||
("NODEINFOMANAGER %p destroyed", this));
|
||||
#endif
|
||||
|
||||
nsLayoutStatics::Release();
|
||||
}
|
||||
|
||||
|
@ -150,6 +175,12 @@ nsNodeInfoManager::Init(nsIDocument *aDocument)
|
|||
|
||||
mDocument = aDocument;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (gNodeInfoManagerLeakPRLog)
|
||||
PR_LOG(gNodeInfoManagerLeakPRLog, PR_LOG_DEBUG,
|
||||
("NODEINFOMANAGER %p Init document=%p", this, aDocument));
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,12 @@ function run() {
|
|||
var m = rest.match(/^ (.*)$/);
|
||||
if (!m)
|
||||
throw "URI expected";
|
||||
this.docs[addr][m[1]] = true;
|
||||
var uri = m[1];
|
||||
var doc_info = this.docs[addr];
|
||||
doc_info[uri] = true;
|
||||
if ("nim" in doc_info) {
|
||||
doc_info["nim"][uri] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -130,7 +135,9 @@ function run() {
|
|||
var doc = this.docs[addr];
|
||||
result += "Leaked document at address " + addr + ".\n";
|
||||
for (var uri in doc) {
|
||||
result += " ... with URI \"" + uri + "\".\n";
|
||||
if (uri != "nim") {
|
||||
result += " ... with URI \"" + uri + "\".\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -181,6 +188,53 @@ function run() {
|
|||
result += 'Leaked ' + len + ' out of ' +
|
||||
this.count + " docshells\n";
|
||||
}
|
||||
},
|
||||
"NODEINFOMANAGER": {
|
||||
count: 0,
|
||||
nims: {},
|
||||
handle_line: function(line) {
|
||||
var match = line.match(/^([0-9a-f]*) (\S*)(.*)/);
|
||||
if (match) {
|
||||
var addr = match[1];
|
||||
var verb = match[2];
|
||||
var rest = match[3];
|
||||
if (verb == "created") {
|
||||
this.nims[addr] = {};
|
||||
++this.count;
|
||||
} else if (verb == "destroyed") {
|
||||
delete this.nims[addr];
|
||||
} else if (verb == "Init") {
|
||||
var m = rest.match(/^ document=(.*)$/);
|
||||
if (!m)
|
||||
throw "document pointer expected";
|
||||
var nim_info = this.nims[addr];
|
||||
var doc = m[1];
|
||||
if (doc != "0") {
|
||||
var doc_info = handlers["DOCUMENT"].docs[doc];
|
||||
for (var uri in doc_info) {
|
||||
nim_info[uri] = true;
|
||||
}
|
||||
doc_info["nim"] = nim_info;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
dump: function() {
|
||||
for (var addr in this.nims) {
|
||||
var nim = this.nims[addr];
|
||||
result += "Leaked content nodes associated with node info manager at address " + addr + ".\n";
|
||||
for (var uri in nim) {
|
||||
result += " ... with document URI \"" + uri + "\".\n";
|
||||
}
|
||||
}
|
||||
},
|
||||
summary: function() {
|
||||
var len = 0;
|
||||
for (var w in this.nims)
|
||||
++len;
|
||||
result += 'Leaked content nodes in ' + len + ' out of ' +
|
||||
this.count + " documents\n";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -237,7 +291,7 @@ function run() {
|
|||
|
||||
<h1>Leak Gauge</h1>
|
||||
|
||||
<pre>$Id: leak-gauge.html,v 1.6 2006/01/14 00:27:41 dbaron%dbaron.org Exp $</pre>
|
||||
<pre>$Id: leak-gauge.html,v 1.7 2008/02/08 19:55:03 dbaron%dbaron.org Exp $</pre>
|
||||
|
||||
<p>This script is designed to help testers isolate and simplify testcases
|
||||
for many classes of leaks (those that involve large graphs of core
|
||||
|
@ -249,7 +303,7 @@ leak. Once a site is known to leak, the logging can then be repeated
|
|||
to figure out under what conditions the leak occurs.</p>
|
||||
|
||||
<p>The way to create this log is to set the environment variables:</p>
|
||||
<pre> NSPR_LOG_MODULES=DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5
|
||||
<pre> NSPR_LOG_MODULES=DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5,NodeInfoManagerLeak:5
|
||||
NSPR_LOG_FILE=nspr.log <i>(or any other filename of your choice)</i></pre>
|
||||
<p>in your shell and then run the program.</p>
|
||||
<ul>
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# $Id: leak-gauge.pl,v 1.7 2006/01/14 00:27:41 dbaron%dbaron.org Exp $
|
||||
# $Id: leak-gauge.pl,v 1.8 2008/02/08 19:55:03 dbaron%dbaron.org Exp $
|
||||
# This script is designed to help testers isolate and simplify testcases
|
||||
# for many classes of leaks (those that involve large graphs of core
|
||||
# data structures) in Mozilla-based browsers. It is designed to print
|
||||
|
@ -47,7 +47,7 @@
|
|||
# to figure out under what conditions the leak occurs.
|
||||
#
|
||||
# The way to create this log is to set the environment variables:
|
||||
# NSPR_LOG_MODULES=DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5
|
||||
# NSPR_LOG_MODULES=DOMLeak:5,DocumentLeak:5,nsDocShellLeak:5,NodeInfoManagerLeak:5
|
||||
# NSPR_LOG_FILE=nspr.log (or any other filename of your choice)
|
||||
# in your shell and then run the program.
|
||||
# * In a Windows command prompt, set environment variables with
|
||||
|
@ -127,7 +127,9 @@ my $handlers = {
|
|||
docs => {},
|
||||
handle_line => sub($$) {
|
||||
my ($self, $line) = @_;
|
||||
my $docs = ${$self}{docs};
|
||||
# This doesn't work; I don't have time to figure out why not.
|
||||
# my $docs = ${$self}{docs};
|
||||
my $docs = ${$handlers}{"DOCUMENT"}{docs};
|
||||
if ($line =~ /^([0-9a-f]*) (\S*)/) {
|
||||
my ($addr, $verb, $rest) = ($1, $2, $');
|
||||
if ($verb eq "created") {
|
||||
|
@ -139,7 +141,11 @@ my $handlers = {
|
|||
$verb eq "StartDocumentLoad") {
|
||||
$rest =~ /^ (.*)$/ || die "URI expected";
|
||||
my $uri = $1;
|
||||
${${$docs}{$addr}}{$uri} = 1;
|
||||
my $doc_info = ${$docs}{$addr};
|
||||
${$doc_info}{$uri} = 1;
|
||||
if (exists(${$doc_info}{"nim"})) {
|
||||
${$doc_info}{"nim"}{$uri} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -149,7 +155,7 @@ my $handlers = {
|
|||
foreach my $addr (keys(%{$docs})) {
|
||||
print "Leaked document at address $addr.\n";
|
||||
foreach my $uri (keys(%{${$docs}{$addr}})) {
|
||||
print " ... with URI \"$uri\".\n";
|
||||
print " ... with URI \"$uri\".\n" unless $uri eq "nim";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -197,6 +203,51 @@ my $handlers = {
|
|||
print 'Leaked ' . keys(%{$shells}) . ' out of ' .
|
||||
${$self}{count} . " docshells\n";
|
||||
}
|
||||
},
|
||||
"NODEINFOMANAGER" => {
|
||||
count => 0,
|
||||
nims => {},
|
||||
handle_line => sub($$) {
|
||||
my ($self, $line) = @_;
|
||||
my $nims = ${$self}{nims};
|
||||
if ($line =~ /^([0-9a-f]*) (\S*)/) {
|
||||
my ($addr, $verb, $rest) = ($1, $2, $');
|
||||
if ($verb eq "created") {
|
||||
${$nims}{$addr} = {};
|
||||
++${$self}{count};
|
||||
} elsif ($verb eq "destroyed") {
|
||||
delete ${$nims}{$addr};
|
||||
} elsif ($verb eq "Init") {
|
||||
$rest =~ /^ document=(.*)$/ ||
|
||||
die "document pointer expected";
|
||||
my $doc = $1;
|
||||
if ($doc ne "0") {
|
||||
my $nim_info = ${$nims}{$addr};
|
||||
my $doc_info = ${$handlers}{"DOCUMENT"}{docs}{$doc};
|
||||
foreach my $uri (keys(%{$doc_info})) {
|
||||
${$nim_info}{$uri} = 1;
|
||||
}
|
||||
${$doc_info}{"nim"} = $nim_info;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
dump => sub ($) {
|
||||
my ($self) = @_;
|
||||
my $nims = ${$self}{nims};
|
||||
foreach my $addr (keys(%{$nims})) {
|
||||
print "Leaked content nodes associated with node info manager at address $addr.\n";
|
||||
foreach my $uri (keys(%{${$nims}{$addr}})) {
|
||||
print " ... with document URI \"$uri\".\n";
|
||||
}
|
||||
}
|
||||
},
|
||||
summary => sub($) {
|
||||
my ($self) = @_;
|
||||
my $nims = ${$self}{nims};
|
||||
print 'Leaked content nodes within ' . keys(%{$nims}) . ' out of ' .
|
||||
${$self}{count} . " documents\n";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче