-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlinux-log-diff
executable file
·195 lines (174 loc) · 5.19 KB
/
linux-log-diff
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/perl -w
# FIXME scripts/mod/file2alias.c
# FATAL: drivers/input/serio/hil_mlc: struct serio_device_id is not terminated
# with a NULL entry!
# http://kisskb.ellerman.id.au/kisskb/buildresult/3385851/
#
# © Copyright 2010 by Geert Uytterhoeven
#
# This file is subject to the terms and conditions of the GNU General Public
# License.
#
sub usage()
{
my $name = $0;
$name =~ s@.*/@@g;
die <<EOF;
Usage: $name [options] oldlog newlog
Valid options:
-h, --help Display this help
-d, --debug Enable debug mode
EOF
}
$common_prefix = "";
sub set_common_prefix()
{
my $s = shift;
return if $s !~ m{^/};
return if $s =~ m{^/opt/};
return if $s =~ m{^/tmp/};
return if $s =~ m{^/usr/};
if (defined($common_prefix)) {
chop $common_prefix while ($s !~ /^\Q$common_prefix\E/);
} else {
$common_prefix = $s;
}
}
sub add_record()
{
my $db = shift;
my $log = shift;
my $file = shift;
my $loc = shift;
my $msg = shift;
$db->{$file}{$msg}{$log}{$loc} = 1;
&set_common_prefix($file);
}
sub read_log()
{
my $log = shift;
my ($line, $file,$loc, $msg);
open(LOG, "<$log") or die "Cannot open $log";
while ($line = <LOG>) {
chomp($line);
if ($line =~ m{^warning: The last gc run reported the following} or
$line =~ m{^warning: There are too many unreachable loose objects}) {
# git warning
print STDERR "Ignoring git: $line\n" if $debug;
} elsif (($file, $loc, $msg) =
$line =~ m{(^[^:]*):([0-9:]+):\s*(error:\s*.*$)}i) {
# compile error
&add_record(\%errors, $log, $file, $loc, $msg);
} elsif (($msg1, $loc, $msg2) =
$line =~ m{(^.*):\((.*\))(.*: undefined reference.*)}i) {
# link error: undefined reference.
&add_record(\%errors, $log, "error", $loc, "$msg1$msg2");
} elsif (($msg1, $loc, $msg2) =
$line =~ m{^(.*)(\(.*\)): (relocation truncated.*)}i) {
# link error: relocation truncated
$msg1 .= " " if ($msg1 ne "");
&add_record(\%errors, $log, "error", $loc, "$msg1$msg2");
} elsif (($loc, $msg) =
$line =~ m{(^\(.*\)): (undefined reference.*)}i) {
# link error: undefined reference.
&add_record(\%errors, $log, "error", $loc, "$msg");
} elsif (($msg) = $line =~ m{error: (.*undefined!)}i) {
# link error: undefined symbol
&add_record(\%errors, $log, "error", "N/A", $msg);
} elsif (($file, $msg) =
$line =~ m{(^[^:]*):\s*(error in\s*.*$)}i) {
# link error
&add_record(\%errors, $log, $file, "N/A", $msg);
} elsif (($target) = $line =~ m{No rule to make target .(.*).,}i) {
# make error
&add_record(\%errors, $log, "error", "N/A",
"No rule to make target $target");
} elsif (($target) = $line =~ m{Inconsistent kallsyms data}i) {
# kallsyms error
&add_record(\%errors, $log, "error", "N/A",
"Inconsistent kallsyms data");
} elsif (($file, $loc, $msg) =
$line =~ m{(^[^:]*):([0-9:]+):\s*(warning:\s*.*$)}i) {
# compile warning
&add_record(\%warnings, $log, $file, $loc, $msg);
} elsif (($msg) = $line =~ m{(warning:\smodpost.*$)}i) {
# modpost warning
&add_record(\%warnings, $log, "modpost", "N/A", $msg);
} elsif ($line =~ m{^distcc}) {
# distcc cruft
print STDERR "Ignoring distcc: $line\n" if $debug;
} elsif (($msg) = $line =~ m{^Warning (\(.*)}i) {
# dtc warning
&add_record(\%warnings, $log, "dtc", "N/A", $msg);
} elsif (($msg) = $line =~ m{^warning: (.*)}i) {
# modpost or relocs_check.pl warning
&add_record(\%warnings, $log, "warning", "N/A", $msg);
} elsif ($debug) {
print STDERR "Unhandled error: $line\n" if ($line =~ /error/i);
print STDERR "Unhandled warning: $line\n" if ($line =~ /warn/i);
}
}
close(LOG);
}
sub print_report
{
my $type = $_[0];
my %db = %{$_[1]};
my ($file, $msgs, $msg, $logs);
my @regressions = ();
my @improvements = ();
while (($file, $msgs) = each %db) {
$file =~ s@^$common_prefix@@;
while (($msg, $logs) = each %$msgs) {
my @msgs1 = keys %{$logs->{$log1}};
my @msgs2 = keys %{$logs->{$log2}};
next if $#msgs1 == $#msgs2 and !$debug;
my $line = "$file: $msg: " . join(', ', @msgs1) . " => " .
join(', ', @msgs2) . "\n";
if ($#msgs1 < $#msgs2) {
print "NEW : $line" if $debug;
push @regressions, $line;
} elsif ($#msgs1 > $#msgs2) {
print "FIXED: $line" if $debug;
push @improvements, $line;
} elsif ($debug) {
print "$line";
}
}
}
$n = $#regressions + 1;
if ($n) {
print "\n$n $type regressions:\n + ";
print join(" + ", sort @regressions);
}
$n = $#improvements + 1;
if ($n) {
print "\n$n $type improvements:\n - ";
print join(" - ", sort @improvements);
}
}
while (defined($ARGV[0])) {
$option = $ARGV[0];
last if not $option =~ /^-/;
if ($option eq '-h' or $option eq '--help') {
&usage();
} elsif ($option eq '-d' or $option eq '--debug') {
$debug = 1;
} elsif ($option eq '--') {
shift @ARGV;
last;
} else {
print STDERR "Unknown option $option\n";
&usage();
}
shift @ARGV;
}
&usage if ($#ARGV != 1);
$log1 = shift @ARGV;
$log2 = shift @ARGV;
&read_log($log1);
&read_log($log2);
print "\n*** ERRORS ***\n";
print_report("error", \%errors);
print "\n\n*** WARNINGS ***\n";
print_report("warning", \%warnings);