Exemplo n.º 1
0
 private void ExtractFileList <T>(HACmdLineFSEntityList <T> aList, SXILElementCategory aCategory, bool aExpandDirectoriesToUnderlyingFiles) where T : HACmdLineFSEntity, 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);
             }
             //
             if (aExpandDirectoriesToUnderlyingFiles)
             {
                 aList.AddRange(dir.Files);
             }
             else
             {
                 aList.Add(dir.Directory);
             }
         }
     }
 }
Exemplo n.º 2
0
 private void ExtractOutput(SXILElementCategory aCategory)
 {
     // We either output to file or directory - if both are present then bail out
     iOutputFile = null;
     //
     foreach (SXILElement element in aCategory)
     {
         if (element is SXILElementFile)
         {
             if (iOutputFile != null)
             {
                 throw new HAUIException("Output specified twice", HAUIException.KErrCommandLineAnalysisOutputInvalid);
             }
             else
             {
                 SXILElementFile file = (SXILElementFile)element;
                 iOutputFile      = new HACmdLineFSEntity();
                 iOutputFile.File = new FileInfo(file.Name);
             }
         }
         else if (element is SXILElementDirectory)
         {
             throw new HAUIException("Cannot output directory", HAUIException.KErrCommandLineAnalysisOutputInvalid);
         }
     }
 }
        private void ExtractParameters(SXILElementCategory aCategory)
        {
            foreach (SXILElement element in aCategory)
            {
                if (element is SXILElementExtension)
                {
                    SXILElementExtension entry = (SXILElementExtension)element;
                    //
                    string extension = entry.Name;
                    if (!extension.StartsWith("."))
                    {
                        extension = "." + extension;
                    }
                    //
                    if (entry.Type == SXILElementExtension.TType.ETypeFailure)
                    {
                        Trace("[CmdInput] ExtractFileList() - failed extension: " + extension);
                        iSinkParams.FileExtensionFailed = extension;
                    }
                    else if (entry.Type == SXILElementExtension.TType.ETypeSuccess)
                    {
                        Trace("[CmdInput] ExtractFileList() - success extension: " + extension);
                        iSinkParams.FileExtensionSuccess = extension;
                    }
                }
                else if (element is SXILElementCommand)
                {
                    SXILElementCommand entry = (SXILElementCommand)element;
                    //
                    if (entry.Name == KInputFileCommandNameAnalysis)
                    {
                        string type = entry.Details.Trim().ToUpper();
                        Trace("[CmdInput] ExtractFileList() - command: " + type);
                        switch (type)
                        {
                        case KInputFileCommandNameAnalysisFull:
                            iSinkParams.DetailLevel = CISinkSerializationParameters.TDetailLevel.EFull;
                            break;

                        case KInputFileCommandNameAnalysisSummary:
                            iSinkParams.DetailLevel = CISinkSerializationParameters.TDetailLevel.ESummary;
                            break;

                        default:
                            throw new NotSupportedException("Unsupported analysis type");
                        }
                    }
                    else
                    {
                        throw new NotSupportedException("Unsupported command: " + entry.Name);
                    }
                }
            }
        }
        public override void XmlParse(XmlNode aNode)
        {
            System.Diagnostics.Debug.Assert(aNode.Name.ToUpper() == "CATEGORY");
            System.Diagnostics.Debug.Assert(aNode.Attributes.Count >= 1);

            SXILElementCategory category = new SXILElementCategory(iName);

            base.Document.AppendChild(category);
            base.Document.CurrentNode = category;
            //
            base.XmlParse(aNode);
            //
            base.Document.MakeParentCurrent();
        }
        private void ExtractOutput(SXILElementCategory aCategory)
        {
            // We either output to file or directory - if both are present then bail out
            FileInfo      savedFile = null;
            DirectoryInfo savedDir  = null;

            //
            foreach (SXILElement element in aCategory)
            {
                if (element is SXILElementFile)
                {
                    if (savedFile != null)
                    {
                        throw new InvalidDataException("Output file already specified");
                    }
                    else
                    {
                        SXILElementFile file = (SXILElementFile)element;
                        savedFile = file;
                    }
                }
                else if (element is SXILElementDirectory)
                {
                    if (savedDir != null)
                    {
                        throw new InvalidDataException("Output directory already specified");
                    }
                    else
                    {
                        SXILElementDirectory dir = (SXILElementDirectory)element;
                        savedDir = dir;
                    }
                }
            }

            // Ensure we have only one type
            if (savedFile != null && savedDir != null)
            {
                throw new InvalidDataException("Output must be EITHER file or directory");
            }
            else if (savedFile != null)
            {
                iSinkParams.OutputFile = savedFile;
            }
            else if (savedDir != null)
            {
                iSinkParams.OutputDirectory = savedDir;
            }
        }
        private void ExtractData(SXILDocument aDocument)
        {
            foreach (SXILElement element in aDocument)
            {
                if (element is SXILElementCategory)
                {
                    SXILElementCategory category = (SXILElementCategory)element;
                    string name = category.Name.ToLower();
                    //
                    switch (name)
                    {
                    case KInputFileCategorySource:
                        ExtractFileList <CACmdLineFileSource>(iSources, category);
                        break;

                    case KInputFileCategoryDebugMetaData:
                        // The debug meta data engine doesn't support directories anymore
                        // so we have to expand all directories to files.
                        ExtractFileList <CACmdLineFSEntity>(iMetaData, category);
                        break;

                    case KInputFileCategoryParameters:
                        ExtractParameters(category);
                        break;

                    case KInputFileCategoryOutput:
                        ExtractOutput(category);
                        break;
                    }
                }
            }

            // We don't require debug meta data if performing a summary operation. Otherwise, we do.
            if (iMetaData.Count == 0 && iSinkParams.DetailLevel == CISinkSerializationParameters.TDetailLevel.EFull)
            {
                Trace("[CmdInput] ExtractData() - WARNING - no debug meta data supplied for full analysis.");
            }
        }
