1#!/usr/bin/perl
2
3use strict;
4
5sub help()
6{
7    print "usage: $0 [-r]\n";
8    print "Counts the number of errors of each type.\n";
9    print "-r means down to the nearest 10.\n";
10    exit 1;
11}
12
13my $round;
14my $arg = shift;
15if ($arg =~ /-h/) {
16    help();
17} elsif ($arg =~ /-r/) {
18    $round = 1;
19}
20
21my %msgs;
22
23sub add_msg($)
24{
25    my $msg = shift;
26
27    if (defined $msgs{$msg}) {
28	$msgs{$msg}++;
29    } else {
30	$msgs{$msg} = 1;
31    }
32}
33
34while (<>) {
35    s/^.*?:\d+(|:\d+:) .*? //;
36    s/[us](16|32|64)(min|max)//g;
37    s/0x\w+//g;
38    s/[01234567890]//g;
39    if ($_ =~ /can't/) {
40        s/(.*can't.*').*?('.*)/$1 $2/;
41        s/(.*?)'.*?'(.*can't.*)/$1 $2/;
42    } elsif ($_ =~ /don't/) {
43    	s/(.*don't.*').*?('.*)/$1 $2/;
44    } else {
45    	s/'.*?'/''/g;
46    }
47    s/,//g;
48    s/\(\w+ returns null\)/(... returns null)/;
49    s/dma on the stack \(.*?\)/dma on the stack (...)/;
50    s/possible ERR_PTR '' to .*/possible ERR_PTR '' to .../;
51    s/inconsistent returns ([^ ]+?) locked \(\)/inconsistent returns ... locked ()/;
52    s/(.*) [^ ]* (too large for) [^ ]+ (.*)/$1 $2 $3/;
53
54    add_msg($_);
55}
56
57foreach my $key (sort { $msgs{$b} <=> $msgs{$a} } keys %msgs) {
58    my $count = $msgs{$key};
59
60    if ($round) {
61	$count = $msgs{$key} - $msgs{$key} % 10;
62    }
63    print "$count $key";
64}
65