예제 #1
0
        int IVsTextViewFilter.GetDataTipText(TextSpan[] pSpan, out string pbstrText)
        {
            pbstrText = "";
            var dbgMode = new DBGMODE[1];

            if (debugger.GetMode(dbgMode) != VSConstants.S_OK ||
                dbgMode[0] != DBGMODE.DBGMODE_Break)
            {
                return(VSConstants.S_FALSE);
            }

            var startLine = buffer.CurrentSnapshot.GetLineFromLineNumber(pSpan[0].iStartLine);
            var offset    = startLine.Start.Position + pSpan[0].iStartIndex;

            var spans = new NormalizedSnapshotSpanCollection(
                new SnapshotSpan(buffer.CurrentSnapshot, offset, 1));

            var tags = GetTags(spans).Select(x => x.Tag).Cast <ExprTag>();

            var expr = tags.SelectMany(x => x.Exprs)
                       .Where(x => offset < x.LastSourceLocation.Offset + x.LastSourceLocation.Length)
                       .FirstOrDefault();

            if (expr == null)
            {
                return(VSConstants.S_FALSE);
            }

            var exprSpan = new Span(expr.FirstSourceLocation.Offset,
                                    expr.LastSourceLocation.Offset + expr.LastSourceLocation.Length
                                    - expr.FirstSourceLocation.Offset);
            var exprText = buffer.CurrentSnapshot.GetText(exprSpan);

            return(debugger.GetDataTipValue(textLines, pSpan, exprText, out pbstrText));
        }
예제 #2
0
        int IVsDebuggerEvents.OnModeChange(DBGMODE dbgmodeNew)
        {
            switch (dbgmodeNew)
            {
            case DBGMODE.DBGMODE_Run:
                if (DebuggedProcessId == 0)
                {
                    // switch mainthread

                    Process debuggedProcess = dte.Debugger.DebuggedProcesses.Cast <Process>().FirstOrDefault(proc => System.Diagnostics.Process.GetProcessById(proc.ProcessID).GetParent().ProcessName.Contains("VsDebugConsole"));
                    //if (System.Diagnostics.Process.GetProcessById(debuggedProcess.ProcessID).GetParent().ProcessName.Contains("VsDebugConsole"))
                    if (debuggedProcess != null)
                    {
                        DebuggedProcessId = debuggedProcess.ProcessID;
                        processMonitor    = new ProcessMonitor(DebuggedProcessId);
                        processMonitor.StartWatch();
                    }
                }
                break;

            case DBGMODE.DBGMODE_Design:
                Process debuggedProcesses = dte.Debugger.DebuggedProcesses.Cast <Process>().FirstOrDefault(process => process.ProcessID == DebuggedProcessId);
                if (DebuggedProcessId != 0 && debuggedProcesses is null)
                {
                    processMonitor.StopWatch();
                    processMonitor.KillChildProcesses();
                    processMonitor    = null;
                    DebuggedProcessId = 0;
                }
                break;
            }
            return((int)dbgmodeNew);
        }
예제 #3
0
        private void ShowMode(DBGMODE mode)
        {
            string msg = "";

            // Remove the DBGMODE.DBGMODE_Enc flag if present
            mode = mode & ~DBGMODE.DBGMODE_EncMask;

            switch (mode)
            {
            case DBGMODE.DBGMODE_Design:

                msg = "Entered mode: Design";
                break;

            case DBGMODE.DBGMODE_Break:

                msg = "Entered mode: Break";
                break;

            case DBGMODE.DBGMODE_Run:

                msg = "Entered mode: Run";
                break;
            }
            Debug.WriteLine(msg);
        }
예제 #4
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);
        }
