/// <summary>
        /// Standard constructor for the tool window.
        /// </summary>
        public TabbedDebugLogToolWindow() :
            base(null)
        {
            // Set the window title reading it from the resources.
            this.Caption = Resources.ToolWindowTitle;
            // Set the image that will appear on the tab of the window frame
            // when docked with an other window
            // The resource ID correspond to the one defined in the resx file
            // while the Index is the offset in the bitmap strip. Each image in
            // the strip being 16x16.
            this.BitmapResourceID = 301;
            this.BitmapIndex      = 1;

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.
            base.Content = new TabbedLogControl();

            m_previousDebuggerMode = DBGMODE.DBGMODE_Design;//Assume we are in design mode to start with.
            IVsDebugger debugService = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShellDebugger)) as IVsDebugger;

            if (debugService != null)
            {
                debugService.AdviseDebuggerEvents(this, out cookie);
                debugService.AdviseDebugEventCallback(this);
            }
        }
Ejemplo n.º 2
0
        public ReAttachDebugger(IReAttachPackage package)
        {
            _package = package;
            _debugger = package.GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            _dte = _package.GetService(typeof(SDTE)) as DTE2;
            if (_dte != null)
                _dteDebugger = _dte.Debugger as Debugger2;

            if (_package == null || _debugger == null || _dte == null || _dteDebugger == null)
            {
                _package.Reporter.ReportError(
                    "Unable to get required services for ReAttachDebugger in ctor.");
                return;
            }

            // TODO: Unadvise, or did I find something telling me otherwise?
            if (_debugger.AdviseDebuggerEvents(this, out _cookie) != VSConstants.S_OK)
                _package.Reporter.ReportError("ReAttach: AdviserDebuggerEvents failed.");

            if (_debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
                _package.Reporter.ReportError("AdviceDebugEventsCallback call failed in ReAttachDebugger ctor.");

            foreach (Engine engine in _dteDebugger.Transports.Item("Default").Engines)
            {
                var engineId = Guid.Parse(engine.ID);
                if (ReAttachConstants.IgnoredDebuggingEngines.Contains(engineId))
                    continue;

                _engines.Add(engineId, engine.Name);
            }
        }
Ejemplo n.º 3
0
 private static bool IsDebugging(IServiceProvider provider, IVsDebugger debugger)
 {
     return(provider.GetUIThread().Invoke(() => {
         var mode = new[] { DBGMODE.DBGMODE_Design };
         return ErrorHandler.Succeeded(debugger.GetMode(mode)) && mode[0] != DBGMODE.DBGMODE_Design;
     }));
 }
Ejemplo n.º 4
0
 internal void InjectService(IVsDebugger vsDebugger)
 {
     if (RevitToolsControl != null)
     {
         RevitToolsControl.ViewModel.VsDebugger = vsDebugger;
     }
 }
Ejemplo n.º 5
0
        private void Attach(IVsDebugger debugger)
        {
            var process = Process;

            if (process != null)
            {
                if (!VsEnvironment.IsDebuggerPresent(process))
                {
                    try
                    {
                        debugger.Attach(process.Id);
                        AttachVisibility = System.Windows.Visibility.Collapsed;
                        DetachVisibility = System.Windows.Visibility.Visible;

                        DetachCommand = new ActionCommand(() => { Detach(debugger); },
                                                          Service.Status == ServiceControllerStatus.Running &&
                                                          VsEnvironment.Debuggers.Any());
                        OnPropertyChanged("DetachCommand");
                    }
                    catch (COMException e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
            }
            ((ActionCommand)AttachCommand).Enabled =
                Service.Status == ServiceControllerStatus.Running &&
                VsEnvironment.Debuggers.Any();
        }
Ejemplo n.º 6
0
        internal DebuggerEvents()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsDebugger svc = VS.GetRequiredService <IVsDebugger, IVsDebugger>();

            svc.AdviseDebuggerEvents(this, out _);
        }
Ejemplo n.º 7
0
        public DebugManager(ExcelDnaToolsPackage package, ExcelConnection connection)
        {
            _package = package;
            _connection = connection;
            var packageServiceProvider = (IServiceProvider)package;
             _debugger = packageServiceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            // var dgr = Package.GetGlobalService(typeof(SVsShellDebugger)) ;
            // _debugger = dgr as IVsDebugger;
            _dte = packageServiceProvider.GetService(typeof(SDTE)) as DTE;
            if (_dte != null)
            {
                _dteDebugger = _dte.Debugger as Debugger2;
            }

            if (_package == null || _debugger == null || _dte == null || _dteDebugger == null)
            {
                Debug.Fail("DebugManager setup failed");
                return;
            }

            if (_debugger.AdviseDebuggerEvents(this, out _debuggerEventsCookie) != VSConstants.S_OK)
            {
                Debug.Fail("DebugManager setup failed");
            }

            if (_debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
            {
                Debug.Fail("DebugManager setup failed");
            }
        }
Ejemplo n.º 8
0
        /// <devdoc>
        /// Launch the debugger.
        /// </devdoc>
        /// <param name="serviceProvider">The service provider.</param>
        /// <param name="info">A reference to a VsDebugTargetInfo object.</param>
        public static void LaunchDebugger(IServiceProvider serviceProvider, VsDebugTargetInfo info)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentException("serviceProvider");
            }

            info.cbSize = (uint)Marshal.SizeOf(info);
            IntPtr ptr = Marshal.AllocCoTaskMem((int)info.cbSize);

            Marshal.StructureToPtr(info, ptr, false);

            try
            {
                IVsDebugger d = serviceProvider.GetService(typeof(IVsDebugger)) as IVsDebugger;

                if (d == null)
                {
                    throw new InvalidOperationException();
                }

                ErrorHandler.ThrowOnFailure(d.LaunchDebugTargets(1, ptr));
            }
            finally
            {
                if (ptr != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(ptr);
                }
            }
        }
Ejemplo n.º 9
0
        public VsDebuggerEvents(IVsDebugger debugger)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            service = debugger;
            service.AdviseDebuggerEvents(this, out cookie);
        }
