Ejemplo n.º 1
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?");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void TryToCreateXmlOutput(CISink aXmlSink, CIContainer aContainer, CACmdLineFileSource aFile, CACmdLineMessage[] aMessagesToAdd)
        {
            UITrace("[CA Cmd] TryToCreateXmlOutput() - START - container source: {0}", aContainer.Source.MasterFileName);

            // By the time we are outputting a container, there should no longer be any messages
            // associated with the file.
            System.Diagnostics.Debug.Assert(aFile.Count == 0);

            // Check whether the file contained any errors or
            // messages of it own.
            if (aMessagesToAdd.Length > 0)
            {
                // Copy warnings, messages and errors into crash item container.
                // Diagnostic messages are not copied.
                CACmdLineFSEntity.CopyMessagesToContainer(aMessagesToAdd, aContainer);
            }

            // This is where we will record the output attempt
            CACmdLineFileSource.OutputEntry outputEntry = null;
            //
            try
            {
                // Finish preparing the sink parameters
                CISinkSerializationParameters sinkParams = iInputs.SinkParameters;
                sinkParams.Container = aContainer;

                // Perform serialization
                UITrace("[CA Cmd] TryToCreateXmlOutput() - serializing...");
                object output = aXmlSink.Serialize(sinkParams);
                UITrace("[CA Cmd] TryToCreateXmlOutput() - serialization returned: " + output);

                if (aFile != null)
                {
                    // Create new output
                    string outputFileName = output is string?(string)output : string.Empty;

                    // Save output file name
                    outputEntry = aFile.AddOutput(aContainer, outputFileName, TOutputStatus.ESuccess);
                }

                // Merge in any diagnostic messages that were left into the output entry.
                // This ensure we output diagnostics in the final manifest data.
                outputEntry.AddRange(aMessagesToAdd, CACmdLineMessage.TType.ETypeDiagnostic);
            }
            catch (Exception outputException)
            {
                UITrace("[CA Cmd] TryToCreateXmlOutput() - outputException.Message:    " + outputException.Message);
                UITrace("[CA Cmd] TryToCreateXmlOutput() - outputException.StackTrace: " + outputException.StackTrace);

                if (aFile != null)
                {
                    // Something went wrong with XML serialisation for the specified container.
                    outputEntry = aFile.AddOutput(aContainer, string.Empty, TOutputStatus.EFailed);
                    //
                    outputEntry.AddError("Could not Create XML", "XML output could not be created");
                    outputEntry.AddDiagnostic("XML Sink Exception Message", outputException.Message);
                    outputEntry.AddDiagnostic("XML Sink Exception Stack", outputException.StackTrace);

                    // Since we didn't manage to sink the container to XML successfully, we must
                    // make sure we don't lose any associated messages from the original file.
                    // Merge these into the output entry also.
                    outputEntry.AddRange(aMessagesToAdd);
                }
            }
        }
        public bool Contains(string aFileName)
        {
            CACmdLineFSEntity ret = this[aFileName];

            return(ret != null);
        }