tools/rb/filter-log.pl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/rb/filter-log.pl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +#!/usr/bin/perl -w
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +# Filter a refcount log to show only the entries for a single object.
    1.11 +# Useful when manually examining refcount logs containing multiple
    1.12 +# objects.
    1.13 +
    1.14 +use 5.004;
    1.15 +use strict;
    1.16 +use Getopt::Long;
    1.17 +
    1.18 +GetOptions("object=s");
    1.19 +
    1.20 +$::opt_object ||
    1.21 +     die qq{
    1.22 +usage: filter-log-for.pl < logfile
    1.23 +  --object <obj>         The address of the object to examine (required)
    1.24 +};
    1.25 +
    1.26 +warn "object $::opt_object\n";
    1.27 +
    1.28 +LINE: while (<>) {
    1.29 +    next LINE if (! /^</);
    1.30 +    my $line = $_;
    1.31 +    my @fields = split(/ /, $_);
    1.32 +
    1.33 +    my $class = shift(@fields);
    1.34 +    my $obj   = shift(@fields);
    1.35 +    next LINE unless ($obj eq $::opt_object);
    1.36 +    my $sno   = shift(@fields);
    1.37 +    my $op  = shift(@fields);
    1.38 +    my $cnt = shift(@fields);
    1.39 +
    1.40 +    print $line;
    1.41 +
    1.42 +    # The lines in the stack trace
    1.43 +    CALLSITE: while (<>) {
    1.44 +        print;
    1.45 +        last CALLSITE if (/^$/);
    1.46 +    }
    1.47 +}

mercurial