Ejemplo n.º 10
0
        public static async Task InitializeAsync(Shell.IAsyncServiceProvider provider)
        {
            await Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            {
                s_ServerId = SERVER_PREFIX;// + System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
                s_PipePool = new PipePool(s_ServerId);
                s_PipePool.Start();
            }
            {
                s_Service = await provider.GetServiceAsync(typeof(SVsShellDebugger)) as IVsDebugger;

                s_DTE = await provider.GetServiceAsync(typeof(SDTE)) as DTE;
            }
            if (s_Service != null)
            {
                s_Service.AdviseDebuggerEvents(Instance, out s_Cookie);
                s_Service.AdviseDebugEventCallback(Instance);
            }
            try
            {
                await Task.Run(() => InitAdresses());
            }
            catch (Exception ex)
            {
                service.Output.WriteError(ex.ToString());
            }
        }
        private void OnStartupComplete()
        {
            CreateOutputWindow();
            CreateStatusBarIcon();

            solutionEvents = events.SolutionEvents;
            buildEvents    = events.BuildEvents;
            windowEvents   = events.WindowEvents;

            solutionEvents.Opened += OnSolutionOpened;

            solutionEvents.AfterClosing += OnSolutionClosed;

            buildEvents.OnBuildBegin += OnBuildBegin;
            buildEvents.OnBuildDone  += OnBuildDone;

            debugService = (IVsDebugger)GetGlobalService(typeof(SVsShellDebugger));
            debugService.AdviseDebuggerEvents(this, out debugCookie);

            var componentModel = (IComponentModel)GetGlobalService(typeof(SComponentModel));

            operationState = componentModel.GetService <IOperationState>();
            operationState.StateChanged += OperationStateOnStateChanged;

            application                   = Application.Current;
            application.Activated        += OnApplicationActivated;
            application.Deactivated      += OnApplicationDeactivated;
            windowEvents.WindowActivated += OnWindowActivated;

            SystemEvents.SessionSwitch    += OnSessionSwitch;
            SystemEvents.PowerModeChanged += OnPowerModeChanged;

            VSColorTheme.ThemeChanged += OnThemeChanged;

            chart.Loaded += (s, a) =>
            {
                Window window = Window.GetWindow(chart);
                new Lid(window).StatusChanged += OnLidStatusChanged;
            };

            ListenToScreenSaver();

            sm = new VSStateMachine();

            if (application.Windows.OfType <Window>()
                .All(w => !w.IsActive))
            {
                sm.On(VSStateMachine.Events.LostFocus);
            }

            if (dte.Solution.Count > 0)
            {
                sm.On(VSStateMachine.Events.SolutionOpened);
            }

            sm.StateChanged += s => Output("Current state: {0}", s.ToString());

            Output("Startup complete");
            Output("Current state: {0}", sm.CurrentState.ToString());
        }
Ejemplo n.º 12
0
        protected override void Dispose(bool disposing)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (this.debugCookie != 0)
            {
                this.debuggerForCookie.UnadviseDebuggerEvents(this.debugCookie);
                this.debuggerForCookie = null;
                this.debugCookie       = 0;
            }

            if (this.frameCookie != 0)
            {
                this.frameForCookie.Unadvise(this.frameCookie);
                this.frameForCookie = null;
                this.frameCookie    = 0;
            }

            if (this.debugTextBuffer != null)
            {
                this.debugTextBuffer.Changed -= this.OnTextBufferChanged;
            }

            this.cancellationTokenSource.Cancel();
            this.cancellationTokenSource.Dispose();
            this.dataBindingOutputLevelKey.Dispose();
            this.viewModel.Dispose();

            base.Dispose(disposing);
        }
