Bug 538388 - Make find-leakers.pl work with the output of XPCOM_MEM_ALLOC_LOG as it dose with XPCOM_MEM_REFCNT_LOG, r=dbaron
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 07 Jan 2010 15:14:27 -0500
changeset 36940 b698c2f70fef80dbca0b29b4d660fababe5874fa
parent 36939 0a062eef0c8ce5b92162f1fd12f2c0e0afbe511e
child 36941 eae745ef62c1c9e650d6bda71c5eb361f7bee712
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs538388
milestone1.9.3a1pre
Bug 538388 - Make find-leakers.pl work with the output of XPCOM_MEM_ALLOC_LOG as it dose with XPCOM_MEM_REFCNT_LOG, r=dbaron
tools/rb/find-leakers.pl
--- a/tools/rb/find-leakers.pl
+++ b/tools/rb/find-leakers.pl
@@ -47,28 +47,42 @@ LINE: while (<>) {
 
     my @fields = split(/ /, $_);
     my $class = shift(@fields);
     my $obj   = shift(@fields);
     my $sno   = shift(@fields);
     my $op    = shift(@fields);
     my $cnt   = shift(@fields);
 
+    # for AddRef/Release $cnt is the refcount, for Ctor/Dtor it's the size
+
     if ($op eq 'AddRef' && $cnt == 1) {
         # Example: <nsStringBuffer> 0x01AFD3B8 1 AddRef 1
 
         $allocs{$obj} = ++$counter{$class}; # the order of allocation
         $classes{$obj} = $class;
     }
     elsif ($op eq 'Release' && $cnt == 0) {
         # Example: <nsStringBuffer> 0x01AFD3B8 1 Release 0
 
         delete($allocs{$obj});
         delete($classes{$obj});
     }
+    elsif ($op eq 'Ctor') {
+	# Example: <PStreamNotifyParent> 0x08880BD0 8 Ctor (20)
+
+	$allocs{$obj} = ++$counter{$class};
+	$classes{$obj} = $class;
+    }
+    elsif ($op eq 'Dtor') {
+	# Example: <PStreamNotifyParent> 0x08880BD0 8 Dtor (20)
+
+	delete($allocs{$obj});
+	delete($classes{$obj});
+    }
 }
 
 
 sub sort_by_value {
     my %x = @_;
     sub _by_value($) { my %x = @_; $x{$a} cmp $x{$b}; } 
     sort _by_value keys(%x);
 }