author | Dario Sestito <darios@symbian.org> |
Mon, 08 Mar 2010 18:21:32 +0000 | |
changeset 185 | b76adfbc6648 |
parent 183 | 38468523076d |
child 190 | 890789575604 |
permissions | -rw-r--r-- |
176 | 1 |
# Copyright (c) 2009 Symbian Foundation Ltd |
2 |
# This component and the accompanying materials are made available |
|
3 |
# under the terms of the License "Eclipse Public License v1.0" |
|
4 |
# which accompanies this distribution, and is available |
|
5 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
6 |
# |
|
7 |
# Initial Contributors: |
|
8 |
# Symbian Foundation Ltd - initial contribution. |
|
9 |
# |
|
10 |
# Contributors: |
|
11 |
# |
|
12 |
# Description: |
|
13 |
# Raptor parser module. |
|
14 |
# Extract, analyzes and dumps raptor recipes i.e. content of <recipe> tags from a raptor log file |
|
15 |
||
16 |
package RaptorRecipe; |
|
17 |
||
18 |
use strict; |
|
19 |
use RaptorCommon; |
|
20 |
||
21 |
our $reset_status = {}; |
|
22 |
my $buildlog_status = {}; |
|
23 |
my $buildlog_recipe_status = {}; |
|
24 |
my $buildlog_recipe_status_status = {}; |
|
25 |
||
26 |
$reset_status->{name} = 'reset_status'; |
|
27 |
$reset_status->{next_status} = {buildlog=>$buildlog_status}; |
|
28 |
||
29 |
$buildlog_status->{name} = 'buildlog_status'; |
|
30 |
$buildlog_status->{next_status} = {recipe=>$buildlog_recipe_status}; |
|
31 |
$buildlog_status->{on_start} = 'RaptorRecipe::on_start_buildlog'; |
|
32 |
$buildlog_status->{on_end} = 'RaptorRecipe::on_end_buildlog'; |
|
33 |
||
34 |
$buildlog_recipe_status->{name} = 'buildlog_recipe_status'; |
|
35 |
$buildlog_recipe_status->{next_status} = {status=>$buildlog_recipe_status_status}; |
|
36 |
$buildlog_recipe_status->{on_start} = 'RaptorRecipe::on_start_buildlog_recipe'; |
|
37 |
$buildlog_recipe_status->{on_end} = 'RaptorRecipe::on_end_buildlog_recipe'; |
|
38 |
$buildlog_recipe_status->{on_chars} = 'RaptorRecipe::on_chars_buildlog_recipe'; |
|
39 |
||
40 |
$buildlog_recipe_status_status->{name} = 'buildlog_recipe_status_status'; |
|
41 |
$buildlog_recipe_status_status->{next_status} = {}; |
|
42 |
$buildlog_recipe_status_status->{on_start} = 'RaptorRecipe::on_start_buildlog_recipe_status'; |
|
43 |
||
44 |
||
45 |
my $filename = ''; |
|
46 |
||
47 |
my $recipe_info = {}; |
|
48 |
||
49 |
my $characters = ''; |
|
50 |
||
51 |
my $CATEGORY_RECIPEFAILURE = 'recipe_failure'; |
|
52 |
my $CATEGORY_RECIPEFAILURE_ARMCC_CANNOTOPENSOURCEINPUTFILE = 'armcc_cannot_open_source_input_file'; |
|
53 |
my $CATEGORY_RECIPEFAILURE_ARMLINK_COULDNOTOPENFILE = 'armlink_could_not_open_file'; |
|
54 |
my $CATEGORY_RECIPEFAILURE_ELF2E32_COULDNOTOPENFILE = 'elf2e32_could_not_open_file'; |
|
55 |
my $CATEGORY_RECIPEFAILURE_ARMAR_FILEDOESNOTEXIST = 'armar_file_does_not_exist'; |
|
56 |
my $CATEGORY_RECIPEFAILURE_ARMCC_CONTROLLINGEXPRESSIONISCONSTANT = 'armcc_controlling_expression_is_constant'; |
|
57 |
my $CATEGORY_RECIPEFAILURE_ARMCC_INTERNALFAULT = 'armcc_internal_fault'; |
|
58 |
my $CATEGORY_RECIPEFAILURE_ARMCC_MODIFIERNOTALLOWED = 'armcc_modifier_not_allowed'; |
|
59 |
my $CATEGORY_RECIPEFAILURE_ARMCC_GENERICWARNINGSERRORS = 'armcc_generic_warnings_errors'; |
|
60 |
my $CATEGORY_RECIPEFAILURE_ELF2E32_SYMBOLMISSINGFROMELFFILE = 'elf2e32_symbol_missing_from_elf_file'; |
|
61 |
my $CATEGORY_RECIPEFAILURE_MWCCSYM2_FILECANNOTBEOPENED = 'mwccsym2_file_cannot_be_opened'; |
|
183
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
62 |
my $CATEGORY_RECIPEFAILURE_BINSH_COMMANDNOTFOUND = 'binsh_command_not_found'; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
63 |
my $CATEGORY_RECIPEFAILURE_AS_ERROR = 'as_error'; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
64 |
my $CATEGORY_RECIPEFAILURE_GPP_ERROR = 'g++_error'; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
65 |
my $CATEGORY_RECIPEFAILURE_GPP_WARNING = 'g++_warning'; |
176 | 66 |
|
67 |
my $mmp_with_issues = {}; |
|
68 |
||
69 |
||
70 |
sub process |
|
71 |
{ |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
72 |
my ($text, $config, $component, $mmp, $phase, $recipe, $file) = @_; |
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
73 |
|
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
74 |
my $dumped = 1; |
176 | 75 |
|
76 |
my $category = $CATEGORY_RECIPEFAILURE; |
|
77 |
my $severity = ''; |
|
78 |
my $subcategory = ''; |
|
79 |
||
80 |
# if mmp is defined assign severity=MAJOR for the first failure |
|
81 |
# then severity=MINOR to all other (for each logfile) |
|
82 |
if ($mmp and defined $mmp_with_issues->{$::current_log_file}->{$mmp}) |
|
83 |
{ |
|
84 |
$severity = $RaptorCommon::SEVERITY_MINOR; |
|
85 |
} |
|
86 |
elsif ($mmp) |
|
87 |
{ |
|
88 |
$mmp_with_issues->{$::current_log_file} = {} if (!defined $mmp_with_issues->{$::current_log_file}); |
|
89 |
$mmp_with_issues->{$::current_log_file}->{$mmp} = 1; |
|
90 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
|
91 |
} |
|
92 |
else |
|
93 |
{ |
|
94 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
|
95 |
} |
|
96 |
||
97 |
||
98 |
if ($text =~ m,Error: #5: cannot open source input file .*: No such file or directory,) |
|
99 |
{ |
|
100 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_CANNOTOPENSOURCEINPUTFILE; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
101 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 102 |
} |
103 |
elsif ($text =~ m,Fatal error: L6002U: Could not open file .*: No such file or directory,) |
|
104 |
{ |
|
105 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMLINK_COULDNOTOPENFILE; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
106 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 107 |
} |
108 |
elsif ($text =~ m,elf2e32 : Error: E1001: Could not open file : .*.,) |
|
109 |
{ |
|
110 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ELF2E32_COULDNOTOPENFILE; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
111 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 112 |
} |
113 |
elsif ($text =~ m,elf2e32 : Error: E1036: Symbol .* Missing from ELF File,) |
|
114 |
{ |
|
115 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ELF2E32_SYMBOLMISSINGFROMELFFILE; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
116 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 117 |
} |
118 |
elsif ($text =~ m,Error: L6833E: File '.*' does not exist,) |
|
119 |
{ |
|
120 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMAR_FILEDOESNOTEXIST; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
121 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 122 |
} |
123 |
elsif ($text =~ m,: Warning: #236-D: controlling expression is constant,) |
|
124 |
{ |
|
125 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_CONTROLLINGEXPRESSIONISCONSTANT; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
126 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 127 |
} |
128 |
elsif ($text =~ m,/armcc.exe , and $text =~ m,Internal fault: ,) |
|
129 |
{ |
|
130 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_INTERNALFAULT; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
131 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 132 |
} |
133 |
elsif ($text =~ m,/armcc.exe , and $text =~ m,Error: #655-D: the modifier ".*" is not allowed on this declaration,) |
|
134 |
{ |
|
135 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_MODIFIERNOTALLOWED; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
136 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 137 |
} |
183
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
138 |
elsif ($text =~ m,^\+.*/make.exe .*\n/bin/sh: .*: command not found,m) |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
139 |
{ |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
140 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
141 |
my $subcategory = $CATEGORY_RECIPEFAILURE_BINSH_COMMANDNOTFOUND; |
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
142 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
183
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
143 |
} |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
144 |
elsif ($text =~ m,^\+.*/arm-none-symbianelf-as\.exe .*^Error: .*,ms) |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
145 |
{ |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
146 |
my $subcategory = $CATEGORY_RECIPEFAILURE_AS_ERROR; |
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
147 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
183
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
148 |
} |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
149 |
elsif ($text =~ m,^\+.*/arm-none-symbianelf-g\+\+\.exe .*:\d+: [Ee]rror: .*,ms) |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
150 |
{ |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
151 |
my $subcategory = $CATEGORY_RECIPEFAILURE_GPP_ERROR; |
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
152 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
183
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
153 |
} |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
154 |
elsif ($text =~ m,^\+.*/arm-none-symbianelf-g\+\+\.exe .*:\d+: [Ww]arning: .*,ms) |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
155 |
{ |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
156 |
my $subcategory = $CATEGORY_RECIPEFAILURE_GPP_WARNING; |
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
157 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
183
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
158 |
} |
176 | 159 |
# the following captures generic armcc error/warnings, not captured by regexps above |
160 |
elsif ($text =~ m,/armcc.exe , and $text =~ m,: \d+ warnings\, \d+ errors$,) |
|
161 |
{ |
|
162 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_GENERICWARNINGSERRORS; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
163 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 164 |
} |
165 |
elsif ($text =~ m,mwccsym2.exe , and $text =~ m,: the file '.*' cannot be opened,) |
|
166 |
{ |
|
167 |
my $subcategory = $CATEGORY_RECIPEFAILURE_MWCCSYM2_FILECANNOTBEOPENED; |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
168 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 169 |
} |
170 |
else # log everything by default |
|
171 |
{ |
|
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
172 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file); |
176 | 173 |
} |
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
174 |
|
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
175 |
return $dumped; |
176 | 176 |
} |
177 |
||
178 |
sub on_start_buildlog |
|
179 |
{ |
|
180 |
#print FILE "line,layer,component,name,armlicence,platform,phase,code,bldinf,mmp,target,source,\n"; |
|
181 |
||
182 |
RaptorCommon::init(); |
|
183 |
} |
|
184 |
||
185 |
sub on_start_buildlog_recipe |
|
186 |
{ |
|
187 |
my ($el) = @_; |
|
188 |
||
189 |
#print "on_start_buildlog_recipe\n"; |
|
190 |
||
191 |
$recipe_info = {}; |
|
192 |
||
193 |
my $attributes = $el->{Attributes}; |
|
194 |
for (keys %{$attributes}) |
|
195 |
{ |
|
196 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'}; |
|
197 |
#print "$_ -> $attributes->{$_}->{'Value'}\n"; |
|
198 |
} |
|
199 |
} |
|
200 |
||
201 |
sub on_chars_buildlog_recipe |
|
202 |
{ |
|
203 |
my ($ch) = @_; |
|
204 |
||
205 |
#print "on_chars_buildlog_recipe\n"; |
|
206 |
||
207 |
$characters .= $ch->{Data}; |
|
208 |
||
209 |
#print "characters is now -->$characters<--\n"; |
|
210 |
} |
|
211 |
||
212 |
sub on_start_buildlog_recipe_status |
|
213 |
{ |
|
214 |
my ($el) = @_; |
|
215 |
||
216 |
my $attributes = $el->{Attributes}; |
|
217 |
for (keys %{$attributes}) |
|
218 |
{ |
|
219 |
if ($attributes->{$_}->{'LocalName'} eq 'code') |
|
220 |
{ |
|
221 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'}; |
|
222 |
} |
|
223 |
elsif ($attributes->{$_}->{'LocalName'} eq 'exit') |
|
224 |
{ |
|
225 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'}; |
|
226 |
} |
|
227 |
elsif ($attributes->{$_}->{'LocalName'} eq 'attempt') |
|
228 |
{ |
|
229 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'}; |
|
230 |
} |
|
231 |
} |
|
232 |
} |
|
233 |
||
234 |
sub on_end_buildlog_recipe |
|
235 |
{ |
|
236 |
$::allbldinfs->{$recipe_info->{bldinf}} = 1; |
|
237 |
||
238 |
if ($recipe_info->{exit} =~ /failed/) |
|
239 |
{ |
|
240 |
# normalize bldinf path |
|
241 |
$recipe_info->{bldinf} = lc($recipe_info->{bldinf}); |
|
242 |
$recipe_info->{bldinf} =~ s,^[A-Za-z]:,,; |
|
243 |
$recipe_info->{bldinf} =~ s,[\\],/,g; |
|
244 |
||
245 |
my $package = ''; |
|
246 |
if ($recipe_info->{bldinf} =~ m,/((os|mw|app|tools|ostools|adaptation)/[^/]*),) |
|
247 |
{ |
|
248 |
$package = $1; |
|
249 |
$package =~ s,/,_,; |
|
250 |
} |
|
251 |
else |
|
252 |
{ |
|
253 |
print "WARNING: can't understand bldinf attribute of recipe: $recipe_info->{bldinf}. Won't dump to failed recipes file.\n"; |
|
254 |
} |
|
255 |
||
256 |
# also normalize mmp path if this exists |
|
257 |
if ($recipe_info->{mmp}) |
|
258 |
{ |
|
259 |
$recipe_info->{mmp} = lc($recipe_info->{mmp}); |
|
260 |
$recipe_info->{mmp} =~ s,^[A-Za-z]:,,; |
|
261 |
$recipe_info->{mmp} =~ s,[\\],/,g; |
|
262 |
} |
|
263 |
||
264 |
$characters =~ s,^[\r\n]*,,; |
|
265 |
$characters =~ s,[\r\n]*$,,; |
|
266 |
||
267 |
if ($package) |
|
268 |
{ |
|
269 |
$filename = "$::raptorbitsdir/$package.txt"; |
|
270 |
if (!-f$filename) |
|
271 |
{ |
|
272 |
print "Writing recipe file $filename\n"; |
|
273 |
open(FILE, ">$filename"); |
|
274 |
close(FILE); |
|
275 |
} |
|
276 |
||
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
277 |
my $dumped = process($characters, $recipe_info->{config}, $recipe_info->{bldinf}, $recipe_info->{mmp}, $recipe_info->{phase}, $recipe_info->{name}, "$package.txt"); |
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
278 |
|
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
279 |
if ($dumped) |
176 | 280 |
{ |
185
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
281 |
open(FILE, ">>$filename"); |
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
282 |
print FILE "---failure_item_$::failure_item_number\---\n"; |
b76adfbc6648
Don't dump failures which aren't reported
Dario Sestito <darios@symbian.org>
parents:
183
diff
changeset
|
283 |
print FILE "$characters\n\n"; |
176 | 284 |
close(FILE); |
285 |
} |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
$characters = ''; |
|
290 |
} |
|
291 |
||
292 |
sub on_end_buildlog |
|
293 |
{ |
|
294 |
} |
|
295 |
||
296 |
||
297 |
1; |