예제 #1
0
        /// <summary>
        /// Called from VsPackage to notify the profiler about the Visual Studio debugging mode change (from design to run,
        /// from run to break, etc.).
        /// </summary>
        /// <param name="dbgmodeNew">The new Visual Studio debugging mode.</param>
        public void OnModeChange(DBGMODE dbgmodeNew)
        {
            DBGMODE lastMode = DebugMode;

            DebugMode = dbgmodeNew;
            ProfileLauncher.OnModeChange(lastMode, dbgmodeNew);
        }
예제 #2
0
        /// <summary>
        /// Start a profiling session.
        /// </summary>
        /// <remarks>
        /// A run profiler dialog is shown (if not starting a live profiling session). The dialog allows a user to edit
        /// different profiling options.
        /// </remarks>
        /// <param name="isLiveProfiling">
        /// true in case of live profiling (i.e. combined debugging and profiling), false otherwise
        /// </param>
        /// <returns>true if profiling has been started successfully, false otherwise</returns>
        public bool StartProfiler(bool isLiveProfiling)
        {
            Project project;

            if (!CanStartProfiler(out project) || (project == null))
            {
                return(false);
            }

            var sessionConfiguration = new ProfileSessionConfiguration(project, GeneralOptions);

            if (isLiveProfiling)
            {
                var preset = ProfilingPreset.CpuSampling;
                preset.ProfilingSettings.TraceSourceLines = false; // TODO!! example
                sessionConfiguration.ProfilingPreset      = preset;
            }
            else
            {
                var dlg = new RunProfilerDialog(sessionConfiguration);
                dlg.ShowDialog();
                if (!(dlg.DialogResult ?? false))
                {
                    return(false);
                }
            }

            SDBDeviceInfo device = GetAndCheckSelectedDevice(isLiveProfiling ? RunMode.LiveProfiler : RunMode.CoreProfiler);

            if (device == null)
            {
                return(false);
            }

            ProfileSession session = ProfileLauncher.CreateSession(device, sessionConfiguration, isLiveProfiling);

            if (session == null)
            {
                return(false);
            }
            ProfilingProgressWindow.SetSession(session);
            ProfileLauncher.StartSession(session);
            return(true);
        }
예제 #3
0
        private ProfilerPlugin(Package package, IVsOutputWindowPane outputPaneTizen, IVsThreadedWaitDialogFactory dialogFactory)
        {
            _package         = package ?? throw new ArgumentNullException(nameof(package));
            _outputPaneTizen = outputPaneTizen;
            _dialogFactory   = dialogFactory;

            OLEServiceProvider =
                GetService(typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)) as
                Microsoft.VisualStudio.OLE.Interop.IServiceProvider;

            VsUiShell5 = GetIVsUIShell5();

            ExplorerWindowCommand.Initialize(_package);
            ProfilingProgressWindowCommand.Initialize(_package);

            GeneralOptions   = new GeneralOptions(new SettingsStore(_package, SettingsCollectionPath));
            HeaptrackOptions = new HeaptrackOptions(new SettingsStore(_package, SettingsCollectionPath));

            RegisterMenuHandlers();

            ProfileLauncher.Initialize();
            HeaptrackLauncher.Initialize();

            ProfileLauncher   = ProfileLauncher.Instance;
            HeaptrackLauncher = HeaptrackLauncher.Instance;
            HeaptrackLauncher.OnSessionFinished += HandleMenuItemRunMemoryProfiler;

            _solutionListener = new SolutionListener(_package)
            {
                AfterOpenSolution = delegate
                {
                    _solutionSessionsContainer.Update();
                    return(VSConstants.S_OK);
                },
                AfterCloseSolution = delegate
                {
                    _solutionSessionsContainer.Update();
                    return(VSConstants.S_OK);
                }
            };
            _solutionListener.Initialize();

            _solutionSessionsContainer = new SolutionSessionsContainer((DTE2)Package.GetGlobalService(typeof(SDTE)));
        }