]>
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 '\bHttpRequest.* constructed, this=(\S+)',
28 '\bHttpRequest.* destructed, this=(\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: Freeing (\S+)',
55 'fd_open.*\sFD (\d+)',
56 'fd_close\s+FD (\d+)',
60 if (!$Pairs{$Thing}) {
61 warn("guessing construction/destruction pattern for $Thing\n");
63 "\\b$Thing construct.*, this=(\\S+)",
64 "\\b$Thing destruct.*, this=(\\S+)",
68 die("unsupported Thing, stopped") unless $Pairs{$Thing};
70 my $reConstructor = $Pairs{$Thing}->[0];
71 my $reDestructor = $Pairs{$Thing}->[1];
76 if (/$reConstructor/) {
77 #die($_) if $Alive{$1};
81 elsif (/$reDestructor/) {
82 #warn("unborn: $_") unless $Alive{$1};
87 printf(STDERR
"Found %d %s\n", $Count, $Thing);
90 foreach my $alive (sort grep { defined($_) } values %Alive) {
91 next unless defined $alive;
92 printf("Alive: %s", $alive);
96 printf(STDERR
"found %d still-alive %s\n", $AliveCount, $Thing);