Ejemplo n.º 13
0
        public DebugManager(ExcelDnaToolsPackage package, ExcelConnection connection)
        {
            _package    = package;
            _connection = connection;
            var packageServiceProvider = (IServiceProvider)package;

            _debugger = packageServiceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            // var dgr = Package.GetGlobalService(typeof(SVsShellDebugger)) ;
            // _debugger = dgr as IVsDebugger;
            _dte = packageServiceProvider.GetService(typeof(SDTE)) as DTE;
            if (_dte != null)
            {
                _dteDebugger = _dte.Debugger as Debugger2;
            }

            if (_package == null || _debugger == null || _dte == null || _dteDebugger == null)
            {
                Debug.Fail("DebugManager setup failed");
                return;
            }

            if (_debugger.AdviseDebuggerEvents(this, out _debuggerEventsCookie) != VSConstants.S_OK)
            {
                Debug.Fail("DebugManager setup failed");
            }

            if (_debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
            {
                Debug.Fail("DebugManager setup failed");
            }
        }
Ejemplo n.º 14
0
        public ReAttachDebugger(IReAttachPackage package)
        {
            _package  = package;
            _debugger = package.GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            _dte      = _package.GetService(typeof(SDTE)) as DTE2;
            if (_dte != null)
            {
                _dteDebugger = _dte.Debugger as Debugger2;
            }

            if (_package == null || _debugger == null || _dte == null || _dteDebugger == null)
            {
                _package.Reporter.ReportError(
                    "Unable to get required services for ReAttachDebugger in ctor.");
                return;
            }

            if (_debugger.AdviseDebuggerEvents(this, out _cookie) != VSConstants.S_OK)
            {
                _package.Reporter.ReportError("ReAttach: AdviserDebuggerEvents failed.");
            }

            if (_debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
            {
                _package.Reporter.ReportError("AdviceDebugEventsCallback call failed in ReAttachDebugger ctor.");
            }

            foreach (Engine engine in _dteDebugger.Transports.Item("Default").Engines)
            {
                _engines.Add(Guid.Parse(engine.ID), engine.Name);
            }
        }
Ejemplo n.º 15
0
        public static void RegisteDefaultTypes(this IUnityContainer container)
        {
            container.RegisterType <ILog, OutputWindowLogger>();

            var ev = new VSEnvironmentEvents.VSEnvironmentEventsPublisher();

            container.RegisterInstance <IVSEnvironmentEventsPublisher>(ev);
            container.RegisterInstance <IVsEnvironmentEvents>(ev);

            container.RegisterType <ExpressioEvaluation.ISearchStatus, SearchStatusLister>();
            container.RegisterInstance <ITaskSchedulerProvider>(new TaskSchedulerProvider());

            var provider = new ExpressionEvaluatorProvider(ev);

            container.RegisterInstance <IExpressionEvaluatorProvider>(provider);
            container.RegisterInstance <IExpressionEvaluatorContainer>(provider);

            // Use this to disable cache while debugging
            //container.RegisterType<IExpressionsCache, DisabledExpressionsCache>();
            container.RegisterType <IExpressionsCache, ExpressionsCache>();


            IVsDebugger _debugger = VisualStudioServices.VsDebugger;
            ExpressionEvaluatorDispatcher _dispatcher;

            _dispatcher = ExpressionEvaluatorDispatcher.Create(VisualStudioServices.VsDebugger,
                                                               container.Resolve <IExpressionEvaluatorContainer>(),
                                                               container.Resolve <IExpressionsCache>());
            container.RegisterInstance <ExpressionEvaluatorDispatcher>(_dispatcher, new ContainerControlledLifetimeManager());

            container.RegisterType <IExpressionEvaluatorViewModel, ExpressionEvaluatorViewModel>();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TracePointHostWindow1"/> class.
        /// </summary>
        public TracePointHostWindow1() : base(null)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            this.Caption             = AppStringResources.lblToolWindowCaption;
            this._ucTracePoint       = new TracePointHostWindow1Control();
            this._debugEventCallback = new VSEventCallbackWrapper();
            this._debugEventCallback.OnSessionStart    += _debugEventCallback_OnSessionStart;
            this._debugEventCallback.OnTracePointAdded += _debugEventCallback_OnTracePointAdded;

            IVsDebugger debugService = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShellDebugger)) as IVsDebugger;

            if (debugService != null)
            {
                // Register for debug events.
                // Assumes the current class implements IDebugEventCallback2.
                debugService.AdviseDebugEventCallback(this._debugEventCallback);
            }

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.

            this.Content = _ucTracePoint;
        }
