File: leak

package info (click to toggle)
lsof 4.93.2%2Bdfsg-1.1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 5,936 kB
  • sloc: ansic: 75,924; sh: 12,859; makefile: 1,686; perl: 1,146; awk: 214
file content (51 lines) | stat: -rwxr-xr-x 1,602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/local/bin/perl

# leak < <lsof_leak_debug_output>

while (<>) {
    if (!/^MEM[afr]/) { next; }
    chop;
    if (/^MEMa ([^ ]*) (.*)/) {
	$new = $1; $loc = $2;
	if (defined($mem{$new})) {
	    print "ERROR: $new already allocated;\n";
	    print "  OLD: $mem{$new}\n";
	    print "  NEW: $_\n";
	} else {$mem{$new} = $loc; }
	next;
    } elsif (/^MEMf ([^ ]*) (.*)/) {
	$old = $1; $loc = $2;
	if (!defined($mem{$old})) {
	    print "ERROR: $old not allocated: $_\n";
	} else { undef($mem{$old}); }
	next;
    } elsif (/^MEMr ([^ ]*) ([^ ]*) (.*)/) {
	$old = $1; $new = $2; $loc = $3;
	if (!defined($mem{$old})) {
	    print "ERROR: $old not allocated: $_\n";
	} else { undef($mem{$old}); }
	if (defined($mem{$new})) {
	    print "ERROR: $new already allocated;\n";
	    print "  OLD: $mem{$new}\n";
	    print "  NEW: $_\n";
	} else {$mem{$new} = $loc; }
	next;
    } else { print "ERROR: MEM what? $_\n"; }
}
foreach $addr (sort keys(%mem)) {
    if (defined($mem{$addr})) {
	if (($mem{$addr} =~ /^rnch.c/)) { next; }
	if (($mem{$addr} =~ /^print.c:14[18]/)) { next; }
	if (($mem{$addr} =~ /^print.c:323/)) { next; }
	if (($mem{$addr} =~ /^print.c:1135/)) { next; }
	if (($mem{$addr} =~ /^print.c:207/)) { next; }
	if (($mem{$addr} =~ /^print.c:219/)) { next; }
	if (($mem{$addr} =~ /^print.c:335/)) { next; }
	if (($mem{$addr} =~ /^print.c:261/)) { next; }
	if (($mem{$addr} =~ /^print.c:1076/)) { next; }
	if (($mem{$addr} =~ /^proc.c:191/)) { next; }
	if (($mem{$addr} =~ /^main.c:581/)) { next; }
	if (($mem{$addr} =~ /^rvfs.c:68/)) { next; }
	print "IN USE $addr: $mem{$addr}\n";
    }
}