]>
git.ipfire.org Git - thirdparty/squid.git/blob - scripts/find-alive.pl
3 # Reads cache.log from STDIN, preferrably with full debugging enabled.
4 # Finds creation and destruction messages for a given class.
5 # At the end, reports log lines that correspond to still-alive objects.
6 # Also reports the number of objects found (total and still-alive).
8 # Many classes have unique creation/destruction line patterns so we
9 # have to hard-code those patterns in the %Pairs table below. That
10 # table usually contains a few outdated entries.
15 my $Thing = $ARGV[0] or die("usage: $0 <Thing-to-look-for>\n");
17 # When creation and destriction messages are standardizes, we
18 # will be able to support any class without this hard-coded table.
19 # We try to do that now (see "guessing ..." below), but it does
23 'AsyncCall.* constructed, this=(\S+)',
24 'AsyncCall.* destruct.*, this=(\S+)',
27 '\bHttpHeaderEntry.* created HttpHeaderEntry (\S+)',
28 '\bHttpHeaderEntry.* destroying entry (\S+)',
30 ClientSocketContext
=> [
31 '\bClientSocketContext constructing, this=(\S+)',
32 '\bClientSocketContext destructed, this=(\S+)',
35 '(?:ICAP|Icap).* constructed, this=(\S+)',
36 '(?:ICAP|Icap).* destruct.*, this=(\S+)',
39 'Adaptation::Icap::ModXact.* constructed, this=(\S+)',
40 'Adaptation::Icap::ModXact.* destruct.*, this=(\S+)',
42 ICAPClientReqmodPrecache
=> [
43 'ICAPClientReqmodPrecache constructed, this=(\S+)',
44 'ICAPClientReqmodPrecache destruct.*, this=(\S+)',
47 'HttpStateData (\S+) created',
48 'HttpStateData (\S+) destroyed',
52 '(?:cbdataFree|cbdataUnlock): Freeing (\S+)',
55 'fd_open.*\sFD (\d+)',
56 'fd_close\s+FD (\d+)',
59 'StoreMap.* opened .*entry (\d+) for \S+ (\S+)',
60 'StoreMap.* closed .*entry (\d+) for \S+ (\S+)',
63 'PageStack.* pop: (sh_page\S+) at',
64 'PageStack.* push: (sh_page\S+) at',
68 if (!$Pairs{$Thing}) {
69 warn("guessing construction/destruction pattern for $Thing\n");
71 "\\b$Thing construct.*, this=(\\S+)",
72 "\\b$Thing destruct.*, this=(\\S+)",
76 die("unsupported Thing, stopped") unless $Pairs{$Thing};
78 my $reConstructor = $Pairs{$Thing}->[0];
79 my $reDestructor = $Pairs{$Thing}->[1];
85 if (my @conIds = (/$reConstructor/)) {
86 my $id = join(':', @conIds);
87 #die($_) if $Alive{$id};
88 $AliveImage{$id} = $_;
89 ++$Count unless $AliveCount{$id}++;
91 elsif (my @deIds = (/$reDestructor/)) {
92 my $id = join(':', @deIds);
93 #warn("unborn: $_") unless $AliveCount{$id};
94 $AliveImage{$id} = undef() unless --$AliveCount{$id};
98 printf(STDERR
"Found %d %s\n", $Count, $Thing);
101 foreach my $alive (sort grep { defined($_) } values %AliveImage) {
102 next unless defined $alive;
103 printf("Alive: %s", $alive);
107 printf(STDERR
"found %d still-alive %s\n", $aliveCount, $Thing);