Ejemplo n.º 17
0
        protected void LaunchDebugTarget()
        {
            Microsoft.VisualStudio.Shell.ServiceProvider sp =
                new Microsoft.VisualStudio.Shell.ServiceProvider((IOleServiceProvider)Dte);

            IVsDebugger dbg = (IVsDebugger)sp.GetService(typeof(SVsShellDebugger));

            VsDebugTargetInfo info = new VsDebugTargetInfo();


            info.cbSize     = (uint)Marshal.SizeOf(info);
            info.dlo        = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            info.bstrExe    = Moniker;
            info.bstrCurDir = @"C:\";
            string connectionString = HierarchyAccessor.Connection.ConnectionSupport.ConnectionString + ";Allow User Variables=true;Allow Zero DateTime=true;";

            if (connectionString.IndexOf("password", StringComparison.OrdinalIgnoreCase) == -1)
            {
                var connection = (MySqlConnection)HierarchyAccessor.Connection.GetLockedProviderObject();
                try
                {
                    var settings = (MySqlConnectionStringBuilder)connection.GetType().GetProperty("Settings", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(connection, null);
                    connectionString += "password="******";Persist Security Info=true;";
                }
                finally
                {
                    HierarchyAccessor.Connection.UnlockProviderObject();
                }
            }
            info.bstrArg                   = connectionString;
            info.bstrRemoteMachine         = null;                                               // Environment.MachineName; // debug locally
            info.fSendStdoutToOutputWindow = 0;                                                  // Let stdout stay with the application.
            info.clsidCustom               = new Guid("{EEEE0740-10F7-4e5f-8BC4-1CC0AC9ED5B0}"); // Set the launching engine the sample engine guid
            info.grfLaunch                 = 0;

            IntPtr pInfo = Marshal.AllocCoTaskMem((int)info.cbSize);

            Marshal.StructureToPtr(info, pInfo, false);

            try
            {
                int result = dbg.LaunchDebugTargets(1, pInfo);
                if (result != 0 && result != VSConstants.E_ABORT)
                {
                    throw new ApplicationException("COM error " + result);
                }
            }
            catch (Exception ex)
            {
                InfoDialog.ShowDialog(InfoDialogProperties.GetErrorDialogProperties("Debugger Error", ex.GetBaseException().Message));
            }
            finally
            {
                if (pInfo != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pInfo);
                }
            }
        }
Ejemplo n.º 18
0
 public EpochQuickInfoSource(EpochQuickInfoSourceProvider provider, ITextBuffer subjectBuffer, IVsDebugger debugger, IVsEditorAdaptersFactoryService adapter)
 {
     m_provider      = provider;
     m_subjectBuffer = subjectBuffer;
     m_debugger      = debugger;
     m_adapter       = adapter;
     m_parsedProject = subjectBuffer.Properties.GetProperty <Parser.Project>(typeof(Parser.Project));
 }
        public IDebuggerEvents AdviseDebuggerEvents(IDebugUserControl control, out uint cookie)
        {
            VisualStudioDebuggerEvents vsde = new VisualStudioDebuggerEvents(r_dte, control);
            IVsDebugger vsd = control.GetDebugService(typeof(IVsDebugger)) as IVsDebugger;
            int         hr  = vsd.AdviseDebuggerEvents(vsde, out cookie);

            return(vsde);
        }
Ejemplo n.º 20
0
 public ExitEventListener()
 {
     _debugger = Package.GetGlobalService(typeof(SVsShellDebugger)) as IVsDebugger;
     if (_debugger != null)
     {
         _debugger.AdviseDebugEventCallback(this);
     }
 }
