Exemple #1
0
        private void AssociateInputFilesWithCrashItemSources()
        {
            CACmdLineFSEntityList <CACmdLineFileSource> sourceFileNames = iInputs.SourceFiles;
            CIEngineSourceCollection sources = iEngine.CrashItemEngine.Sources;
            int count = sources.Count;

            // Emit progress banner
            iProgressReporter.StepBegin("Categorizing files...", KStepKeyCategorizingInputFiles, count);

            // Check each source in the engine and try to map it back onto an input source
            // file name. The goal is to identify input files which have no corresponding crash engine
            // source. These files are unsupported.
            for (int i = 0; i < count; i++)
            {
                CIEngineSource source         = sources[i];
                string         sourceFileName = source.FileName;

                // Try to match an input file with a given source object
                CACmdLineFileSource inputFile = sourceFileNames[sourceFileName];
                if (inputFile != null)
                {
                    inputFile.Source = source;
                }

                // Report progress as we work through the sources
                iProgressReporter.StepProgress(string.Empty, i, KStepKeyCategorizingInputFiles);
            }

            iProgressReporter.StepEnd(string.Empty, KStepKeyCategorizingInputFiles);
        }
 private void ExtractFileList <T>(CACmdLineFSEntityList <T> aList, SXILElementCategory aCategory) where T : CACmdLineFSEntity, new()
 {
     foreach (SXILElement element in aCategory)
     {
         if (element is SXILElementFile)
         {
             SXILElementFile file = (SXILElementFile)element;
             Trace("[CmdInput] ExtractFileList() - file: " + file);
             if (!file.Exists)
             {
                 throw new FileNotFoundException("File not found", file.Name);
             }
             //
             aList.Add(file);
         }
         else if (element is SXILElementDirectory)
         {
             SXILElementDirectory dir = (SXILElementDirectory)element;
             Trace("[CmdInput] ExtractFileList() - dir:  " + dir);
             if (!dir.Exists)
             {
                 throw new DirectoryNotFoundException("Directory not found: " + dir.Name);
             }
             //
             aList.AddRange(dir.Files);
         }
     }
 }
Exemple #3
0
        private void AddMetaDataMessagesToContainer(CIContainer aContainer)
        {
            // All meta-data errors, warnings & messages are added as
            // children of the container.
            CACmdLineFSEntityList <CACmdLineFSEntity> metaDataFiles = iInputs.MetaDataFiles;

            foreach (CACmdLineFSEntity file in metaDataFiles)
            {
                file.CopyMessagesToContainer(aContainer);
            }
        }
Exemple #4
0
        private void TryToPrimeSources()
        {
            UITrace("[CA Cmd] TryToPrimeSources() - START");
            CrashItemEngine.ClearAll();

            // Prime engine with source files
            CACmdLineFSEntityList <CACmdLineFileSource> sourceFileNames = iInputs.SourceFiles;
            int count = sourceFileNames.Count;

            // Emit progress banner
            iProgressReporter.StepBegin("Locating crash files...", KStepKeyPrimingSources, count);
            skippedFiles.Clear();
            for (int i = 0; i < count; i++)
            {
                CACmdLineFileSource file = sourceFileNames[i];
                //
                try
                {
                    // We prime each file individually. If an exception is thrown then we
                    // record an appropriate error in the associated file object.
                    UITrace("[CA Cmd] TryToPrimeSources() - priming: " + file);

                    bool primeSuccess = CrashItemEngine.Prime(file);
                    if (primeSuccess == false)
                    {
                        skippedFiles.Add(file.Name);
                    }


                    UITrace("[CA Cmd] TryToPrimeSources() - primed result: " + primeSuccess);
                }
                catch (Exception sourcePrimerException)
                {
                    file.AddError("Error Identifying Source Type", "There was an error when attempting to identify the source file type. The file could not be processed.");
                    file.AddDiagnostic("Crash Primer Exception Message", sourcePrimerException.Message);
                    file.AddDiagnostic("Crash Primer Exception Stack", sourcePrimerException.StackTrace);
                }

                // Report progress as we work through the sources
                iProgressReporter.StepProgress(string.Empty, i, KStepKeyPrimingSources);
            }

            iProgressReporter.StepEnd(string.Empty, KStepKeyPrimingSources);

            UITrace("[CA Cmd] TryToPrimeSources() - END");
        }
Exemple #5
0
 public CACmdLineManifestWriter(CACmdLineFSEntityList <CACmdLineFileSource> aSourceFiles)
 {
     iSourceFiles = aSourceFiles;
 }