예제 #5
0
        int IVsDebuggerEvents.OnModeChange(DBGMODE dbgmodeNew)
        {
            // Push actual handler activity to the UI thread, if not already there
            // Run Async is needed since this is an interface defined method that
            // isn't async aware.
            ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync( );
                DebugMode = dbgmodeNew.ToString( );
                PropertyChanged(this, DebugModeChangedEventArgs);
                if (dbgmodeNew != DBGMODE.DBGMODE_Break)
                {
                    return;
                }

                foreach (var knownReg in RegIdToViewModelMap.Values)
                {
                    knownReg.IsChanged = false;
                }

                var registers = await GetUpdatedRegistersAsync( );
                foreach (var reg in registers)
                {
                    RegIdToViewModelMap[reg.Id].Value = reg.Value;
                }
            });

            return(VSConstants.S_OK);
        }
예제 #6
0
        /// <summary>
        /// Called when one or more items are dragged over the target hierarchy or hierarchy window.
        /// </summary>
        /// <param name="grfKeyState">Current state of the keyboard keys and the mouse modifier buttons. See <seealso cref="IVsHierarchyDropDataTarget"/></param>
        /// <param name="itemid">Item identifier of the drop data target over which the item is being dragged</param>
        /// <param name="pdwEffect"> On entry, reference to the value of the pdwEffect parameter of the IVsHierarchy object, identifying all effects that the hierarchy supports.
        /// On return, the pdwEffect parameter must contain one of the effect flags that indicate the result of the drop operation. For a list of pwdEffects values, see <seealso cref="DragEnter"/></param>
        /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns>
        public override int DragOver(uint grfKeyState, uint itemid, ref uint pdwEffect)
        {
            pdwEffect = (uint)DropEffect.None;

            // Dragging items to a project that is being debugged is not supported
            // (see VSWhidbey 144785)
            DBGMODE dbgMode = VsShellUtilities.GetDebugMode(this.Site) & ~DBGMODE.DBGMODE_EncMask;

            if (dbgMode == DBGMODE.DBGMODE_Run || dbgMode == DBGMODE.DBGMODE_Break)
            {
                return(VSConstants.S_OK);
            }

            if (this.isClosed || this.site == null)
            {
                return(VSConstants.E_UNEXPECTED);
            }

            // We should also analyze if the node being dragged over can accept the drop.
            if (!this.CanTargetNodeAcceptDrop(itemid))
            {
                return(VSConstants.E_NOTIMPL);
            }

            if (this.dropDataType != DropDataType.None)
            {
                pdwEffect = (uint)this.QueryDropEffect(this.dropDataType, grfKeyState);
            }

            return(VSConstants.S_OK);
        }
예제 #7
0
        int IVsDebuggerEvents.OnModeChange(DBGMODE dbgmodeNew)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (dbgmodeNew.HasFlag(DBGMODE.DBGMODE_Run))
            {
                this.package.Telemetry.TrackEvent(Constants.EventDebugStart, this.viewModel.GetEntryTelemetryProperties());

                this.viewModel.IsDebugging = true;
                this.viewModel.ClearEntries();

                this.WaitForDebugOutputTextBuffer();
            }
            else if (dbgmodeNew.HasFlag(DBGMODE.DBGMODE_Break))
            {
                this.viewModel.IsDebugging = true;
            }
            else
            {
                this.package.Telemetry.TrackEvent(Constants.EventDebugEnd, this.viewModel.GetEntryTelemetryProperties(includeErrorCodes: true));
                this.viewModel.IsDebugging = false;
            }

            return(Constants.S_OK);
        }
        public int OnModeChange(DBGMODE dbgmodeNew)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            ThreadHelper.JoinableTaskFactory.RunAsync(() => RefreshAsync(dbgmodeNew));

            return(0);
        }
예제 #9
0
        public static DBGMODE GetInternalDebugMode(this IVsDebugger2 debugger)
        {
            DBGMODE[] mode = new DBGMODE[1];
            if (ErrorHandler.Failed(debugger.GetInternalDebugMode(mode)))
                return DBGMODE.DBGMODE_Design;

            return mode[0];
        }
예제 #10
0
 public int OnModeChange(DBGMODE dbgmodeNew)
 {
     if (dbgmodeNew == DBGMODE.DBGMODE_Run)
     {
         ReportWindowLayout();
     }
     return(VSConstants.S_OK);
 }