Ejemplo n.º 21
0
        private static bool TryGetQuickInfoFromDebugger(IQuickInfoSession session, SnapshotSpan span, IVsTextView viewAdapter, out string tipText)
        {
            IVsTextLines lines;

            tipText = null;
            IVsDebugger debuggerService = GetDebuggerService(session.TextView);

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

            IVsTextView vsTextView = viewAdapter;
            var         txtSpan    = GetTextSpan(viewAdapter, span); //GetTextSpan(session.TextView.TextBuffer, span, out vsTextView);

            TextSpan[] dataBufferTextSpan = new TextSpan[] { txtSpan };

            int hr = -2147467259;

            if ((dataBufferTextSpan[0].iStartLine == dataBufferTextSpan[0].iEndLine) && (dataBufferTextSpan[0].iStartIndex == dataBufferTextSpan[0].iEndIndex))
            {
                int iStartIndex = dataBufferTextSpan[0].iStartIndex;
                int iStartLine  = dataBufferTextSpan[0].iStartLine;
                //if (ErrorHandler.Failed(textViewWindow.GetWordExtent(iStartLine, iStartIndex, 0, dataBufferTextSpan)))
                //{
                //    return false;
                //}
                if ((iStartLine < dataBufferTextSpan[0].iStartLine) || (iStartLine > dataBufferTextSpan[0].iEndLine))
                {
                    return(false);
                }
                if ((iStartLine == dataBufferTextSpan[0].iStartLine) && (iStartIndex < dataBufferTextSpan[0].iStartIndex))
                {
                    return(false);
                }
                if ((iStartLine == dataBufferTextSpan[0].iEndLine) && (iStartIndex >= dataBufferTextSpan[0].iEndIndex))
                {
                    return(false);
                }
            }
            if (ErrorHandler.Failed(vsTextView.GetBuffer(out lines)))
            {
                return(false);
            }
            hr = debuggerService.GetDataTipValue(lines, dataBufferTextSpan, null, out tipText);
            if (hr == 0x45001)
            {
                HandoffNoDefaultTipToDebugger(session);
                session.Dismiss();
                tipText = null;
                return(true);
            }
            if (ErrorHandler.Failed(hr))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 22
0
        public DataTipTextViewFilter(System.IServiceProvider serviceProvider, IVsTextView vsTextView) {
            _debugger = (IVsDebugger)NodejsPackage.GetGlobalService(typeof(IVsDebugger));
            vsTextView.GetBuffer(out _vsTextLines);

            var editorAdaptersFactory = serviceProvider.GetComponentModel().GetService<IVsEditorAdaptersFactoryService>();
            _wpfTextView = editorAdaptersFactory.GetWpfTextView(vsTextView);

            ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
        }
Ejemplo n.º 23
0
 ///--------------------------------------------------------------------------------------------
 /// <summary>
 /// Quit listening to debug mode changes
 /// </summary>
 ///--------------------------------------------------------------------------------------------
 private void UnadviseDebugger()
 {
     if (_debuggerCookie != 0 && _debugger != null)
     {
         _debugger.UnadviseDebuggerEvents(_debuggerCookie);
     }
     _debugger       = null;
     _debuggerCookie = 0;
 }
Ejemplo n.º 24
0
 public static void Instantiate(IVsDebugger debugger)
 {
     lock (_locker)
     {
         if (_instance != null)
             throw new InvalidOperationException(string.Format("{0} of Resurrect is already instantiated.", _instance.GetType().Name));
         _instance = new DebugEventsHunter(debugger);
     }
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            ICPServiceProvider cpServProv = ICPServiceProvider.GetProvider();

            cpServProv.RegisterService <ICPTracerService>(new CPTracerService());

            IVsDebugger vsDebugService = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShellDebugger)) as IVsDebugger;

            if (vsDebugService != null)
            {
                cpServProv.RegisterService <ICPDebugService>(new CPDebugService(vsDebugService));
            }

            ICPExtension extensionServ = new CPExtension();

            cpServProv.RegisterService <ICPExtension>(extensionServ);

            Globals.dte = (DTE)GetService(typeof(DTE));
            //factory = new ChartPntFactoryImpl();
            if (Globals.processor == null)
            {
                Globals.processor = CP.Utils.IClassFactory.GetInstance().CreateCPProc();
            }
            Globals.orchestrator = CP.Utils.IClassFactory.GetInstance().CreateCPOrchestrator();
            IVsSolution vsSolution = GetService(typeof(SVsSolution)) as IVsSolution;
            object      objLoadMgr = this; //the class that implements IVsSolutionManager

            vsSolution.SetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, objLoadMgr);
            solEvents = new VsSolutionEvents(this);
            uint solEvsCookie;

            vsSolution.AdviseSolutionEvents(solEvents, out solEvsCookie);
            buildManager3 = GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager3;
            cmdEvsHandler = new CmdEventsHandler(vsSolution);

            string vsixInstPath = extensionServ.GetVSIXInstallPath();
            string regSrvFName  = vsixInstPath + "\\cper.exe";

            if (File.Exists(regSrvFName))
            {
                string            message = "First time registration.\nAdministration privileges needed.";
                string            caption = "ChartPoints";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
                var p = new System.Diagnostics.Process();
                p.StartInfo.FileName    = regSrvFName;
                p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                p.StartInfo.Verb        = "runas";
                if (p.Start())
                {
                    p.WaitForExit();
                    File.Delete(regSrvFName);
                }
            }
        }
Ejemplo n.º 26
0
 public VsImmediateWindowProvider(
     SVsServiceProvider serviceProvider,
     IVsInteractiveWindowFactory interactiveWindowFactory,
     IViewClassifierAggregatorService classifierAggregator,
     IContentTypeRegistryService contentTypeRegistry,
     VisualStudioWorkspace workspace)
 {
     _vsInteractiveWindowFactory = interactiveWindowFactory;
     _vsDebugger = (IVsDebugger)serviceProvider.GetService(typeof(IVsDebugger));
 }
        public EpochTextViewFilter(IVsDebugger debugger, CodeWindowManager mgr, IVsTextView textView, IWpfTextView wpfTextView)
            : base(mgr, textView)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Debugger    = debugger;
            WpfTextView = wpfTextView;

            textView.GetBuffer(out TextLines);
        }
 public VsImmediateWindowProvider(
     SVsServiceProvider serviceProvider,
     IVsInteractiveWindowFactory interactiveWindowFactory,
     IViewClassifierAggregatorService classifierAggregator,
     IContentTypeRegistryService contentTypeRegistry,
     VisualStudioWorkspace workspace)
 {
     _vsInteractiveWindowFactory = interactiveWindowFactory;
     _vsDebugger = (IVsDebugger)serviceProvider.GetService(typeof(IVsDebugger));
 }
