diffgdb: Significant ignore patterns reduction.
[nethome.git] / bin / diffgdb
1 #! /usr/bin/perl
2 use strict;
3 use warnings;
4
5 my @ignore=(
6 qr{^.PASS: }o,
7 qr{^.KPASS: }o,
8 qr{^-FAIL: }o,
9 qr{^-KFAIL: }o,
10 qr{^-XFAIL: }o,
11 qr{^.Test Run By }o,
12 qr{^.gnatbind }o,
13 qr{^.gnatlink }o,
14 qr{^.gnatlink: }o,
15 qr{^.gnatmake: }o,
16 qr{^.gcc }o,
17 qr{^./usr/bin/ld: .* architecture of input file .* is incompatible with .* output\n$}o,
18 qr{^.collect2: }o,
19 #qr{^.UNSUPPORTED: }o,
20 #qr{^.UNTESTED: }o,
21 #qr{^.UNRESOLVED: }o,
22 #qr{^.ERROR: }o,
23 #qr{^.WARNING: }o,
24 qr{^.[^:]*[.]ad[sb]:[0-9]}o,
25 qr{^.gdb compile failed, }o,
26 qr{^.gdb compile failed, /usr/bin/ld: /tmp/[a-zA-Z0-9]*.o: relocation R_X86_64_32S against `a local symbol. can not be used when making a shared object; recompile with -fPIC\n$}o,
27 qr{^./tmp/[a-zA-Z0-9]*.o: could not read symbols: Bad value\n$}o,
28 qr{^./tmp/[a-zA-Z0-9]*.s:\d+: Error: unrecognized symbol type "gnu_indirect_function"\n$}o,
29 qr{^./tmp/[a-zA-Z0-9]*.o: In function `\S+':\n$}o,
30 qr{^./tmp/[a-zA-Z0-9]*.o:.*: undefined reference to `.*'\n$}o,
31 qr{^./tmp/[a-zA-Z0-9]*.s:\d+: Error: syntax error; found `.' but expected `,'\n$}o,
32 qr{^./tmp/[a-zA-Z0-9]*.s:\d+: Error: junk at end of line: `.(?:plt|local)'\n$}o,
33 qr{^./usr/bin/ld: /tmp/[a-zA-Z0-9]*.o\(\.text\+0x[0-9a-f]+\): unresolvable R_PPC64_REL24 relocation against symbol `\S+'\n$}o,
34 qr{^.# of }o,
35 qr{^./home/}o,
36 qr{^.\.\./as-new [0-9.]*\n$}o,
37 qr{^.(?:/unsafe)?ld/ld-new [0-9.]*\n$}o,
38 qr{\bgdb version  \d\S+ -nw -nx\b}o,
39 qr{^.FAIL: \S+\.exp: valgrind check \d+\n$}o,
40 qr{^.KFAIL: gdb.threads/watchthreads2.exp: gdb can drop watchpoints in multithreaded app \(PRMS: gdb/10116\)\n$}o,
41 qr{^.FAIL: gdb.base/info-os.exp: .*\n$}o,
42 );
43 my $ignore=shift @ignore;
44 $ignore=qr/$ignore|$_/ for @ignore;
45
46 my $opt_new;
47 while (1) {
48   if ($ARGV[0] eq "-r") {
49     $ignore=undef;
50     shift;
51     next;
52   }
53   if ($ARGV[0] eq "-N") {
54     $opt_new=1;
55     shift;
56     next;
57   }
58   last;
59 }
60
61 my $last;
62 my $lastfile;
63 local *DIFF;
64 my(@diff)=("diff","-rU-1",@ARGV);
65 open DIFF,"-|",@diff or die join(" ",@diff).": $!";
66 while (<DIFF>) {
67   next if /^diff /;
68   my($thisname)=m{^.(?:Running (?:.*/)?|[A-Z]+: )(gdb[.]\w+/\S+[.]exp)(?: \Q...\E|: .*)$};
69   $thisname||=(m{^.\t\t=== gdb (Summary) ===\n$})[0];
70   $thisname||=(m{^(Only in) })[0];
71   my $this;
72   if (!$thisname || ($last && $thisname eq $last->{"name"})) {
73 #if (!$thisname) { print "X: !thisname\n"; } else { print "X: \"".$last->{"name"}."\" -> \"$thisname\"\n"; }
74     $this=$last;
75   } else {
76 #print "X: new \"$thisname\"\n";
77     $last=$this={"name"=>$thisname,"+Running"=>(/^[+]/||0)};
78   }
79   next if /^@@ .* @@\n$/;
80   if ($this->{"print"}) {
81     print;
82     next;
83   }
84   if (/^Only in /) {
85     $lastfile=$_;
86   }
87   if (/^--- /) {
88     $lastfile=$_;
89     next;
90   }
91   if (/^\Q+++\E /) {
92     $lastfile.=$_;
93     next;
94   }
95   $this->{"buffer"}.=$_;
96   next if /^ /;
97   next if /^[+]Running / && $thisname && !$opt_new;
98   next if $ignore && /$ignore/o;
99   next if /^[+]FAIL: / && $this->{"+Running"};
100   next if /^[+]KFAIL: / && $this->{"+Running"};
101   next if /^[+]XFAIL: / && $this->{"+Running"};
102   next if /^[+]UNTESTED: / && $this->{"+Running"};
103   next if /^[+]gdb compile failed, / && $this->{"+Running"};
104   next if /^[+].*: Error: bad register name `%.*'\n$/ && $this->{"+Running"};
105   next if /^[+].*: Error: `.*' is only supported in 64-bit mode\n$/ && $this->{"+Running"};
106
107   $this->{"print"}=1;
108   print $lastfile||""; $lastfile=undef();
109   print "\n#".($this->{"name"}||"???")."\n";
110   print $this->{"buffer"}; $this->{"buffer"}=undef();
111   next;
112 }