author | Dario Sestito <darios@symbian.org> |
Thu, 04 Mar 2010 17:14:46 +0000 | |
changeset 183 | 38468523076d |
parent 176 | 6d3c3db11e72 |
child 185 | b76adfbc6648 |
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 |
my $failure_item = 0; |
|
47 |
||
48 |
my $recipe_info = {}; |
|
49 |
||
50 |
my $characters = ''; |
|
51 |
||
52 |
my $CATEGORY_RECIPEFAILURE = 'recipe_failure'; |
|
53 |
my $CATEGORY_RECIPEFAILURE_ARMCC_CANNOTOPENSOURCEINPUTFILE = 'armcc_cannot_open_source_input_file'; |
|
54 |
my $CATEGORY_RECIPEFAILURE_ARMLINK_COULDNOTOPENFILE = 'armlink_could_not_open_file'; |
|
55 |
my $CATEGORY_RECIPEFAILURE_ELF2E32_COULDNOTOPENFILE = 'elf2e32_could_not_open_file'; |
|
56 |
my $CATEGORY_RECIPEFAILURE_ARMAR_FILEDOESNOTEXIST = 'armar_file_does_not_exist'; |
|
57 |
my $CATEGORY_RECIPEFAILURE_ARMCC_CONTROLLINGEXPRESSIONISCONSTANT = 'armcc_controlling_expression_is_constant'; |
|
58 |
my $CATEGORY_RECIPEFAILURE_ARMCC_INTERNALFAULT = 'armcc_internal_fault'; |
|
59 |
my $CATEGORY_RECIPEFAILURE_ARMCC_MODIFIERNOTALLOWED = 'armcc_modifier_not_allowed'; |
|
60 |
my $CATEGORY_RECIPEFAILURE_ARMCC_GENERICWARNINGSERRORS = 'armcc_generic_warnings_errors'; |
|
61 |
my $CATEGORY_RECIPEFAILURE_ELF2E32_SYMBOLMISSINGFROMELFFILE = 'elf2e32_symbol_missing_from_elf_file'; |
|
62 |
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
|
63 |
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
|
64 |
my $CATEGORY_RECIPEFAILURE_AS_ERROR = 'as_error'; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
65 |
my $CATEGORY_RECIPEFAILURE_GPP_ERROR = 'g++_error'; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
66 |
my $CATEGORY_RECIPEFAILURE_GPP_WARNING = 'g++_warning'; |
176 | 67 |
|
68 |
my $mmp_with_issues = {}; |
|
69 |
||
70 |
||
71 |
sub process |
|
72 |
{ |
|
73 |
my ($text, $config, $component, $mmp, $phase, $recipe, $file, $line) = @_; |
|
74 |
||
75 |
my $category = $CATEGORY_RECIPEFAILURE; |
|
76 |
my $severity = ''; |
|
77 |
my $subcategory = ''; |
|
78 |
||
79 |
# if mmp is defined assign severity=MAJOR for the first failure |
|
80 |
# then severity=MINOR to all other (for each logfile) |
|
81 |
if ($mmp and defined $mmp_with_issues->{$::current_log_file}->{$mmp}) |
|
82 |
{ |
|
83 |
$severity = $RaptorCommon::SEVERITY_MINOR; |
|
84 |
} |
|
85 |
elsif ($mmp) |
|
86 |
{ |
|
87 |
$mmp_with_issues->{$::current_log_file} = {} if (!defined $mmp_with_issues->{$::current_log_file}); |
|
88 |
$mmp_with_issues->{$::current_log_file}->{$mmp} = 1; |
|
89 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
|
90 |
} |
|
91 |
else |
|
92 |
{ |
|
93 |
$severity = $RaptorCommon::SEVERITY_MAJOR; |
|
94 |
} |
|
95 |
||
96 |
||
97 |
if ($text =~ m,Error: #5: cannot open source input file .*: No such file or directory,) |
|
98 |
{ |
|
99 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_CANNOTOPENSOURCEINPUTFILE; |
|
100 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
101 |
} |
|
102 |
elsif ($text =~ m,Fatal error: L6002U: Could not open file .*: No such file or directory,) |
|
103 |
{ |
|
104 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMLINK_COULDNOTOPENFILE; |
|
105 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
106 |
} |
|
107 |
elsif ($text =~ m,elf2e32 : Error: E1001: Could not open file : .*.,) |
|
108 |
{ |
|
109 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ELF2E32_COULDNOTOPENFILE; |
|
110 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
111 |
} |
|
112 |
elsif ($text =~ m,elf2e32 : Error: E1036: Symbol .* Missing from ELF File,) |
|
113 |
{ |
|
114 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ELF2E32_SYMBOLMISSINGFROMELFFILE; |
|
115 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
116 |
} |
|
117 |
elsif ($text =~ m,Error: L6833E: File '.*' does not exist,) |
|
118 |
{ |
|
119 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMAR_FILEDOESNOTEXIST; |
|
120 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
121 |
} |
|
122 |
elsif ($text =~ m,: Warning: #236-D: controlling expression is constant,) |
|
123 |
{ |
|
124 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_CONTROLLINGEXPRESSIONISCONSTANT; |
|
125 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
126 |
} |
|
127 |
elsif ($text =~ m,/armcc.exe , and $text =~ m,Internal fault: ,) |
|
128 |
{ |
|
129 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_INTERNALFAULT; |
|
130 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
131 |
} |
|
132 |
elsif ($text =~ m,/armcc.exe , and $text =~ m,Error: #655-D: the modifier ".*" is not allowed on this declaration,) |
|
133 |
{ |
|
134 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_MODIFIERNOTALLOWED; |
|
135 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
136 |
} |
|
183
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
137 |
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
|
138 |
{ |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
139 |
$severity = $RaptorCommon::SEVERITY_CRITICAL; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
140 |
my $subcategory = $CATEGORY_RECIPEFAILURE_BINSH_COMMANDNOTFOUND; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
141 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
142 |
} |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
143 |
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
|
144 |
{ |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
145 |
my $subcategory = $CATEGORY_RECIPEFAILURE_AS_ERROR; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
146 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
147 |
} |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
148 |
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
|
149 |
{ |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
150 |
my $subcategory = $CATEGORY_RECIPEFAILURE_GPP_ERROR; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
151 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
152 |
} |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
153 |
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
|
154 |
{ |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
155 |
my $subcategory = $CATEGORY_RECIPEFAILURE_GPP_WARNING; |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
156 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
38468523076d
Add more categories for recipe failures
Dario Sestito <darios@symbian.org>
parents:
176
diff
changeset
|
157 |
} |
176 | 158 |
# the following captures generic armcc error/warnings, not captured by regexps above |
159 |
elsif ($text =~ m,/armcc.exe , and $text =~ m,: \d+ warnings\, \d+ errors$,) |
|
160 |
{ |
|
161 |
my $subcategory = $CATEGORY_RECIPEFAILURE_ARMCC_GENERICWARNINGSERRORS; |
|
162 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
163 |
} |
|
164 |
elsif ($text =~ m,mwccsym2.exe , and $text =~ m,: the file '.*' cannot be opened,) |
|
165 |
{ |
|
166 |
my $subcategory = $CATEGORY_RECIPEFAILURE_MWCCSYM2_FILECANNOTBEOPENED; |
|
167 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
168 |
} |
|
169 |
else # log everything by default |
|
170 |
{ |
|
171 |
RaptorCommon::dump_fault($category, $subcategory, $severity, $config, $component, $mmp, $phase, $recipe, $file, $line); |
|
172 |
} |
|
173 |
} |
|
174 |
||
175 |
sub on_start_buildlog |
|
176 |
{ |
|
177 |
#print FILE "line,layer,component,name,armlicence,platform,phase,code,bldinf,mmp,target,source,\n"; |
|
178 |
||
179 |
RaptorCommon::init(); |
|
180 |
} |
|
181 |
||
182 |
sub on_start_buildlog_recipe |
|
183 |
{ |
|
184 |
my ($el) = @_; |
|
185 |
||
186 |
#print "on_start_buildlog_recipe\n"; |
|
187 |
||
188 |
$recipe_info = {}; |
|
189 |
||
190 |
my $attributes = $el->{Attributes}; |
|
191 |
for (keys %{$attributes}) |
|
192 |
{ |
|
193 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'}; |
|
194 |
#print "$_ -> $attributes->{$_}->{'Value'}\n"; |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
sub on_chars_buildlog_recipe |
|
199 |
{ |
|
200 |
my ($ch) = @_; |
|
201 |
||
202 |
#print "on_chars_buildlog_recipe\n"; |
|
203 |
||
204 |
$characters .= $ch->{Data}; |
|
205 |
||
206 |
#print "characters is now -->$characters<--\n"; |
|
207 |
} |
|
208 |
||
209 |
sub on_start_buildlog_recipe_status |
|
210 |
{ |
|
211 |
my ($el) = @_; |
|
212 |
||
213 |
my $attributes = $el->{Attributes}; |
|
214 |
for (keys %{$attributes}) |
|
215 |
{ |
|
216 |
if ($attributes->{$_}->{'LocalName'} eq 'code') |
|
217 |
{ |
|
218 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'}; |
|
219 |
} |
|
220 |
elsif ($attributes->{$_}->{'LocalName'} eq 'exit') |
|
221 |
{ |
|
222 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'}; |
|
223 |
} |
|
224 |
elsif ($attributes->{$_}->{'LocalName'} eq 'attempt') |
|
225 |
{ |
|
226 |
$recipe_info->{$attributes->{$_}->{'LocalName'}} = $attributes->{$_}->{'Value'}; |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
sub on_end_buildlog_recipe |
|
232 |
{ |
|
233 |
$::allbldinfs->{$recipe_info->{bldinf}} = 1; |
|
234 |
||
235 |
if ($recipe_info->{exit} =~ /failed/) |
|
236 |
{ |
|
237 |
# normalize bldinf path |
|
238 |
$recipe_info->{bldinf} = lc($recipe_info->{bldinf}); |
|
239 |
$recipe_info->{bldinf} =~ s,^[A-Za-z]:,,; |
|
240 |
$recipe_info->{bldinf} =~ s,[\\],/,g; |
|
241 |
||
242 |
my $package = ''; |
|
243 |
if ($recipe_info->{bldinf} =~ m,/((os|mw|app|tools|ostools|adaptation)/[^/]*),) |
|
244 |
{ |
|
245 |
$package = $1; |
|
246 |
$package =~ s,/,_,; |
|
247 |
} |
|
248 |
else |
|
249 |
{ |
|
250 |
print "WARNING: can't understand bldinf attribute of recipe: $recipe_info->{bldinf}. Won't dump to failed recipes file.\n"; |
|
251 |
} |
|
252 |
||
253 |
# also normalize mmp path if this exists |
|
254 |
if ($recipe_info->{mmp}) |
|
255 |
{ |
|
256 |
$recipe_info->{mmp} = lc($recipe_info->{mmp}); |
|
257 |
$recipe_info->{mmp} =~ s,^[A-Za-z]:,,; |
|
258 |
$recipe_info->{mmp} =~ s,[\\],/,g; |
|
259 |
} |
|
260 |
||
261 |
$characters =~ s,^[\r\n]*,,; |
|
262 |
$characters =~ s,[\r\n]*$,,; |
|
263 |
||
264 |
if ($package) |
|
265 |
{ |
|
266 |
$filename = "$::raptorbitsdir/$package.txt"; |
|
267 |
if (!-f$filename) |
|
268 |
{ |
|
269 |
print "Writing recipe file $filename\n"; |
|
270 |
open(FILE, ">$filename"); |
|
271 |
close(FILE); |
|
272 |
} |
|
273 |
||
274 |
if ($failure_item == 0 and -f "$filename") |
|
275 |
{ |
|
276 |
open(FILE, "$filename"); |
|
277 |
{ |
|
278 |
local $/ = undef; |
|
279 |
my $filecontent = <FILE>; |
|
280 |
$failure_item = $1 if ($filecontent =~ m/.*---failure_item_(\d+)/s); |
|
281 |
} |
|
282 |
close(FILE); |
|
283 |
} |
|
284 |
||
285 |
$failure_item++; |
|
286 |
||
287 |
open(FILE, ">>$filename"); |
|
288 |
print FILE "---failure_item_$failure_item\---\n"; |
|
289 |
print FILE "$characters\n\n"; |
|
290 |
close(FILE); |
|
291 |
} |
|
292 |
||
293 |
process($characters, $recipe_info->{config}, $recipe_info->{bldinf}, $recipe_info->{mmp}, $recipe_info->{phase}, $recipe_info->{name}, "$package.txt", $failure_item); |
|
294 |
} |
|
295 |
||
296 |
$characters = ''; |
|
297 |
} |
|
298 |
||
299 |
sub on_end_buildlog |
|
300 |
{ |
|
301 |
} |
|
302 |
||
303 |
||
304 |
1; |