Ejemplo n.º 29
0
        public static DBGMODE GetMode(this IVsDebugger debugger)
        {
            DBGMODE[] mode = new DBGMODE[1];
            if (ErrorHandler.Failed(debugger.GetMode(mode)))
            {
                return(DBGMODE.DBGMODE_Design);
            }

            return(mode[0]);
        }
Ejemplo n.º 30
0
        public async Task <IReadOnlyList <IDebugLaunchSettings> > QueryDebugTargetsAsync(DebugLaunchOptions launchOptions, ILaunchProfile profile)
        {
            // NOTE: This method is called from the main (UI) thread and must remain on that thread!
            if (profile.IsSnapshotDebuggerProfile())
            {
                IVsDebugger dbg = ServiceProvider.GetService(typeof(IVsDebugger)) as IVsDebugger;
            }

            return(new List <IDebugLaunchSettings>());
        }
Ejemplo n.º 31
0
        public TextViewFilter(IServiceProvider serviceProvider, IVsTextView vsTextView) {
            var compModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
            _vsEditorAdaptersFactoryService = compModel.GetService<IVsEditorAdaptersFactoryService>();
            _debugger = (IVsDebugger)serviceProvider.GetService(typeof(IVsDebugger));

            vsTextView.GetBuffer(out _vsTextLines);
            _wpfTextView = _vsEditorAdaptersFactoryService.GetWpfTextView(vsTextView);

            ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
        }
Ejemplo n.º 32
0
        public TextViewFilter(PythonEditorServices editorServices, IVsTextView vsTextView)
        {
            _editorServices = editorServices;
            _debugger       = (IVsDebugger)_editorServices.Site.GetService(typeof(IVsDebugger));

            vsTextView.GetBuffer(out _vsTextLines);
            _wpfTextView = _editorServices.EditorAdaptersFactoryService.GetWpfTextView(vsTextView);

            ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
        }
        internal void Initialize()
        {
            DTE dte = GetService(typeof(DTE)) as DTE;

            _debugEvents = new VsDebuggerEvents(dte, this);

            IVsDebugger vsd = GetService(typeof(IVsDebugger)) as IVsDebugger;
            int         hr  = vsd.AdviseDebuggerEvents(_debugEvents, out _debugEventsCookie);

            this.ContextMenuStrip = _contextMenuStrip;
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            VsDebugger = await this.GetServiceAsync(typeof(IVsDebugger)) as IVsDebugger;

            await RevitToolsCommand.InitializeAsync(this);
        }
Ejemplo n.º 35
0
        public void Dispose() {
            _timer?.Stop();
            _timer?.Dispose();
            _timer = null;

            if(_debuggerEventCookie != 0 && _debugger != null) {
                _debugger.UnadviseDebuggerEvents(_debuggerEventCookie);
                _debuggerEventCookie = 0;
                _debugger = null;
            }
        }
Ejemplo n.º 36
0
        public virtual void DebugLaunch(uint flags)
        {
            CCITracing.TraceCall();


            try {
                IVsDebugger d = (IVsDebugger)project.QueryService(typeof(IVsDebugger).GUID, typeof(IVsDebugger));

                VsDebugTargetInfo info = new VsDebugTargetInfo();
                info.cbSize = (uint)Marshal.SizeOf(info);
                info.dlo    = Microsoft.VisualStudio.Shell.Interop.DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
                if (this.node.HasAttribute("StartProgram") && this.node.GetAttribute("StartProgram").Length > 0)
                {
                    info.bstrExe = this.node.GetAttribute("StartProgram");
                }
                else
                {
                    info.bstrExe = this.project.GetOutputAssembly(node);
                }

                if (this.node.HasAttribute("WorkingDirectory") && this.node.GetAttribute("WorkingDirectory").Length > 0)
                {
                    info.bstrCurDir = this.node.GetAttribute("WorkingDirectory");
                }
                else
                {
                    info.bstrCurDir = Path.GetDirectoryName(info.bstrExe);
                }

                if (this.node.HasAttribute("CmdArgs") && this.node.GetAttribute("CmdArgs").Length > 0)
                {
                    info.bstrArg = this.node.GetAttribute("CmdArgs");
                }
                if (this.node.HasAttribute("RemoteDebugMachine") && this.node.GetAttribute("RemoteDebugMachine").Length > 0)
                {
                    info.bstrRemoteMachine = this.node.GetAttribute("RemoteDebugMachine");
                }

                info.fSendStdoutToOutputWindow = 0;
                info.clsidCustom = CLSID_ComPlusOnlyDebugEngine;
                info.grfLaunch   = flags;

                IntPtr ptr = Marshal.AllocCoTaskMem((int)info.cbSize);
                Marshal.StructureToPtr(info, ptr, false);
                try {
                    d.LaunchDebugTargets(1, ptr);
                } finally{
                    Marshal.FreeCoTaskMem(ptr);
                }
            }
            catch (Exception e) {
                throw new SystemException("Could not launch debugger - " + e.Message);
            }
        }