예제 #11
0
 public int OnModeChange(DBGMODE mode)
 {
     if (mode == DBGMODE.DBGMODE_Design)
     {
         _package.History.Save();
     }
     return(VSConstants.S_OK);
 }
예제 #12
0
        private void InitializeDebugMode()
        {
            var modeArray = new DBGMODE[1];

            Marshal.ThrowExceptionForHR(this.Debugger.GetMode(modeArray));

            _debugMode = ConvertDebugMode(modeArray[0]);
            OnDebugModeChanged();
        }
            public int GetDataTipText(IVsTextBuffer pBuffer, VsTextSpan[] pSpan, out string pbstrText)
            {
                using (Logger.LogBlock(FunctionId.Debugging_VsLanguageDebugInfo_GetDataTipText, CancellationToken.None))
                {
                    pbstrText = null;
                    if (pSpan == null || pSpan.Length != 1)
                    {
                        return(VSConstants.E_INVALIDARG);
                    }

                    int    result            = VSConstants.E_FAIL;
                    string pbstrTextInternal = null;

                    _waitIndicator.Wait(
                        title: ServicesVSResources.Debugger,
                        message: ServicesVSResources.Getting_DataTip_text,
                        allowCancel: true,
                        action: waitContext =>
                    {
                        var debugger        = _languageService.Debugger;
                        DBGMODE[] debugMode = new DBGMODE[1];

                        var cancellationToken = waitContext.CancellationToken;
                        if (ErrorHandler.Succeeded(debugger.GetMode(debugMode)) && debugMode[0] != DBGMODE.DBGMODE_Design)
                        {
                            var editorAdapters = _languageService.EditorAdaptersFactoryService;

                            var textSpan      = pSpan[0];
                            var subjectBuffer = editorAdapters.GetDataBuffer(pBuffer);

                            var textSnapshot = subjectBuffer.CurrentSnapshot;
                            var document     = textSnapshot.GetOpenDocumentInCurrentContextWithChanges();

                            if (document != null)
                            {
                                var spanOpt = textSnapshot.TryGetSpan(textSpan);
                                if (spanOpt.HasValue)
                                {
                                    var dataTipInfo = _languageDebugInfo.GetDataTipInfoAsync(document, spanOpt.Value.Start, cancellationToken).WaitAndGetResult(cancellationToken);
                                    if (!dataTipInfo.IsDefault)
                                    {
                                        var resultSpan = dataTipInfo.Span.ToSnapshotSpan(textSnapshot);
                                        string textOpt = dataTipInfo.Text;

                                        pSpan[0] = resultSpan.ToVsTextSpan();
                                        result   = debugger.GetDataTipValue((IVsTextLines)pBuffer, pSpan, textOpt, out pbstrTextInternal);
                                    }
                                }
                            }
                        }
                    });

                    pbstrText = pbstrTextInternal;
                    return(result);
                }
            }
예제 #14
0
        public static DBGMODE GetInternalDebugMode(this IVsDebugger2 debugger)
        {
            DBGMODE[] mode = new DBGMODE[1];
            if (ErrorHandler.Failed(debugger.GetInternalDebugMode(mode)))
            {
                return(DBGMODE.DBGMODE_Design);
            }

            return(mode[0]);
        }
        private async System.Threading.Tasks.Task RefreshAsync(DBGMODE dbgmodeNew)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            switch (dbgmodeNew)
            {
            case DBGMODE.DBGMODE_Break:
                VsUnityHierarchyCommand.Instance?.Refresh((object)null, (EventArgs)null);
                break;
            }
        }
예제 #16
0
        public static bool isExceptionThrown()
        {
            DebuggerService debuggerService = new DebuggerService();
            DBGMODE         dBGMODE         = VsShellUtilities.GetDebugMode(debuggerService);

            if (DBGMODE.DBGMODE_Break == dBGMODE)
            {
                return(true);
            }
            return(false);
        }
