2000-08-09 20:45:24 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
# Perl script to analyze the log output from xpcom and print
|
|
|
|
# the results in html.
|
|
|
|
#
|
|
|
|
# To get the xpcom log output to a file say xpcom.log:
|
|
|
|
# setenv NSPR_LOG_MODULES nsComponentManager:5
|
|
|
|
# setenv NSPR_LOG_FILE xpcom.log
|
|
|
|
# ./mozilla
|
|
|
|
# <quit>
|
|
|
|
#
|
2000-09-14 23:20:49 +00:00
|
|
|
# To get registry (used to figure out contractid mappings)
|
2000-08-09 20:45:24 +00:00
|
|
|
# ./regExport component.reg > registry.txt
|
|
|
|
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# a) To get simple output
|
|
|
|
# cat xpcom.log | perl xpcom-log-analyze.pl > xpcom-log.html
|
|
|
|
#
|
2000-09-14 23:20:49 +00:00
|
|
|
# b) To get all possible cid->contractid mappings filled in
|
2000-08-09 20:45:24 +00:00
|
|
|
# cat xpcom.log registry.txt | perl xpcom-log-analyze.pl > xpcom-log.html
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Author: Suresh Duddi <dp@netscape.com>
|
|
|
|
# Created Aug 9 2000
|
|
|
|
|
|
|
|
while (<>)
|
|
|
|
{
|
|
|
|
chomp;
|
2000-09-14 23:20:49 +00:00
|
|
|
if ( /ContractIDToClassID.*\}/ )
|
2000-08-09 20:45:24 +00:00
|
|
|
{
|
2000-09-14 23:20:49 +00:00
|
|
|
# Passed contractid to cid mapping. Add contractid to cid mapping
|
2000-08-09 20:45:24 +00:00
|
|
|
$cid = GetCID();
|
2000-09-14 23:20:49 +00:00
|
|
|
$contractid = GetContractID();
|
|
|
|
$contractid_map{$cid} = $contractid;
|
|
|
|
$contractid_passed{$contractid}++;
|
|
|
|
$ncontractid_passed++;
|
2000-08-09 20:45:24 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2000-09-14 23:20:49 +00:00
|
|
|
if ( /ContractIDToClassID.*FAILED/ )
|
2000-08-09 20:45:24 +00:00
|
|
|
{
|
2000-09-14 23:20:49 +00:00
|
|
|
# Failed contractid. Collect it.
|
|
|
|
$contractid = GetContractID();
|
|
|
|
$contractid_failed{$contractid}++;
|
|
|
|
$ncontractid_failed++;
|
2000-08-09 20:45:24 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( /CreateInstance.*succeeded/ )
|
|
|
|
{
|
|
|
|
# Successful create instance
|
|
|
|
$objects{GetCID()}++;
|
|
|
|
$nobjects++;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( /CreateInstance.*FAILED/ )
|
|
|
|
{
|
|
|
|
# Failed create instance
|
|
|
|
$objects_failed{GetCID()}++;
|
|
|
|
$nobjects_failed++;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( /: loading/ )
|
|
|
|
{
|
|
|
|
$dll = GetDll();
|
|
|
|
# make the name a little pretty
|
|
|
|
$dll =~ s/^.*bin\///;
|
|
|
|
$dll_loaded[@dll_loaded] = $dll;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( / classID - \{/ )
|
|
|
|
{
|
2000-09-14 23:20:49 +00:00
|
|
|
# this is from the output of registry. Try to update contractid_map
|
2000-08-09 20:45:24 +00:00
|
|
|
$cid = GetCID();
|
2000-09-14 23:20:49 +00:00
|
|
|
# Get the next contractid or classname line until a empty new line
|
|
|
|
$_ = <STDIN> until (/ContractID|ClassName/ || length == 1);
|
2000-08-09 20:45:24 +00:00
|
|
|
chomp;
|
2000-09-14 23:20:49 +00:00
|
|
|
$contractid = $_;
|
|
|
|
$contractid =~ s/^.*= //;
|
|
|
|
$contractid_map{$cid} = $contractid;
|
2000-08-09 20:45:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintHTMLResults();
|
|
|
|
|
|
|
|
|
2000-09-14 23:20:49 +00:00
|
|
|
sub GetContractID() {
|
2000-08-09 20:45:24 +00:00
|
|
|
# Get a proid from a line
|
2000-09-14 23:20:49 +00:00
|
|
|
my($contractid) = $_;
|
|
|
|
$contractid =~ s/^.*\((.*)\).*$/$1/;
|
|
|
|
# print "Got Progid: $contractid\n";
|
|
|
|
return $contractid;
|
2000-08-09 20:45:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub GetCID() {
|
|
|
|
# Get a CID from a line
|
|
|
|
my($cid) = $_;
|
|
|
|
$cid =~ s/^.*\{(.*)\}.*$/$1/;
|
|
|
|
# print "Got cid: $cid\n";
|
|
|
|
return $cid;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub GetDll() {
|
|
|
|
# Get a Dll from a line
|
|
|
|
my($dll) = $_;
|
|
|
|
$dll =~ s/^.*\"(.*)\".*$/$1/;
|
|
|
|
# print "Got dll: $dll\n";
|
|
|
|
return $dll;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Print the results of our log analysis in html
|
|
|
|
#
|
|
|
|
sub PrintHTMLResults()
|
|
|
|
{
|
|
|
|
$now_time = localtime();
|
|
|
|
print "<HTML><HEAD><title>XPCOM Log analysis dated: $now_time\n";
|
|
|
|
print "</TITLE></HEAD>\n";
|
|
|
|
print "<H1><center>\n";
|
|
|
|
print "XPCOM Log analysis dated: $now_time\n";
|
|
|
|
print "</center></H1>\n";
|
|
|
|
# ========================================================================
|
|
|
|
# Performance analysis
|
|
|
|
# ========================================================================
|
|
|
|
print "<H2>Performance Analysis</H2>\n";
|
|
|
|
|
|
|
|
# Number of dlls loaded
|
|
|
|
$n = @dll_loaded;
|
|
|
|
print "<H3>Dlls Loaded : $n</H3>\n";
|
|
|
|
print "<blockquote><pre>\n";
|
|
|
|
PrintArray(@dll_loaded);
|
|
|
|
print "</blockquote></pre>\n";
|
|
|
|
|
|
|
|
# Objects created with a histogram
|
|
|
|
print "<H3>Objects created : $nobjects</H3>\n";
|
|
|
|
print "<blockquote><pre>\n";
|
|
|
|
@sorted_key = SortKeyByValue(%objects);
|
|
|
|
foreach $cid (@sorted_key)
|
|
|
|
{
|
2000-09-14 23:20:49 +00:00
|
|
|
printf("%5d %s [%s]\n", $objects{$cid}, $cid, $contractid_map{$cid});
|
2000-08-09 20:45:24 +00:00
|
|
|
}
|
|
|
|
print "</blockquote></pre>\n";
|
|
|
|
|
2000-09-14 23:20:49 +00:00
|
|
|
# Passed contractid calls
|
|
|
|
print "<H3>Succeeded ContractIDToClassID() : $ncontractid_passed</H3>\n";
|
2000-08-09 20:45:24 +00:00
|
|
|
print "<blockquote><pre>\n";
|
2000-09-14 23:20:49 +00:00
|
|
|
@sorted_key = SortKeyByValue(%contractid_passed);
|
|
|
|
foreach $contractid (@sorted_key)
|
2000-08-09 20:45:24 +00:00
|
|
|
{
|
2000-09-14 23:20:49 +00:00
|
|
|
printf("%5d %s\n", $contractid_passed{$contractid}, $contractid);
|
2000-08-09 20:45:24 +00:00
|
|
|
}
|
|
|
|
print "</blockquote></pre>\n";
|
|
|
|
|
|
|
|
|
|
|
|
# ========================================================================
|
|
|
|
# Error analysis
|
|
|
|
# ========================================================================
|
|
|
|
print "<H2>Error Analysis</H2>\n";
|
|
|
|
|
|
|
|
# CreateInstance() FAILED
|
|
|
|
print "<H3>Failed CreateInstance() : $nobjects_failed</H3>\n";
|
|
|
|
print "<blockquote><pre>\n";
|
|
|
|
@sorted_key = SortKeyByValue(%objects_failed);
|
|
|
|
foreach $cid (@sorted_key)
|
|
|
|
{
|
2000-09-14 23:20:49 +00:00
|
|
|
printf("%5d %s [%s]\n", $objects_failed{$cid}, $cid, $contractid_map{$cid});
|
2000-08-09 20:45:24 +00:00
|
|
|
}
|
|
|
|
print "</blockquote></pre>\n";
|
|
|
|
|
2000-09-14 23:20:49 +00:00
|
|
|
# ContractIDToClassID() FAILED with a histogram
|
|
|
|
print "<H3>Failed ContractIDToClassID() : $ncontractid_failed</H3>\n";
|
2000-08-09 20:45:24 +00:00
|
|
|
print "<blockquote><pre>\n";
|
2000-09-14 23:20:49 +00:00
|
|
|
@sorted_key = SortKeyByValue(%contractid_failed);
|
|
|
|
foreach $contractid (@sorted_key)
|
2000-08-09 20:45:24 +00:00
|
|
|
{
|
2000-09-14 23:20:49 +00:00
|
|
|
printf("%5d %s\n", $contractid_failed{$contractid}, $contractid);
|
2000-08-09 20:45:24 +00:00
|
|
|
}
|
|
|
|
print "</blockquote></pre>\n";
|
|
|
|
|
|
|
|
# end the html listing
|
|
|
|
print "</HTML>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub PrintArray()
|
|
|
|
{
|
|
|
|
my(@array) = @_;
|
|
|
|
for ($i=0; $i<@array; $i++)
|
|
|
|
{
|
|
|
|
print "$array[$i]\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Sort a given hash by reverse numeric order of value
|
|
|
|
# return the sorted keylist
|
|
|
|
#
|
|
|
|
sub SortKeyByValue()
|
|
|
|
{
|
|
|
|
my(%hash) = @_;
|
|
|
|
my(@sorted_keys) = sort { $hash{$b} <=> $hash{$a} } keys %hash;
|
|
|
|
return @sorted_keys;
|
|
|
|
}
|