Ejemplo n.º 37
0
        public DataTipTextViewFilter(System.IServiceProvider serviceProvider, IVsTextView vsTextView)
        {
            _debugger = (IVsDebugger)NodejsPackage.GetGlobalService(typeof(IVsDebugger));
            vsTextView.GetBuffer(out _vsTextLines);

            var editorAdaptersFactory = serviceProvider.GetComponentModel().GetService <IVsEditorAdaptersFactoryService>();

            _wpfTextView = editorAdaptersFactory.GetWpfTextView(vsTextView);

            ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next));
        }
Ejemplo n.º 38
0
        public ToolWindowTracker() {
            _debugger = VsAppShell.Current.GetGlobalService<IVsDebugger>(typeof(IVsDebugger));
            if (_debugger != null) {
                _debugger.AdviseDebuggerEvents(this, out _debuggerEventCookie);

                _timer.Interval = new TimeSpan(0, 0, 10).TotalMilliseconds;
                _timer.AutoReset = true;
                _timer.Elapsed += OnElapsed;
                _timer.Start();
            }
        }
Ejemplo n.º 39
0
        private DataTipTextViewFilter(IWpfTextView textView, IVsEditorAdaptersFactoryService adapterService, IVsDebugger debugger) {
            Trace.Assert(textView.TextBuffer.ContentType.IsOfType(RContentTypeDefinition.ContentType));

            _textView = textView;
            _debugger = debugger;

            _vsTextView = adapterService.GetViewAdapter(textView);
            _vsTextView.AddCommandFilter(this, out _nextTarget);
            _vsTextView.GetBuffer(out _vsTextLines);

            textView.Properties.AddProperty(typeof(DataTipTextViewFilter), this);
        }
Ejemplo n.º 40
0
        public ReAttachDebugger(IReAttachPackage package)
        {
            _package = package;
            _debugger = package.GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            _dte = _package.GetService(typeof(SDTE)) as DTE2;
            if (_dte != null)
                _dteDebugger = _dte.Debugger as Debugger2;

            if (_package == null || _debugger == null || _dte == null || _dteDebugger == null)
            {
                _package.Reporter.ReportError(
                    "Unable to get required services for ReAttachDebugger in ctor.");
                return;
            }

            if (_debugger.AdviseDebuggerEvents(this, out _cookie) != VSConstants.S_OK)
                _package.Reporter.ReportError("ReAttach: AdviserDebuggerEvents failed.");

            if (_debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
                _package.Reporter.ReportError("AdviceDebugEventsCallback call failed in ReAttachDebugger ctor.");
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public DebuggerEventListener (EnvDTE.DTE dteService, IVsDebugger debuggerService, IDebuggerConnectionService debuggerConnectionService)
    {
      m_dteService = dteService;

      m_debuggerService = debuggerService;

      m_debuggerConnectionService = debuggerConnectionService;

      LoggingUtils.RequireOk (m_debuggerService.AdviseDebuggerEvents (this, out m_debuggerServiceCookie));

      LoggingUtils.RequireOk (m_debuggerService.AdviseDebugEventCallback (this));

      // 
      // Register required listener events and paired process function callbacks.
      // 

      m_eventCallbacks = new Dictionary<Guid, DebuggerEventListenerDelegate> ();

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.SessionCreate)), OnSessionCreate);

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.SessionDestroy)), OnSessionDestroy);

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.EngineCreate)), OnEngineCreate);

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.ProgramCreate)), OnProgramCreate);

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.ProgramDestroy)), OnProgramDestroy);

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.AttachComplete)), OnAttachComplete);

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.Error)), OnError);

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.DebuggerConnectionEvent)), OnDebuggerConnectionEvent);

      m_eventCallbacks.Add (ComUtils.GuidOf (typeof (DebugEngineEvent.DebuggerLogcatEvent)), OnDebuggerLogcatEvent);
    }