예제 #17
0
        public int OnModeChange(DBGMODE dbgmodeNew)
        {
            this.currentMode = dbgmodeNew;
            EventHandler <DBGMODE> handler = this.DebugModeChanged;

            if (handler != null)
            {
                handler(this, this.currentMode);
            }

            return(VSConstants.S_OK);
        }
 public int OnModeChange(DBGMODE dbgmodeNew)
 {
     if (dbgmodeNew == DBGMODE.DBGMODE_Break)
     {
         ProcessBreakMode();
     }
     else
     {
         ProcessRunMode();
     }
     return(0);
 }
 public int OnModeChange(DBGMODE dbgmodeNew)
 {
     if (dbgmodeNew == DBGMODE.DBGMODE_Break)
     {
         ProcessBreakMode();
     }
     else
     {
         ProcessRunMode();
     }
     return 0;
 }
예제 #20
0
 public int OnModeChange(DBGMODE mode)
 {
     if (mode == DBGMODE.DBGMODE_Run)
     {
         if (!s_IsInitialized)
         {
             s_Module = null;
             _        = Output.ClearAsync();
         }
     }
     return(VSConstants.S_OK);
 }
예제 #21
0
        private void DebugExec(string command)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var commandWindow = (IVsCommandWindow)serviceProvider.GetService(typeof(SVsCommandWindow));

            Assumes.Present(commandWindow);
            var atBreak = false;

            if (serviceProvider.GetService(typeof(SVsShellDebugger)) is IVsDebugger debugger)
            {
                var mode = new DBGMODE[1];
                if (debugger.GetMode(mode) == VSConstants.S_OK)
                {
                    atBreak = mode[0] == DBGMODE.DBGMODE_Break;
                }
            }

            string results = null;

            try
            {
                if (atBreak)
                {
                    commandWindow.ExecuteCommand(String.Format(CultureInfo.InvariantCulture, "Debug.EvaluateStatement -exec {0}", command));
                }
                else
                {
                    //results = await MIDebugCommandDispatcher.ExecuteCommand(command);
                }
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    e = e.InnerException;
                }

                commandWindow.Print($"Error: {e.Message}\r\n");
            }

            if (results != null && results.Length > 0)
            {
                // Make sure that we are printing whole lines
                if (!results.EndsWith("\n") && !results.EndsWith("\r\n"))
                {
                    results = results + "\n";
                }

                commandWindow.Print(results);
            }
        }
예제 #22
0
        public int OnModeChange(DBGMODE dbgmodeNew)
        {
            var currentDebugMode = _debugMode;

            _debugMode = ConvertDebugMode(dbgmodeNew);

            if (currentDebugMode != _debugMode)
            {
                this.OnDebugModeChanged();
            }

            return(VSConstants.S_OK);
        }
        public int OnModeChange(DBGMODE dbgmodeNew)
        {
            if (dbgmodeNew == DBGMODE.DBGMODE_Break)
            {
                OnBreak?.Invoke();
            }
            else if (dbgmodeNew == DBGMODE.DBGMODE_Design)
            {
                OnDebugEnd?.Invoke();
            }

            return(VSConstants.S_OK);
        }
예제 #24
0
        public static bool IsDebugMode()
        {
            IVsDebugger debugger = ThreadHelper.JoinableTaskFactory.Run(() => VS.Services.GetDebuggerAsync());

            DBGMODE[] mode = new DBGMODE[1];
            ErrorHandler.ThrowOnFailure(debugger.GetMode(mode));

            if (mode[0] != DBGMODE.DBGMODE_Design)
            {
                return(true);
            }

            return(false);
        }
