|
1 #!/usr/bin/perl -w |
|
2 # |
|
3 # This Source Code Form is subject to the terms of the Mozilla Public |
|
4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
6 |
|
7 # Filter a refcount log to show only the entries for a single object. |
|
8 # Useful when manually examining refcount logs containing multiple |
|
9 # objects. |
|
10 |
|
11 use 5.004; |
|
12 use strict; |
|
13 use Getopt::Long; |
|
14 |
|
15 GetOptions("object=s"); |
|
16 |
|
17 $::opt_object || |
|
18 die qq{ |
|
19 usage: filter-log-for.pl < logfile |
|
20 --object <obj> The address of the object to examine (required) |
|
21 }; |
|
22 |
|
23 warn "object $::opt_object\n"; |
|
24 |
|
25 LINE: while (<>) { |
|
26 next LINE if (! /^</); |
|
27 my $line = $_; |
|
28 my @fields = split(/ /, $_); |
|
29 |
|
30 my $class = shift(@fields); |
|
31 my $obj = shift(@fields); |
|
32 next LINE unless ($obj eq $::opt_object); |
|
33 my $sno = shift(@fields); |
|
34 my $op = shift(@fields); |
|
35 my $cnt = shift(@fields); |
|
36 |
|
37 print $line; |
|
38 |
|
39 # The lines in the stack trace |
|
40 CALLSITE: while (<>) { |
|
41 print; |
|
42 last CALLSITE if (/^$/); |
|
43 } |
|
44 } |