#!/usr/bin/perl -w # vim:sw=4:et:ts=4:tw=72 # rank-output.pl - Print nice HTML file based on talkback database. # L. David Baron, 2001-08-18 use 5.004; use strict; use Getopt::Long; my $logname = "seamonkey-crash-analysis-detailed"; GetOptions("firstdate=i", "lastdate=i", "db=s", "bugdb=s"); $::opt_db || die qq{ usage: $0 --db The database. [REQUIRED] --bugdb Database mapping stack signatures to bugs. --firstdate YYYYMMDD Exclude builds before YYYYMMDD. --lastdate YYYYMMDD Exclude builds after YYYYMMDD. }; require "dbfuncs.pl"; require "bugdb.pl"; my %database; read_database($::opt_db, \%database); my %bug_database; if ($::opt_bugdb) { read_bug_database($::opt_bugdb, \%bug_database); } my %sigs; # hash from signature (or special TOTAL) to references to # hashes of three members # dates) a hash from dates (as strings) to the crash count # platforms) a hash from platforms (as strings) to the crash count # TOTAL) total crash count sub fill_sigs() { foreach my $bbid (keys(%database)) { my $dbentry = $database{$bbid}; my $buildday = substr($dbentry->{builddate}, 0, 8); next if ((defined $::opt_firstdate && $buildday lt $::opt_firstdate) || (defined $::opt_lastdate && $buildday gt $::opt_lastdate)); if (!defined $sigs{TOTAL}) { $sigs{TOTAL} = { dates => {}, platforms => {} }; } my $totalentry = $sigs{TOTAL}; if (!defined $sigs{$dbentry->{stacksig}}) { $sigs{$dbentry->{stacksig}} = { dates => {}, platforms => {} }; } my $sigentry = $sigs{$dbentry->{stacksig}}; # increment the entries if (defined($totalentry->{dates}->{$buildday})) { ++($totalentry->{dates}->{$buildday}); } else { $totalentry->{dates}->{$buildday} = 1; } if (defined($totalentry->{platforms}->{$dbentry->{platform}})) { ++($totalentry->{platforms}->{$dbentry->{platform}}); } else { $totalentry->{platforms}->{$dbentry->{platform}} = 1; } if (defined($totalentry->{TOTAL})) { ++($totalentry->{TOTAL}); } else { $totalentry->{TOTAL} = 1; } if (defined($sigentry->{dates}->{$buildday})) { ++($sigentry->{dates}->{$buildday}); } else { $sigentry->{dates}->{$buildday} = 1; } if (defined($sigentry->{platforms}->{$dbentry->{platform}})) { ++($sigentry->{platforms}->{$dbentry->{platform}}); } else { $sigentry->{platforms}->{$dbentry->{platform}} = 1; } if (defined($sigentry->{TOTAL})) { ++($sigentry->{TOTAL}); } else { $sigentry->{TOTAL} = 1; } } } sub print_sig_page($) { my ($dirname) = $_; } sub print_main_page() { my $dirname = "output.$$"; mkdir($dirname, 0777); open(INDEX, ">"."$dirname/index.html"); my $totalentry = $sigs{TOTAL}; my @dates = sort {$b cmp $a} keys(%{$totalentry->{dates}}); my @platforms = sort {$a cmp $b} keys(%{$totalentry->{platforms}}); print INDEX << "EndOfHead"; Talkback data summary EndOfHead print INDEX "\n" . "" . ""; foreach my $date (@dates) { my $chopdate = substr($date, 4, 2) . "-" . substr($date, 6, 2); print INDEX "" } foreach my $platform (@platforms) { print INDEX "" } print INDEX "\n"; my @rankedsigs = sort { $sigs{$b}->{TOTAL} <=> $sigs{$a}->{TOTAL} } keys(%sigs); foreach my $sig (@rankedsigs) { my $sigentry = $sigs{$sig}; next if ($sigentry == $totalentry); print INDEX "" . ""; foreach my $date (@dates) { my $num = $sigentry->{dates}->{$date}; if (defined $num) { print INDEX ""; } else { print INDEX ""; } } foreach my $platform (@platforms) { my $num = $sigentry->{platforms}->{$platform}; if (defined $num) { print INDEX ""; } else { print INDEX ""; } } print INDEX "\n"; } print INDEX "
SignatureBugs$chopdate$platformTotal
" . $sig . ""; if (defined $bug_database{$sig}) { my @bugs = split(" ", $bug_database{$sig}); foreach my $bug (@bugs) { if ($bug =~ /^\d*$/) { print INDEX "$bug "; } else { print INDEX "$bug "; } } } print INDEX "" . $num . "0" . $num . "0" . $sigentry->{TOTAL} . "
\n\n"; close(INDEX); } fill_sigs(); print_main_page();