예제 #25
0
        protected override void SetStatus()
        {
            Enabled = false;
            Visible = false;

            if (!RSession.IsHostRunning)
            {
                return;
            }

            var debugger = VsAppShell.Current.GetGlobalService <IVsDebugger>(typeof(SVsShellDebugger));

            if (debugger == null)
            {
                return;
            }

            var mode = new DBGMODE[1];

            if (debugger.GetMode(mode) < 0)
            {
                return;
            }

            if (mode[0] == DBGMODE.DBGMODE_Design)
            {
                if (_visibility == DebuggerCommandVisibility.DesignMode)
                {
                    Visible = _interactiveWorkflow.ActiveWindow != null;
                    Enabled = true;
                }
                return;
            }

            if ((_visibility & DebuggerCommandVisibility.DebugMode) > 0)
            {
                Visible = _interactiveWorkflow.ActiveWindow != null;

                if (mode[0] == DBGMODE.DBGMODE_Break)
                {
                    Enabled = (_visibility & DebuggerCommandVisibility.Stopped) > 0;
                    return;
                }
                if (mode[0] == DBGMODE.DBGMODE_Run)
                {
                    Enabled = (_visibility & DebuggerCommandVisibility.Run) > 0;
                    return;
                }
            }
        }
예제 #26
0
 ///--------------------------------------------------------------------------------------------
 /// <summary>
 /// Initialize and listen to debug mode changes
 /// </summary>
 ///--------------------------------------------------------------------------------------------
 internal void AdviseDebugger()
 {
     if (_site is System.IServiceProvider sp)
     {
         _debugger = sp.GetService <IVsDebugger, IVsDebugger>();
         if (_debugger != null)
         {
             _debugger.AdviseDebuggerEvents(this, out _debuggerCookie);
             var dbgMode = new DBGMODE[1];
             _debugger.GetMode(dbgMode);
             ((IVsDebuggerEvents)this).OnModeChange(dbgMode[0]);
         }
     }
 }
예제 #27
0
        public int OnModeChange(DBGMODE dbgmodeNew) {
            if (IsInBreakMode) {
                LeaveBreakMode?.Invoke(this, EventArgs.Empty);
            }

            IsInBreakMode = dbgmodeNew == DBGMODE.DBGMODE_Break;
            IsDebugging = dbgmodeNew != DBGMODE.DBGMODE_Design;

            if (IsInBreakMode) {
                EnterBreakMode?.Invoke(this, EventArgs.Empty);
            }

            return VSConstants.S_OK;
        }
예제 #28
0
        bool IDebuggerEventSink.QueryRuntimeFrozen()
        {
            var debugMode = new DBGMODE[1];
            int res       = VSConstants.S_FALSE;

            vsDebuggerThreadDispatcher
            .BeginInvoke(new Action(() => res = VsDebugger.GetMode(debugMode)), new object[0])
            .Wait();

            if (res != VSConstants.S_OK)
            {
                return(false);
            }
            return(debugMode[0] != DBGMODE.DBGMODE_Run);
        }
예제 #29
0
 internal void AdviseDebugger()
 {
     System.IServiceProvider sp = _site as System.IServiceProvider;
     if (sp != null)
     {
         _debugger = (IVsDebugger)sp.GetService(typeof(IVsDebugger));
         if (_debugger != null)
         {
             _debugger.AdviseDebuggerEvents(this, out _debuggerCookie);
             DBGMODE[] dbgMode = new DBGMODE[1];
             _debugger.GetMode(dbgMode);
             ((IVsDebuggerEvents)this).OnModeChange(dbgMode[0]);
         }
     }
 }
예제 #30
0
        public int OnModeChange(DBGMODE dbgmodeNew)
        {
            switch (dbgmodeNew)
            {
            case DBGMODE.DBGMODE_Run:
                dynamicCmdMenuCommand.Enabled = false;
                break;

            case DBGMODE.DBGMODE_Design:
                dynamicCmdMenuCommand.Enabled = true;
                break;
            }

            return(VSConstants.S_OK);
        }
예제 #31
0
        public int OnModeChange(DBGMODE mode)
        {
            switch (mode)
            {
            case DBGMODE.DBGMODE_Run:
                _recording = true;
                break;

            case DBGMODE.DBGMODE_Design:
                _recording = false;
                _package.History.Save();
                break;
            }
            return(VSConstants.S_OK);
        }