Exemplo n.º 7
0
        private void ExtractParameters(SXILElementCategory aCategory)
        {
            foreach (SXILElement element in aCategory)
            {
                if (element is SXILElementCommand)
                {
                    SXILElementCommand entry = (SXILElementCommand)element;
                    //
                    string type = entry.Details.Trim();
                    if (entry.Name == KInputFileCommandNameAnalysis)
                    {
                        Trace("[CmdInput] ExtractFileList() - command: " + type);
                        switch (type.ToUpper())
                        {
                        case KInputFileCommandNameAnalysisViewer:
                            iEngine.OperationType = HeapWizardEngine.TOperationType.EOperationTypeAnalyseAndView;
                            break;

                        case KInputFileCommandNameAnalysisCompareTwoHeaps:
                            iEngine.OperationType = HeapWizardEngine.TOperationType.EOperationTypeCompareHeapDumps;
                            break;

                        default:
                            throw new HAUIException("Unsupported analysis type", HAUIException.KErrCommandLineAnalysisTypeNotSupported);
                        }
                    }
                    else if (entry.Name == KInputFileCommandThread)
                    {
                        iThreadName = type;
                    }
                    else
                    {
                        throw new HAUIException("Unsupported command: " + entry.Name, HAUIException.KErrCommandLineInvalidCommand);
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void ExtractData(SXILDocument aDocument)
        {
            foreach (SXILElement element in aDocument)
            {
                if (element is SXILElementCategory)
                {
                    SXILElementCategory category = (SXILElementCategory)element;
                    string name = category.Name.ToLower();
                    //
                    switch (name)
                    {
                    case KInputFileCategorySource:
                        ExtractFileList <HACmdLineFileSource>(iSources, category, true);
                        break;

                    case KInputFileCategoryDebugMetaData:
                        ExtractFileList <HACmdLineFSEntity>(iMetaData, category, false);
                        break;

                    case KInputFileCategoryParameters:
                        ExtractParameters(category);
                        break;

                    case KInputFileCategoryOutput:
                        ExtractOutput(category);
                        break;
                    }
                }
            }

            // We don't require debug meta data if performing a summary operation. Otherwise, we do.
            if (iMetaData.Count == 0)
            {
                Trace("[CmdInput] ExtractData() - no debug meta data supplied!");
                throw new HAUIException("Debug meta-data not present", HAUIException.KErrCommandLineDebugMetaDataMissing);
            }
        }