|
1 # Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 use strict; |
|
17 use Getopt::Long; |
|
18 my $trimmed = 1; |
|
19 my $inPlace = 0; |
|
20 my $zapHex = 0; |
|
21 my $zapTime = 0; |
|
22 my $forceCDU = 0; |
|
23 my $forceULOG = 0; |
|
24 GetOptions('trim|t!' => \$trimmed, 'inplace|i!' => \$inPlace, 'zaphex!' => \$zapHex, 'zaptime!' => \$zapTime, 'cdu!' => \$forceCDU, 'ulogger!' => \$forceULOG); |
|
25 |
|
26 my $log = "log.txt"; |
|
27 if(defined($ARGV[0])) |
|
28 { |
|
29 $log = $ARGV[0]; |
|
30 die "$log not found" if !-e $log; |
|
31 } |
|
32 elsif(!-e $log) |
|
33 { |
|
34 $log = "/epoc32/winscw/c/logs/log.txt"; |
|
35 } |
|
36 my %ids; |
|
37 my $uLogger = $forceULOG; |
|
38 if($inPlace) |
|
39 { |
|
40 @ARGV = $log; |
|
41 $^I = ".bak"; |
|
42 if(!$forceCDU && !$forceULOG && defined($_ = <>)) |
|
43 { |
|
44 $uLogger = $_ =~ /^Sequence,/; |
|
45 DoLine($_); |
|
46 } |
|
47 while(<>) |
|
48 { |
|
49 DoLine($_); |
|
50 } |
|
51 } |
|
52 else |
|
53 { |
|
54 open LOG, $log or die "Failed opening '$log'"; |
|
55 if(!$forceCDU && !$forceULOG && defined($_ = <LOG>)) |
|
56 { |
|
57 $uLogger = $_ =~ /^Sequence,/; |
|
58 DoLine($_); |
|
59 } |
|
60 while(<LOG>) |
|
61 { |
|
62 DoLine($_); |
|
63 } |
|
64 } |
|
65 |
|
66 my $CDULoggerTid; |
|
67 |
|
68 sub DoCDULine($$) |
|
69 { |
|
70 my ($pref, $line) = ($_[0], $_[1]); |
|
71 if($line !~ /^#/ && $line =~ /(^[^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)(\s+)(.*)/) |
|
72 { |
|
73 my @bits = ( $1, $2, $3, $4, $5, $6 ); |
|
74 my $tid = hex($bits[3]); |
|
75 if($bits[5] =~ /^W(\d+): /) |
|
76 { |
|
77 $ids{$tid} = $1; |
|
78 } |
|
79 elsif(defined $ids{$tid}) |
|
80 { |
|
81 $bits[5] = sprintf "W%d: %s", $ids{$tid}, $bits[5]; |
|
82 } |
|
83 $bits[5] =~ s/[0-9a-f]{8}/--------/gi if($zapHex); |
|
84 if($trimmed) |
|
85 { |
|
86 print "$pref$bits[0]\t$bits[1]$bits[4]$bits[5]\n"; |
|
87 } |
|
88 else |
|
89 { |
|
90 print "$pref$bits[0]\t$bits[1]\t$bits[2]\t$bits[3]$bits[4]$bits[5]\n"; |
|
91 } |
|
92 } |
|
93 else |
|
94 { |
|
95 print "$pref$line\n" unless $zapTime && $line =~ /^#Time/; |
|
96 } |
|
97 } |
|
98 |
|
99 sub DoULoggerLine($) |
|
100 { |
|
101 if($_[0] =~ /^(\d+),(\d+),(\d+),(\d+),(\d+),(0x[0-9a-fA-F]+),(.+)/) |
|
102 { |
|
103 my ($seq, $pri, $sub, $time1, $time2, $context, $desc) = ($1, $2, $3, $4, $5, $6, $7); |
|
104 $time1 = $time2 = "" if $zapTime; |
|
105 $seq = '---' if($zapHex); |
|
106 if($desc =~ /^W(\d+):\s+SocketServer::InitL\(\) Done!/) |
|
107 { |
|
108 print stderr "WARNING: $context was defined as $ids{$context}\n" if(defined($ids{$context}) && $ids{$context} ne $1); |
|
109 $ids{$context} = $1; |
|
110 } |
|
111 elsif($desc =~ /^EThreadIdentification: Thread Create: \[NThread=(0x[0-9a-fA-F]+)\] \[DProcess=0x[0-9a-fA-F]+\] \[Name=Comsdbg2\]/) |
|
112 { |
|
113 $CDULoggerTid = $1; |
|
114 } |
|
115 elsif($desc =~ /^(ENodeMessages: )(.*)/ || $desc =~ /^(ERDebugPrintf: )(.*)/ || $desc !~ /W\d+:/) |
|
116 { |
|
117 if($1 eq 'ERDebugPrintf: ' && $context eq $CDULoggerTid) |
|
118 { |
|
119 $context = '0x--------' if($zapHex); |
|
120 my $pref = "$seq,$pri,$sub,$time1,$time2,$context,"; |
|
121 DoCDULine($pref, $2); |
|
122 return; |
|
123 } |
|
124 elsif($1 eq 'ENodeMessages: ' && $2 !~ /W\d+:/) |
|
125 { |
|
126 $context = '0x--------' if($zapHex); |
|
127 my $pref = "$seq,$pri,$sub,$time1,$time2,$context,"; |
|
128 DoCDULine($pref, $2); |
|
129 return; |
|
130 } |
|
131 my $tid = $ids{$context}; |
|
132 $desc = "W$tid: $desc" if defined $tid; |
|
133 } |
|
134 $context =~ s/[0-9a-f]{8}/--------/gi if($zapHex); |
|
135 $desc =~ s/[0-9a-f]{8}/--------/gi if($zapHex); |
|
136 print "$seq,$pri,$sub,$time1,$time2,$context,$desc\n"; |
|
137 } |
|
138 elsif($_[0] ne '') |
|
139 { |
|
140 print "$_[0]\n"; |
|
141 } |
|
142 } |
|
143 |
|
144 sub DoLine($) |
|
145 { |
|
146 chomp $_[0]; |
|
147 if(!$uLogger) |
|
148 { |
|
149 DoCDULine('', $_[0]); |
|
150 } |
|
151 else |
|
152 { |
|
153 DoULoggerLine($_[0]); |
|
154 } |
|
155 } |
|
156 |