예제 #32
0
        /// <summary>
        /// Need to know when debugging starts/stops
        /// </summary>
        private void HookDebugEvents()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (this.GetService(typeof(IVsDebugger)) is IVsDebugger debugger)
            {
                this.debuggerForCookie = debugger;
                this.debuggerForCookie.AdviseDebuggerEvents(this, out this.debugCookie);

                DBGMODE[] dbgMode = new DBGMODE[1];
                if (ErrorHandler.Succeeded(debugger.GetMode(dbgMode)))
                {
                    this.viewModel.IsDebugging = dbgMode[0].HasFlag(DBGMODE.DBGMODE_Run) || dbgMode[0].HasFlag(DBGMODE.DBGMODE_Break);
                }
            }
        }
예제 #33
0
        /// <summary>
        /// Initialize and listen to debug mode changes
        /// </summary>
        internal void AdviseDebugger()
        {
            if (_site is System.IServiceProvider sp)
            {
#pragma warning disable RS0030 // Do not used banned APIs
                _debugger = sp.GetService <IVsDebugger, IVsDebugger>();
#pragma warning restore RS0030 // Do not used banned APIs
                if (_debugger != null)
                {
                    _debugger.AdviseDebuggerEvents(this, out _debuggerCookie);
                    var dbgMode = new DBGMODE[1];
                    _debugger.GetMode(dbgMode);
                    ((IVsDebuggerEvents)this).OnModeChange(dbgMode[0]);
                }
            }
        }
예제 #34
0
 public int OnModeChange(DBGMODE dbgmodeNew)
 {
     return VSConstants.S_OK;
 }
예제 #35
0
 public int OnModeChange(DBGMODE mode)
 {
     if (mode == DBGMODE.DBGMODE_Design)
         _package.History.Save();
     return VSConstants.S_OK;
 }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    #region IVsDebuggerEvents Members

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int OnModeChange (DBGMODE dbgmodeNew)
    {
      LoggingUtils.Print ("[DebuggerEventListener] OnModeChange: " + dbgmodeNew.ToString ());

      switch (dbgmodeNew)
      {
        case DBGMODE.DBGMODE_Design:
        case DBGMODE.DBGMODE_Break:
        case DBGMODE.DBGMODE_Run:
        {
          break;
        }
      }

      return VSConstants.S_OK;
    }
예제 #37
0
        private async void MIDebugExecAsync(string command)
        {
            var commandWindow = (IVsCommandWindow)GetService(typeof(SVsCommandWindow));
            bool atBreak = false;
            var debugger = GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            if (debugger != null)
            {
                DBGMODE[] mode = new DBGMODE[1];
                if (debugger.GetMode(mode) == MIDebugEngine.Constants.S_OK)
                {
                    atBreak = mode[0] == DBGMODE.DBGMODE_Break;
                }
            }

            string results = null;

            try
            {
                if (atBreak)
                {
                    commandWindow.ExecuteCommand(String.Format(CultureInfo.InvariantCulture, "Debug.EvaluateStatement -exec {0}", command));
                }
                else
                {
                    results = await MIDebugCommandDispatcher.ExecuteCommand(command);
                }
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                    e = e.InnerException;

                UnexpectedMIResultException miException = e as UnexpectedMIResultException;
                string message;
                if (miException != null && miException.MIError != null)
                    message = miException.MIError;
                else
                    message = e.Message;

                commandWindow.Print(string.Format("Error: {0}\r\n", message));
                return;
            }

            if (results != null && results.Length > 0)
            {
                // Make sure that we are printing whole lines
                if (!results.EndsWith("\n") && !results.EndsWith("\r\n"))
                {
                    results = results + "\n";
                }

                commandWindow.Print(results);
            }
        }