Ejemplo n.º 42
0
        public ReAttachDebugger(IReAttachPackage package)
        {
            _package = package;
            _debugger = package.GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            _dte = _package.GetService(typeof(SDTE)) as DTE2;
            if (_dte != null)
                _dteDebugger = _dte.Debugger as Debugger2;

            if (_package == null || _debugger == null || _dte == null || _dteDebugger == null)
            {
                _package.Reporter.ReportError(
                    "Unable to get required services for ReAttachDebugger in ctor.");
                return;
            }

            if (_debugger.AdviseDebuggerEvents(this, out _cookie) != VSConstants.S_OK)
                _package.Reporter.ReportError("ReAttach: AdviserDebuggerEvents failed.");

            if (_debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
                _package.Reporter.ReportError("AdviceDebugEventsCallback call failed in ReAttachDebugger ctor.");

            foreach (Engine engine in _dteDebugger.Transports.Item("Default").Engines)
                _engines.Add(Guid.Parse(engine.ID), engine.Name);
        }
Ejemplo n.º 43
0
 public DebugEventsHunter(IVsDebugger debugger)
 {
     _debugger = debugger;
 }
Ejemplo n.º 44
0
        // IDebugExceptionEvent2
        // Debugger core interfaces
        // http://msdn.microsoft.com/en-US/library/bb146305(v=VS.80).aspx
        // New Debugging stuff in Visual 2010, data tips, etc
        // http://msdn.microsoft.com/en-us/library/envdte90.debugger3_members.aspx
        // http://channel9.msdn.com/Shows/10-4/10-4-Episode-34-Debugger-Enhancements-and-Improvements
        public bool Register(EnvDTE.DTE dte, GanjiContext context)
        {
            _applicationObject = dte;

            m_debugger = Package.GetGlobalService(typeof(SVsShellDebugger)) as IVsDebugger;
            if (m_debugger != null)
            {
                HandleException.Debugger = m_debugger as IVsDebugger2;
                m_debugger.AdviseDebuggerEvents(this, out m_debugEventsCookie);
                m_debugger.AdviseDebugEventCallback(this);
            }
            return true;
        }
Ejemplo n.º 45
0
 internal DebuggerEvaluator(IVsDebugger debugger)
 {
     _debugger = debugger;
 }
Ejemplo n.º 46
0
 private static bool IsDebugging(IServiceProvider provider, IVsDebugger debugger) {
     return provider.GetUIThread().Invoke(() => {
         var mode = new[] { DBGMODE.DBGMODE_Design };
         return ErrorHandler.Succeeded(debugger.GetMode(mode)) && mode[0] != DBGMODE.DBGMODE_Design;
     });
 }
Ejemplo n.º 47
0
 public static DataTipTextViewFilter GetOrCreate(IWpfTextView textView, IVsEditorAdaptersFactoryService adapterService, IVsDebugger debugger)  {
     return textView.Properties.GetOrCreateSingletonProperty(() => new DataTipTextViewFilter(textView, adapterService, debugger));
 }
Ejemplo n.º 48
0
 internal IVsDebugger GetIVsDebugger()
 {
     if (this.debugger == null)
     {
         Guid guid = typeof(Microsoft.VisualStudio.Shell.Interop.IVsDebugger).GUID;
         this.debugger = this.GetService(typeof(IVsDebugger)) as IVsDebugger;
         if (this.debugger != null)
         {
             NativeMethods.ThrowOnFailure(debugger.AdviseDebuggerEvents(this, out this.cookie));
             DBGMODE[] mode = new DBGMODE[1];
             NativeMethods.ThrowOnFailure(debugger.GetMode(mode));
             this.dbgMode = mode[0];
         }
     }
     return debugger;
 }
Ejemplo n.º 49
0
        /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.Done"]/*' />
        /// <summary>
        /// Cleanup the sources, uiShell, shell, preferences and imageList objects
        /// and unregister this language service with VS.
        /// </summary>
        public virtual void Dispose() {
            OnActiveViewChanged(null);
            this.disposed = true;
            this.StopThread();
            this.lastActiveView = null;
            if (this.sources != null) {
                foreach (Source s in this.sources) {
                    s.Dispose();
                }
                this.sources.Clear();
                this.sources = null;
            }
            if (this.colorizers != null) {
                foreach (Colorizer c in this.colorizers) {
                    c.Dispose();
                }
                this.colorizers.Clear();
                this.colorizers = null;
            }

            if (this.codeWindowManagers != null) {
                foreach (CodeWindowManager m in this.codeWindowManagers) {
                    m.Close();
                }
                this.codeWindowManagers.Clear();
                this.codeWindowManagers = null;
            }

            if (this.preferences != null) {
                this.preferences.Dispose();
                this.preferences = null;
            }
            if (this.debugger != null && this.cookie != 0) {
                NativeMethods.ThrowOnFailure(this.debugger.UnadviseDebuggerEvents(this.cookie));
                this.cookie = 0;
                this.debugger = null;
            }
            if (this.task != null)
                this.task.Dispose();
            this.task = null;
            this.site = null;
        }
Ejemplo n.º 50
0
 /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.GetIVsDebugger"]/*' />
 public IVsDebugger GetIVsDebugger() {
     if (this.debugger == null) {
         Guid guid = typeof(Microsoft.VisualStudio.Shell.Interop.IVsDebugger).GUID;
         this.debugger = this.GetService(typeof(IVsDebugger)) as IVsDebugger;
         if (this.debugger != null) {
             NativeMethods.ThrowOnFailure(debugger.AdviseDebuggerEvents(this, out this.cookie));
         }
     }
     return debugger;
 }