コード例 #1
0
        private Disposable <ExecutionLogFileReader> LoadExecutionLog(IExecutionLogTarget analyzer)
        {
            Contract.Requires(CachedGraph != null);

            if (ExecutionLogPath != null)
            {
                var analysisInput = this;
                var readerWrapper = StreamProvider.OpenReadStream(ExecutionLogPath)
                                    .ChainSelect(executionLogStream => new ExecutionLogFileReader(executionLogStream, analysisInput.CachedGraph.Context, analyzer, closeStreamOnDispose: true));

                var reader = readerWrapper.Value;

                if (!reader.LogId.HasValue)
                {
                    throw CommandLineUtilities.Error("Could not load execution log. Execution log does not have header containing pip graph id.");
                }

                if (reader.LogId.Value != CachedGraph.PipGraph.GraphId)
                {
                    throw CommandLineUtilities.Error("Could not load execution log. Execution log header contains pip graph id that does not match id from loaded pip graph.");
                }

                return(readerWrapper);
            }

            return(null);
        }
コード例 #2
0
        public DumpPipAnalyzer(AnalysisInput input, string outputFilePath, long semiStableHash, DirectoryArtifact directory, bool useOriginalPaths, bool logProgress = false)
            : base(input)
        {
            if (string.IsNullOrEmpty(outputFilePath))
            {
                outputFilePath = Path.Combine(Path.GetDirectoryName(input.ExecutionLogPath), $"Pip{semiStableHash:X16}.html");
                Console.WriteLine($"Missing option /outputFilePath using: {outputFilePath}");
            }

            m_outputFilePath   = outputFilePath;
            m_useOriginalPaths = useOriginalPaths;

            if (logProgress)
            {
                Console.WriteLine("Finding matching pip");
            }

            var pipTable = input.CachedGraph.PipTable;

            foreach (var pipId in pipTable.StableKeys)
            {
                if (pipTable.GetPipType(pipId) == PipType.Module)
                {
                    var modulePip = (ModulePip)pipTable.HydratePip(pipId, PipQueryContext.ViewerAnalyzer);
                    m_moduleIdToFriendlyName.Add(modulePip.Module, modulePip.Identity.ToString(StringTable));
                }

                var possibleMatch = pipTable.GetPipSemiStableHash(pipId);
                if (possibleMatch == semiStableHash)
                {
                    m_pip = pipTable.HydratePip(pipId, PipQueryContext.ViewerAnalyzer);
                }
            }

            if (directory.IsValid)
            {
                Console.WriteLine("Looking for a pip that produced the specified DirectoryArtifact.");

                var directoryProducers = input.CachedGraph.PipGraph.AllOutputDirectoriesAndProducers.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                if (directoryProducers.TryGetValue(directory, out var pipId))
                {
                    m_pip = pipTable.HydratePip(pipId, PipQueryContext.ViewerAnalyzer);
                }
                // This directory artifact does not have a registered producer. This might happen if it represents a composite SOD.
                else if (directory.IsSharedOpaque)
                {
                    directoryProducers = input.CachedGraph.PipGraph.AllCompositeSharedOpaqueDirectoriesAndProducers.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                    if (directoryProducers.TryGetValue(directory, out pipId))
                    {
                        m_pip = pipTable.HydratePip(pipId, PipQueryContext.ViewerAnalyzer);
                    }
                }
            }

            if (m_pip == null)
            {
                throw CommandLineUtilities.Error("Did not find a matching pip.");
            }

            m_html = new HtmlHelper(PathTable, StringTable, SymbolTable, CachedGraph.PipTable);
        }