Exemple #1
0
        private async System.Threading.Tasks.Task CancelGatheringAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            SetState(StateType.Canceling);

            string extraArgs = "";

            if (CompilerSource == Compiler.Clang)
            {
                extraArgs += " -i " + FixPath(Evaluator.Evaluate(SettingsManager.Instance.Settings.ScoreGenerator.InputPath));
            }

            string commandLine = GetPlatformFlag() + " -cancel" + extraArgs;

            OutputLog.Log("Calling ScoreDataExtractor with " + commandLine);
            int exitCode = ExternalProcess.ExecuteSync(GetScoreExtractorToolPath(), commandLine);

            if (exitCode != 0)
            {
                DisplayError("Score Data Extractor failed to cancel the recording session with code " + exitCode + ".");
            }

            SetState(StateType.Idle);
        }
Exemple #2
0
        private void PrepareGathering()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            SetState(StateType.Preparing);

            string extraArgs = "";

            if (CompilerSource == Compiler.MSVC)
            {
                extraArgs += " -d " + (int)OverviewDetail + (TimelinePacking == 0 ? "" : " -td " + (int)TimelineDetail);
            }
            else
            {
                extraArgs += " -i " + FixPath(Evaluator.Evaluate(SettingsManager.Instance.Settings.ScoreGenerator.InputPath));
            }

            string commandLine = GetPlatformFlag() + " -start" + extraArgs;

            OutputLog.Log("Calling ScoreDataExtractor with " + commandLine);
            int exitCode = ExternalProcess.ExecuteSync(GetScoreExtractorToolPath(), commandLine);

            if (exitCode != 0)
            {
                DisplayError("Score Data Extractor failed to start the recording session with code " + exitCode + ". The current build data won't be captured. Please check the output pane for more information.");
            }
        }
Exemple #3
0
        private bool SetScoreLocation(string input)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (ScoreLocation != input)
            {
                ScoreLocation = input;
                OutputLog.Log("Settings - Score File: " + ScoreLocation);
                return(true);
            }
            return(false);
        }
Exemple #4
0
        private void OnBuildBegin(vsBuildScope Scope, vsBuildAction Action)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            switch (State)
            {
            case StateType.Idle:
                SetState(StateType.BuildingExternal);
                break;

            case StateType.Triggering:
                PrepareGathering();
                OutputLog.Log("Building...");
                SetState(StateType.Building);
                break;
            }
        }
        private static void OnWatchedFileChanged(object source, FileSystemEventArgs e)
        {
            DateTime lastWriteTime = File.GetLastWriteTime(_fileWatcherFullPath);

            if ((lastWriteTime - _fileWatcherLastRead).Milliseconds > 100)
            {
                var fileInfo = new FileInfo(_fileWatcherFullPath);
                while (File.Exists(_fileWatcherFullPath) && IsFileLocked(fileInfo))
                {
                    //File is still locked, meaning the writing stream is still writing to the file,
                    // we need to wait until that process is done before trying to refresh it here.
                    System.Threading.Thread.Sleep(500);
                }

                ThreadHelper.JoinableTaskFactory.Run(async delegate {
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                    OutputLog.Log("File change detected.");
                    FileWatchedChanged?.Invoke();
                });

                _fileWatcherLastRead = lastWriteTime;
            }
        }
Exemple #6
0
        private async System.Threading.Tasks.Task GatherAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            OutputLog.Focus();

            SetState(StateType.Gathering);

            DocumentLifetimeManager.UnWatchFile();

            string inputPath    = CompilerSource == Compiler.Clang ? FixPath(Evaluator.Evaluate(SettingsManager.Instance.Settings.ScoreGenerator.InputPath)) : "";
            string inputCommand = inputPath.Length > 0 ? " -i " + inputPath : "";

            string outputPath    = Evaluator.Evaluate(SettingsManager.Instance.Settings.ScoreGenerator.OutputPath);
            string outputCommand = outputPath.Length > 0 ? " -o " + outputPath : "";

            string detail   = " -d " + (int)OverviewDetail;
            string timeline = TimelinePacking == 0 ? " -nt" : " -tp " + TimelinePacking + " -td " + (int)TimelineDetail;

            string commandLine = GetPlatformFlag() + " -stop" + timeline + detail + inputCommand + outputCommand;

            CreateDirectory(Path.GetDirectoryName(outputPath));

            OutputLog.Log("Calling ScoreDataExtractor with " + commandLine);
            int exitCode = ExternalProcess.ExecuteSync(GetScoreExtractorToolPath(), commandLine);

            if (exitCode != 0)
            {
                DisplayError("Score Data Extractor process failed with code " + exitCode + ". Please check the output pane for more information.");
            }

            CompilerData.Instance.ForceLoadFromFilename(outputPath);
            EditorUtils.FocusOverviewWindow();

            OutputLog.Log("Score generation completed!");
            SetState(StateType.Idle);
        }
