Example #1
0
        private void ApplyStateToSession(ExceptionBreakState state)
        {
            const int SkippedExceptionLogLimit = 25;

            _logger.WriteLine("Manager: Applying {0} to debug session.", state);
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var newExceptionState = (state == ExceptionBreakState.BreakOnAll)
                                  ? (uint)VSExceptionStateStopAll
                                  : (uint)VSExceptionStateStopNotSet;

            var guid = Guid.Empty;
            var hr   = Session.RemoveAllSetExceptions(ref guid);

            if (hr != VSConstants.S_OK)
            {
                Marshal.ThrowExceptionForHR(hr);
            }

            var updated = new EXCEPTION_INFO[1];
            var skippedExceptionCount = 0;

            foreach (var exception in _exceptionCache)
            {
                if (_ignorePredicate(exception.bstrExceptionName))
                {
                    if (skippedExceptionCount < SkippedExceptionLogLimit)
                    {
                        _logger.WriteLine("  Skipped exception {0} (matches ignore rule).", exception.bstrExceptionName);
                    }

                    skippedExceptionCount += 1;
                    continue;
                }

                updated[0] = new EXCEPTION_INFO {
                    guidType          = exception.guidType,
                    bstrExceptionName = exception.bstrExceptionName,
                    dwState           = newExceptionState
                };

                hr = Session.SetException(updated);
                if (hr != VSConstants.S_OK)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
            }

            if (skippedExceptionCount > SkippedExceptionLogLimit)
            {
                _logger.WriteLine("  Skipped {0} more exceptions (match ignore rule).", skippedExceptionCount - SkippedExceptionLogLimit);
            }

            stopwatch.Stop();
            _logger.WriteLine("  Finished in {0}ms.", stopwatch.ElapsedMilliseconds);
        }
        public ExceptionBreakManager(DebugSessionManager sessionManager, Func<string, bool> ignorePredicate, IDiagnosticLogger logger) {
            _sessionManager = sessionManager;
            _ignorePredicate = ignorePredicate;
            _logger = logger;

            if (Session != null)
                _currentState = GetStateFromSession();
            _sessionManager.DebugSessionChanged += sessionManager_DebugSessionChanged;
        }
Example #3
0
        public ExceptionBreakManager(DebugSessionManager sessionManager, Func <string, bool> ignorePredicate, IDiagnosticLogger logger)
        {
            _sessionManager  = sessionManager;
            _ignorePredicate = ignorePredicate;
            _logger          = logger;

            if (Session != null)
            {
                _currentState = GetStateFromSession();
            }
            _sessionManager.DebugSessionChanged += sessionManager_DebugSessionChanged;
        }
 public void RefreshCurrentState() {
     // not using property here as it would try to re-apply state
     _currentState = GetStateFromSession();
     CurrentStateChanged(this, EventArgs.Empty);
 }
        private void ApplyStateToSession(ExceptionBreakState state) {
            const int SkippedExceptionLogLimit = 25;

            _logger.WriteLine("Manager: Applying {0} to debug session.", state);
            var stopwatch = new Stopwatch();
            stopwatch.Start();

            var newExceptionState = (state == ExceptionBreakState.BreakOnAll)
                                  ? (uint)VSExceptionStateStopAll
                                  : (uint)VSExceptionStateStopNotSet;

            var guid = Guid.Empty;
            var hr = Session.RemoveAllSetExceptions(ref guid);
            if (hr != VSConstants.S_OK)
                Marshal.ThrowExceptionForHR(hr);

            var updated = new EXCEPTION_INFO[1];
            var skippedExceptionCount = 0;
            foreach (var exception in _exceptionCache) {
                if (_ignorePredicate(exception.bstrExceptionName)) {
                    if (skippedExceptionCount < SkippedExceptionLogLimit)
                        _logger.WriteLine("  Skipped exception {0} (matches ignore rule).", exception.bstrExceptionName);

                    skippedExceptionCount += 1;
                    continue;
                }

                updated[0] = new EXCEPTION_INFO {
                    guidType = exception.guidType,
                    bstrExceptionName = exception.bstrExceptionName,
                    dwState = newExceptionState
                };

                hr = Session.SetException(updated);
                if (hr != VSConstants.S_OK)
                    Marshal.ThrowExceptionForHR(hr);
            }

            if (skippedExceptionCount > SkippedExceptionLogLimit)
                _logger.WriteLine("  Skipped {0} more exceptions (match ignore rule).", skippedExceptionCount - SkippedExceptionLogLimit);

            stopwatch.Stop();
            _logger.WriteLine("  Finished in {0}ms.", stopwatch.ElapsedMilliseconds);
        }
Example #6
0
 public void RefreshCurrentState()
 {
     // not using property here as it would try to re-apply state
     _currentState = GetStateFromSession();
     CurrentStateChanged(this, EventArgs.Empty);
 }