41 using SymbianDebugLib.Engine; |
41 using SymbianDebugLib.Engine; |
42 using SymbianDebugLib.Entity; |
42 using SymbianDebugLib.Entity; |
43 using SymbianUtils; |
43 using SymbianUtils; |
44 using SymbianUtils.Tracer; |
44 using SymbianUtils.Tracer; |
45 using CrashItemLib.Crash.InfoSW; |
45 using CrashItemLib.Crash.InfoSW; |
|
46 using MobileCrashLib; |
|
47 using MobileCrashLib.Parser; |
|
48 using MobileCrashLib.Structures.Items; |
|
49 using MobileCrashLib.Structures; |
46 |
50 |
47 namespace CrashAnalyserServerExe.Engine |
51 namespace CrashAnalyserServerExe.Engine |
48 { |
52 { |
49 internal class CACmdLineEngine : DisposableObject, ITracer, ICIEngineUI |
53 internal class CACmdLineEngine : DisposableObject, ITracer, ICIEngineUI |
50 { |
54 { |
90 // create all the needed Crash Item Source objects for each input file. |
94 // create all the needed Crash Item Source objects for each input file. |
91 // Any inputs which we don't support will not have an associated source and |
95 // Any inputs which we don't support will not have an associated source and |
92 // will be flagged accordingly within the CACmdLineFileSource object. |
96 // will be flagged accordingly within the CACmdLineFileSource object. |
93 TryToPrimeSources(); |
97 TryToPrimeSources(); |
94 |
98 |
|
99 // Try to the ROM ID and file type (i.e. crash, |
|
100 // registration msg, report) out of the crash files. This information is |
|
101 // used in later phases (e.g. if there are only registration messages in |
|
102 // source files then we do not have to load symbol files). |
|
103 TryToGetCrashInformation(); |
|
104 |
95 // Next, prime the debug engine will all the debug meta-data inputs. |
105 // Next, prime the debug engine will all the debug meta-data inputs. |
96 // Again, individual error messages will be associated with each meta-data |
106 // Again, individual error messages will be associated with each meta-data |
97 // input. |
107 // input. |
98 TryToPrimeDbgEngine(); |
108 |
|
109 // if (SymbolFilesNeeded()) |
|
110 { |
|
111 TryToPrimeDbgEngine(); |
|
112 } |
99 |
113 |
100 // Next, we invoke the crash engine to process all the crash item sources we |
114 // Next, we invoke the crash engine to process all the crash item sources we |
101 // created during the prime step. Exceptions are caught and associated |
115 // created during the prime step. Exceptions are caught and associated |
102 // messages & diagnostics are created at the input-file level. |
116 // messages & diagnostics are created at the input-file level. |
103 TryToIdentifyCrashes(); |
117 TryToIdentifyCrashes(); |
206 } |
221 } |
207 #endregion |
222 #endregion |
208 |
223 |
209 #region Internal constants |
224 #region Internal constants |
210 private const string KCrashItemSinkName = "CRASH INFO FILE"; |
225 private const string KCrashItemSinkName = "CRASH INFO FILE"; |
|
226 private const string KXmlCrashItemSinkName = "XML CRASH FILE"; |
211 private const string KParamProgress = "-PROGRESS"; |
227 private const string KParamProgress = "-PROGRESS"; |
212 #endregion |
228 #endregion |
213 |
229 |
214 #region Internal methods |
230 #region Internal methods |
215 private bool CheckForProgressParameter() |
231 private bool CheckForProgressParameter() |
216 { |
232 { |
217 bool report = this.CommandLineArguments.Contains( KParamProgress ); |
233 bool report = this.CommandLineArguments.Contains( KParamProgress ); |
218 return report; |
234 return report; |
219 } |
235 } |
220 |
236 |
221 private CISink FindSink() |
237 private CISink FindSink(bool aUseXmlSink) |
222 { |
238 { |
223 Trace( "[CA Cmd] FindSink() - START" ); |
239 Trace( "[CA Cmd] FindSink() - START" ); |
224 CISink ret = null; |
240 CISink ret = null; |
225 // |
241 // |
|
242 string sinkToUse = KCrashItemSinkName; |
|
243 if (aUseXmlSink) |
|
244 { |
|
245 sinkToUse = KXmlCrashItemSinkName; |
|
246 } |
|
247 |
226 CISinkManager sinkManager = iCrashItemEngine.SinkManager; |
248 CISinkManager sinkManager = iCrashItemEngine.SinkManager; |
227 foreach ( CISink sink in sinkManager ) |
249 foreach ( CISink sink in sinkManager ) |
228 { |
250 { |
229 Trace( "[CA Cmd] FindSink() - found sink: " + sink.Name ); |
251 Trace( "[CA Cmd] FindSink() - found sink: " + sink.Name ); |
230 |
252 |
231 if ( sink.Name.ToUpper().Contains( KCrashItemSinkName ) ) |
253 if ( sink.Name.ToUpper().Contains( sinkToUse ) ) |
232 { |
254 { |
233 ret = sink; |
255 ret = sink; |
234 break; |
256 break; |
235 } |
257 } |
236 } |
258 } |
290 |
312 |
291 AssociateInputFilesWithCrashItemSources(); |
313 AssociateInputFilesWithCrashItemSources(); |
292 Trace( "[CA Cmd] TryToPrimeSources() - END" ); |
314 Trace( "[CA Cmd] TryToPrimeSources() - END" ); |
293 } |
315 } |
294 |
316 |
|
317 /** |
|
318 * Get important data (i.e. RomId and content type) |
|
319 */ |
|
320 private void TryToGetCrashInformation() |
|
321 { |
|
322 Trace("[CA Cmd] TryToGetCrashInformation() - START"); |
|
323 |
|
324 foreach (CACmdLineFileSource file in iInputs.SourceFiles) |
|
325 { |
|
326 if (file.Source != null) |
|
327 { |
|
328 byte[] bytes = File.ReadAllBytes(file.File.FullName); |
|
329 MobileCrashBin bin = new MobileCrashBin(bytes); |
|
330 MobileCrashData data = new MobileCrashData(); |
|
331 MobileCrashParser parser = new MobileCrashParser(bin, data); |
|
332 parser.Parse(TSynchronicity.ESynchronous); |
|
333 data = parser.MobileCrashData; |
|
334 file.RomId = data.ItemById<MobileCrashItemUint32>(TMobileCrashId.EMobileCrashId_ROMID); |
|
335 file.ContentType = data.ContentType; |
|
336 } |
|
337 } |
|
338 |
|
339 Trace("[CA Cmd] TryToGetCrashInformation() - END"); |
|
340 |
|
341 } |
|
342 |
295 private void TryToPrimeDbgEngine() |
343 private void TryToPrimeDbgEngine() |
296 { |
344 { |
297 DbgEngine debugEngine = iDebugEngine; |
345 DbgEngine debugEngine = iDebugEngine; |
298 // |
346 // |
299 Exception primerException = null; |
347 Exception primerException = null; |
300 CACmdLineFSEntityList<CACmdLineFSEntity> metaDataFiles = iInputs.MetaDataFiles; |
348 CACmdLineFSEntityList<CACmdLineFSEntity> metaDataFiles = iInputs.MetaDataFiles; |
301 // |
349 // |
302 try |
350 try |
303 { |
351 { |
304 debugEngine.Clear(); |
352 debugEngine.Clear(); |
|
353 |
|
354 foreach (CACmdLineFileSource file in iInputs.SourceFiles) |
|
355 { |
|
356 if (file.RomId != null) |
|
357 debugEngine.AddActiveRomId(file.RomId.Value); |
|
358 } |
305 |
359 |
306 foreach ( CACmdLineFSEntity entry in metaDataFiles ) |
360 foreach ( CACmdLineFSEntity entry in metaDataFiles ) |
307 { |
361 { |
308 Trace( "[CA Cmd] Seeding debug meta engine with entry: " + entry.Name ); |
362 Trace( "[CA Cmd] Seeding debug meta engine with entry: " + entry.Name ); |
309 DbgEntity entity = debugEngine.Add( entry.Name ); |
363 DbgEntity entity = debugEngine.Add( entry.Name ); |
446 |
500 |
447 private void TryToCreateOutput() |
501 private void TryToCreateOutput() |
448 { |
502 { |
449 CACmdLineFSEntityList<CACmdLineFileSource> inputFiles = iInputs.SourceFiles; |
503 CACmdLineFSEntityList<CACmdLineFileSource> inputFiles = iInputs.SourceFiles; |
450 // |
504 // |
451 CISink sink = FindSink(); |
505 CISink sink = FindSink(iInputs.UseXmlSink); |
452 if ( sink == null ) |
506 if ( sink == null ) |
453 { |
507 { |
454 throw new CACmdLineException( "CI Output Plugin Not Available", CACmdLineException.KErrSinkNotAvailable ); |
508 throw new CACmdLineException( "CI Output Plugin Not Available", CACmdLineException.KErrSinkNotAvailable ); |
455 } |
509 } |
456 |
510 |
744 |
798 |
745 foreach (CIMessage message in aContainer.Messages) |
799 foreach (CIMessage message in aContainer.Messages) |
746 { |
800 { |
747 if (message.Title == "MobileCrash content type") |
801 if (message.Title == "MobileCrash content type") |
748 { |
802 { |
|
803 /* We could also decode registrations without but that will cause server to have |
|
804 * lots of registration only sw versions |
749 if (message.Description.Trim() == "registration") |
805 if (message.Description.Trim() == "registration") |
750 { |
806 { |
751 retval = true; |
807 retval = true; |
752 } |
808 } |
753 else if (message.Description.Trim() == "alive") |
809 else if (message.Description.Trim() == "alive") |
754 { |
810 { |
755 retval = true; |
811 retval = true; |
756 } |
812 } |
757 else if (message.Description.Trim() == "report") |
813 else */ |
|
814 |
|
815 if (message.Description.Trim() == "report") |
758 { |
816 { |
759 retval = true; |
817 retval = true; |
760 } |
818 } |
761 } |
819 } |
762 } |
820 } |