예제 #38
0
        public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, 
			IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent, uint attributes)
        {
            // _package.Reporter.ReportTrace(TypeHelper.GetDebugEventTypeName(debugEvent));

            if (!(debugEvent is IDebugProcessCreateEvent2) &&
                !(debugEvent is IDebugProcessDestroyEvent2))
                return VSConstants.S_OK;

            var target = GetTargetFromProcess(process);
            if (target == null)
            {
                _package.Reporter.ReportWarning("Can't find target from process {0} ({1}). Event: {2}.",
                    process.GetName(), process.GetProcessId(), TypeHelper.GetDebugEventTypeName(debugEvent));
                return VSConstants.S_OK;
            }

            if (debugEvent is IDebugProcessCreateEvent2)
            {
                var engines = target.Engines.Where(e => _engines.ContainsKey(e)).Select(e => _engines[e]).ToArray();

                var mode = new DBGMODE[1];
                _debugger.GetMode(mode);
                if (mode[0] == DBGMODE.DBGMODE_Design)
                    return VSConstants.S_OK;

                target.IsAttached = true;
                _package.History.Items.AddFirst(target);
                _package.Ui.Update();
            }
            else
            {
                target.IsAttached = false;
                _package.Ui.Update();
            }

            return VSConstants.S_OK;
        }
 int IVsUIShell.OnModeChange(DBGMODE dbgmodeNew)
 {
     throw new NotImplementedException();
 }
예제 #40
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;
 }
예제 #41
0
 public int OnModeChange(DBGMODE dbgmodeNew) {
     if(dbgmodeNew == DBGMODE.DBGMODE_Run) {
         ReportWindowLayout();
     }
     return VSConstants.S_OK;
 }
예제 #42
0
 public int GetMode(DBGMODE[] pdbgmode) {
     pdbgmode[0] = DBGMODE.DBGMODE_Design;
     return VSConstants.S_OK;
 }
예제 #43
0
 /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.OnModeChange"]/*' />
 public virtual int OnModeChange(DBGMODE dbgmodeNew) {
     this.dbgMode = dbgmodeNew;
     return NativeMethods.S_OK;
 }
예제 #44
0
 public virtual int OnModeChange(DBGMODE dbgmodeNew);
		// ~IVsSolutionEvents

		// IVsDebuggerEvents
		public virtual int OnModeChange(DBGMODE dbgmodeNew)
		{
			Schedule_UpdateWindowTitle();
			return VSConstants.S_OK;
		}
예제 #46
0
 public int GetMode(DBGMODE[] pdbgmode) {
     pdbgmode[0] = Mode;
     return VSConstants.S_OK;
 }
예제 #47
0
        /// <include file='doc\VsShellUtilities.uex' path='docs/doc[@for="VsShellUtilities.GetDebugMode"]/*' />
        /// <devdoc>
        /// Get debug mode of the shell (design/break/shell).
        /// </devdoc>
        /// <param name="serviceProvider">The service provider.</param>
        /// <returns>A DBGMODE enumeration.</returns>
        public static DBGMODE GetDebugMode(IServiceProvider serviceProvider)
        {
            DBGMODE[] dbgmode = new DBGMODE[1] { DBGMODE.DBGMODE_Design };

            if (serviceProvider == null)
            {
                throw new ArgumentException("serviceProvider");
            }

            IVsDebugger debugger = serviceProvider.GetService(typeof(IVsDebugger)) as IVsDebugger;

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

            try
            {
                ErrorHandler.ThrowOnFailure(debugger.GetMode(dbgmode));
            }
            catch (COMException e)
            {
                Trace.WriteLine("Exception :" + e.Message);
            }

            return dbgmode[0];
        }