Exemple #7
0
        private async System.Threading.Tasks.Task GenerateClangScoreAsync()
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (CompilerSource != Compiler.Clang)
            {
                return;
            }

            //Stop watching as the data extractor might modify the watched file
            DocumentLifetimeManager.UnWatchFile();

            //Process Data
            string inputPath  = FixPath(Evaluator.Evaluate(SettingsManager.Instance.Settings.ScoreGenerator.InputPath));
            string outputPath = Evaluator.Evaluate(SettingsManager.Instance.Settings.ScoreGenerator.OutputPath);

            CreateDirectory(Path.GetDirectoryName(outputPath));

            string detail   = " -d " + (int)OverviewDetail;
            string timeline = TimelinePacking == 0 ? " -nt" : " -tp " + TimelinePacking + " -td " + (int)TimelineDetail;

            string commandLine = "-clang -extract" + timeline + detail + " -i " + inputPath + " -o " + outputPath;

            OutputLog.Log("Calling ScoreDataExtractor with " + commandLine);
            int exitCode = await ExternalProcess.ExecuteAsync(GetScoreExtractorToolPath(), commandLine);

            if (exitCode != 0)
            {
                DisplayError("Compile Score Data Extractor process failed with code " + exitCode + ". Please check the output pane for more information.");
            }

            CompilerData.Instance.ForceLoadFromFilename(outputPath);
            EditorUtils.FocusOverviewWindow();

            OutputLog.Log("Score generation completed!");
        }
Exemple #8
0
        private void LoadSeverities(string fullPath)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            UnitsCollection.Clear();
            Totals.Clear();
            ClearDatasets();

            if (File.Exists(fullPath))
            {
                var watch = System.Diagnostics.Stopwatch.StartNew();

                FileStream fileStream = File.Open(fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                using (BinaryReader reader = new BinaryReader(fileStream))
                {
                    // Read version
                    uint thisVersion = reader.ReadUInt32();
                    if (thisVersion == VERSION)
                    {
                        // Read Header
                        Timeline.CompilerTimeline.Instance.TimelinePacking = reader.ReadUInt32();

                        // Read Units
                        uint unitsLength = reader.ReadUInt32();
                        var  unitList    = new List <UnitValue>((int)unitsLength);
                        for (uint i = 0; i < unitsLength; ++i)
                        {
                            ReadCompileUnit(reader, unitList, i);
                        }

                        UnitsCollection = new List <UnitValue>(unitList);

                        //Read Datasets
                        for (int i = 0; i < (int)CompileThresholds.Gather; ++i)
                        {
                            uint dataLength = reader.ReadUInt32();
                            var  thislist   = new List <CompileValue>((int)dataLength);
                            for (uint k = 0; k < dataLength; ++k)
                            {
                                ReadCompileValue(reader, thislist);
                            }
                            Datasets[i].collection = new List <CompileValue>(thislist);
                        }
                    }
                    else
                    {
                        OutputLog.Error("Version mismatch! Expected " + VERSION + " - Found " + thisVersion + " - Please export again with matching Data Exporter");
                    }
                }

                fileStream.Close();

                //Post process on read data
                PostProcessLoadedData();

                watch.Stop();
                const long TicksPerMicrosecond = (TimeSpan.TicksPerMillisecond / 1000);
                ulong      microseconds        = (ulong)(watch.ElapsedTicks / TicksPerMicrosecond);
                OutputLog.Log("Score file processed in " + Common.UIConverters.GetTimeStr(microseconds));
            }

            RecomputeSeverities();

            ScoreDataChanged?.Invoke();
        }