common/tools/raptor/preprocess_log.pl
author Shabe Razvi <shaber@symbian.org>
Mon, 08 Mar 2010 12:37:47 +0000
changeset 915 9bfe1b1c0a41
parent 843 c32873117195
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
     1
#!perl -w
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     2
# Copyright (c) 2009 Symbian Foundation Ltd
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     3
# This component and the accompanying materials are made available
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     5
# which accompanies this distribution, and is available
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     7
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     8
# Initial Contributors:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
     9
# Symbian Foundation Ltd - initial contribution.
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    10
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    11
# Contributors:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    12
#
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    13
# Description:
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    14
# Preprocess a raptor log, trying to countermeasure a list of known anomalies
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    15
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    16
use strict;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    17
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    18
use Getopt::Long;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    19
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    20
my $help = 0;
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    21
GetOptions(
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    22
	'help!' => \$help,
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    23
);
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    24
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    25
if ($help)
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    26
{
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    27
	warn <<"EOF";
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    28
Preprocess a raptor log, trying to countermeasure a list of known anomalies
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    29
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    30
Usage: perl preprocess_log.pl < INFILE > OUTFILE
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    31
EOF
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    32
	exit(0);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    33
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    34
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    35
while (my $line = <>)
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    36
{
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    37
	if ($line =~ m{<[^<^>]+>.*&.*</[^<^>]+>})
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    38
	{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    39
		$line = escape_ampersand($line);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    40
	}
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    41
	elsif ($line =~ m{<\?xml\s.*encoding=.*\".*\?>})
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    42
	{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    43
		$line = set_encoding_utf8($line);
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    44
	}
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    45
	elsif ($line =~ m{<archive.*?[^/]>})
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    46
	{
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    47
		$line = unterminated_archive_tag($line, scalar <>, $.)
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    48
	}
843
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
    49
	elsif ($line =~ m{make.exe: Circular .* <- .* dependency dropped.})
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
    50
	{
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
    51
		$line = escape_left_angle_bracket($line);
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
    52
	}
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    53
	
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    54
	print $line;
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    55
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    56
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    57
sub escape_ampersand
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    58
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    59
	my ($line) = @_;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    60
	
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    61
	warn "escape_ampersand\n";
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    62
	warn "in: $line";
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    63
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    64
	$line =~ s,&,&amp;,g;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    65
	
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    66
	warn "out: $line";
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    67
	return $line;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    68
}
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    69
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    70
sub set_encoding_utf8
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    71
{
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    72
	my ($line) = @_;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    73
	
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    74
	warn "set_encoding_utf8\n";
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    75
	warn "in: $line";
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    76
	
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    77
	$line =~ s,encoding=".*",encoding="utf-8",;
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    78
	
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    79
	warn "out: $line";
222
1d9c60a4e308 Adding extraction of whatlog information into "deliverables" files
Dario Sestito <darios@symbian.org>
parents:
diff changeset
    80
	return $line;
243
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    81
}
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    82
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    83
sub unterminated_archive_tag
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    84
{
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    85
	my $line = shift;
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    86
	my $nextLine = shift;
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    87
	my $lineNum = shift;
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    88
	
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    89
	if ($nextLine !~ m{(<member>)|(</archive>)})
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    90
	{
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    91
		warn "unterminated_archive_tag\n";
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    92
		warn "in: $line";
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    93
		$line =~ s{>}{/>};
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    94
		warn "out: $line";
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    95
	}
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    96
	
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    97
	return $line . $nextLine;
71d24b4fa162 Updated preprocess_log to deal with mal-formed <archive> tags - workaround for Bug 170.
Simon Howkins <simonh@symbian.org>
parents: 222
diff changeset
    98
}
843
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
    99
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   100
sub escape_left_angle_bracket
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   101
{
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   102
	my ($line) = @_;
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   103
	
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   104
	warn "escape_left_angle_bracket\n";
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   105
	warn "in: $line";
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   106
	
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   107
	$line =~ s,<,&lt;,g;
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   108
	
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   109
	warn "out: $line";
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   110
	return $line;
c32873117195 Add escape left angle bracket to preprocessing of raptor log (see bug #1519)
Dario Sestito <darios@symbian.org>
parents: 243
diff changeset
   111
}