Exemple #6
0
        private void TryToCreateXmlOutput()
        {
            CACmdLineFSEntityList <CACmdLineFileSource> inputFiles = iInputs.SourceFiles;
            //
            CISink xmlSink = FindXmlSink();

            if (xmlSink == null)
            {
                throw new CACmdLineException("XML Output Plugin Not Available", CAPlugin.KErrCommandLinePluginSinkNotAvailable);
            }

            CACmdLineFSEntityList <CACmdLineFileSource> sourceFileNames = iInputs.SourceFiles;
            int count = sourceFileNames.Count;

            // Emit progress banner
            iProgressReporter.StepBegin("Creating crash XML content...", KStepKeyWritingOutputXml, count);

            for (int i = 0; i < count; i++)
            {
                CACmdLineFileSource file = sourceFileNames[i];

                // If the file has a corresponding source then we know that crash item recognised it.
                if (file.Source == null)
                {
                    // File is not supported by crash item engine. Create dummy container which we'll
                    // serialize below.
                    CACmdLineSource cmdLineSource   = new CACmdLineSource(file.File);
                    CIContainer     failedContainer = CIContainer.NewErrorContainer(CrashItemEngine, cmdLineSource);
                    file.Add(failedContainer);
                }

                // We copy and remove all the file-level messages. These will be added to the container
                // (where appropriate) or then to an output entry otherwise.
                CACmdLineMessage[] fileMessages = file.ToArray();
                file.Clear();

                // At this point, the input file is guaranteed to have associated containers. Either
                // valid ones (created by crash item engine) or a single 'FAILED' one which we just
                // added above.
                foreach (CIContainer container in file.Containers)
                {
                    // Firstly, add any meta-data errors/messages/warnings to this container
                    // as crash item message entries
                    AddMetaDataMessagesToContainer(container);

                    // Now we can try to serialize the container to XML. This method will
                    // not throw an exception.
                    //
                    // If the operation succeeds, then the input file will have an associated
                    // container object (and associated xml output file name) and we need not
                    // do anymore.
                    //
                    // If it fails, then the input file will not be assigned the container
                    // object and therefore, later on, we'll invoke the XML Sink directly to
                    // create a stub 'FAILED' XML output file.
                    TryToCreateXmlOutput(xmlSink, container, file, fileMessages);
                }

                // Report progress as we work through the sources
                iProgressReporter.StepProgress(string.Empty, i, KStepKeyWritingOutputXml);
            }

            iProgressReporter.StepEnd(string.Empty, KStepKeyWritingOutputXml);
        }
Exemple #7
0
        private void TryToPrimeDbgEngine()
        {
            DbgEngine debugEngine = iEngine.DebugEngine;
            //
            Exception primerException = null;
            CACmdLineFSEntityList <CACmdLineFSEntity> metaDataFiles = iInputs.MetaDataFiles;

            //
            try
            {
                debugEngine.Clear();

                foreach (CACmdLineFSEntity entry in metaDataFiles)
                {
                    UITrace("[CA Cmd] Seeding debug meta engine with entry: " + entry.Name);
                    DbgEntity entity = debugEngine.Add(entry.Name);
                    if (entity != null)
                    {
                        UITrace("[CA Cmd] Entry type detected as: [" + entity.CategoryName + "]");
                        entity.Tag = entry;
                    }
                    else
                    {
                        UITrace("[CA Cmd] Entry not handled: " + entry.Name);
                        entry.AddError("Meta-Data File Not Supported", "The file \'" + entry.Name + "\' is of unknown origin.");
                    }
                }

                // Listen to prime events
                try
                {
                    UITrace("[CA Cmd] Starting prime operation... ");
                    debugEngine.EntityPrimingStarted  += new DbgEngine.EventHandler(DbgEngine_EntityPrimingStarted);
                    debugEngine.EntityPrimingProgress += new DbgEngine.EventHandler(DbgEngine_EntityPrimingProgress);
                    debugEngine.EntityPrimingComplete += new DbgEngine.EventHandler(DbgEngine_EntityPrimingComplete);
                    debugEngine.Prime(TSynchronicity.ESynchronous);
                    UITrace("[CA Cmd] Debug meta data priming completed successfully.");
                }
                finally
                {
                    debugEngine.EntityPrimingStarted  -= new DbgEngine.EventHandler(DbgEngine_EntityPrimingStarted);
                    debugEngine.EntityPrimingProgress -= new DbgEngine.EventHandler(DbgEngine_EntityPrimingProgress);
                    debugEngine.EntityPrimingComplete -= new DbgEngine.EventHandler(DbgEngine_EntityPrimingComplete);
                }
            }
            catch (Exception exception)
            {
                UITrace("[CA Cmd] Debug meta data priming exception: " + exception.Message + ", " + exception.StackTrace);
                primerException = exception;
            }

            // Go through each debug entity and check it for errors. Add diagnostics
            // and error messages where appropriate.
            foreach (DbgEntity entity in debugEngine)
            {
                string name = entity.FullName;
                //
                CACmdLineFSEntity file = metaDataFiles[name];
                file.Clear();
                //
                if (entity.PrimerResult.PrimedOkay)
                {
                    if (!entity.Exists)
                    {
                        file.AddError("Meta-Data File Missing", string.Format("The file \'{0}\' could not be found.", file.Name));
                    }
                    else if (entity.IsUnsupported)
                    {
                        file.AddError("Meta-Data File Not Supported", string.Format("The file \'{0}\' is of unknown origin.", file.Name));
                    }
                }
                else
                {
                    // Add error
                    file.AddError("Meta-Data Read Error", entity.PrimerResult.PrimeErrorMessage);

                    // And diagnostic information
                    Exception exception = entity.PrimerResult.PrimeException != null ? entity.PrimerResult.PrimeException : primerException;
                    if (exception != null)
                    {
                        file.AddDiagnostic("Meta-Data Exception Message", entity.PrimerResult.PrimeException.Message);
                        file.AddDiagnostic("Meta-Data Exception Stack", entity.PrimerResult.PrimeException.StackTrace);
                    }
                    else
                    {
                        file.AddDiagnostic("Meta-Data Unknown Failure", "No exception occurred at the primer or entity level?");
                    }
                }
            }
        }