예제 #48
0
 public int OnModeChange(DBGMODE mode)
 {
     Log.Instance.Clear();
     switch (mode)
     {
         case DBGMODE.DBGMODE_Design:
             AttachCenter.Instance.Unfreeze();
             Storage.Instance.Persist();
             break;
     }
     return VSConstants.S_OK;
 }
        void GetVariableValues(VarValues var_values)
        {
            DTE2 dte = (DTE2)m_Package.GetInterface(typeof(DTE));
            IVsSolution vs_solution = (IVsSolution)m_Package.GetInterface(typeof(IVsSolution));
            string temp_solution_dir, temp_solution_options;
            if (VSConstants.S_OK != vs_solution.GetSolutionInfo(out temp_solution_dir, out var_values.sln_path, out temp_solution_options) || var_values.sln_path == null)
                var_values.sln_path = "";

            IVsDebugger debugger = (IVsDebugger)m_Package.GetInterface(typeof(IVsDebugger));
            DBGMODE[] adbgmode = new DBGMODE[] { DBGMODE.DBGMODE_Design };
            if (VSConstants.S_OK != debugger.GetMode(adbgmode))
                adbgmode[0] = DBGMODE.DBGMODE_Design;
            var_values.dbgmode = adbgmode[0] & ~DBGMODE.DBGMODE_EncMask;

            var_values.sln_dirty = !dte.Solution.Saved;

            try
            {
                SolutionConfiguration2 active_cfg = (SolutionConfiguration2)dte.Solution.SolutionBuild.ActiveConfiguration;
                if (active_cfg != null)
                {
                    var_values.configuration = active_cfg.Name == null ? "" : active_cfg.Name; ;
                    var_values.platform = active_cfg.PlatformName == null ? "" : active_cfg.PlatformName;
                }
            }
            catch (System.Exception ex)
            {
                var_values.exceptions.Add(ex);
            }

            try
            {
                Project startup_project = GetStartupProject(dte.Solution);
                if (startup_project != null)
                {
                    var_values.startup_proj = startup_project.Name;
                    var_values.startup_proj_path = startup_project.FullName;
                    var_values.startup_proj_dirty = !startup_project.Saved;
                }
            }
            catch (System.Exception ex)
            {
                var_values.exceptions.Add(ex);
            }

            try
            {
                Document active_document = dte.ActiveDocument;
                if (active_document != null)
                {
                    var_values.doc_path = active_document.FullName;
                    var_values.doc_dirty = !active_document.Saved;
                }
            }
            catch (System.Exception ex)
            {
                var_values.exceptions.Add(ex);
            }

            try
            {
                foreach (Document doc in dte.Documents)
                {
                    if (!doc.Saved)
                    {
                        var_values.any_doc_dirty = true;
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                var_values.exceptions.Add(ex);
            }

            try
            {
                foreach (Project proj in dte.Solution.Projects)
                {
                    if (!proj.Saved)
                    {
                        var_values.any_proj_dirty = true;
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                var_values.exceptions.Add(ex);
            }

            try
            {
                var_values.wnd_minimized = m_Package.VSMainWindow.Minimized;
                var_values.wnd_foreground = m_Package.VSMainWindow.IsForegroundWindow();
                var_values.app_active = m_Package.VSMainWindow.IsAppActive;
            }
            catch (System.Exception ex)
            {
                var_values.exceptions.Add(ex);
            }

            IntPtr active_wnd = GetActiveWindow();
            if (active_wnd != IntPtr.Zero)
            {
                var_values.active_wnd_title = GetWindowText(active_wnd);
                var_values.active_wnd_class = GetWindowClassName(active_wnd);
            }

            var_values.orig_title = m_Package.VSMainWindow.OriginalTitle;

            try
            {
                var_values.cmdline = Marshal.PtrToStringAuto(GetCommandLine());
            }
            catch (System.Exception ex)
            {
                var_values.exceptions.Add(ex);
            }
        }
        //~ Methods ..........................................................
        // ------------------------------------------------------
        /// <summary>
        /// Called when the debugger's mode changes.
        /// </summary>
        /// <param name="dbgmodeNew">
        /// The new debugger mode.
        /// </param>
        /// <returns>
        /// S_OK on success, otherwise an error code.
        /// </returns>
        public int OnModeChange(DBGMODE dbgmodeNew)
        {
            if (dbgmodeNew == DBGMODE.DBGMODE_Design)
            {
                if (startingTestRun)
                {
                    startingTestRun = false;

                    // Update the CxxTest Results tool window once execution
                    // is complete.

                    CxxTestPackage.Instance.TryToRefreshTestResultsWindow();
                }
            }

            return VSConstants.S_OK;
        }
 public int OnModeChange( DBGMODE dbgmodeNew )
 {
     Logger.Debug( string.Empty );
     return VSConstants.S_OK;
 }