private void Initialize() { _debugger = CreateDebuggerClient(); _control = _debugger as IDebugControl4; _symbols = _debugger as IDebugSymbols4; _systemObjects = _debugger as IDebugSystemObjects3; _advanced = _debugger as IDebugAdvanced3; _spaces = _debugger as IDebugDataSpaces4; // in case previous debugging session hasn't finished correctly // some leftover breakpoints may exist (even if debugging target has changed) _control.ClearBreakpoints(); _requestHelper = new RequestHelper(_advanced, _spaces, _symbols); _commandExecutor = new CommandExecutor(_control); _output = new OutputCallbacks(); _callbacks = new EventCallbacks(_control); _callbacks.BreakpointHit += OnBreakpoint; _callbacks.ExceptionHit += OnException; _callbacks.BreakHappened += OnBreak; _callbacks.ThreadStarted += OnThreadStarted; _callbacks.ThreadFinished += OnThreadFinished; _callbacks.ProcessExited += OnProcessExited; _debugger.SetEventCallbacks(_callbacks); _debugger.SetOutputCallbacks(_output); _debugger.SetInputCallbacks(new InputCallbacks()); _visualizers = new VisualizerRegistry(new DefaultVisualizer(_requestHelper, _symbols, _output)); InitializeHandlers(); }
private void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { _cancel.Cancel(); if (_debuggerThread != null) _debuggerThread.Join(TimeSpan.FromMilliseconds(100)); if (_callbacks != null) { _callbacks.BreakpointHit -= OnBreakpoint; _callbacks.ExceptionHit -= OnException; _callbacks.BreakHappened -= OnBreak; _callbacks.ThreadFinished -= OnThreadFinished; _callbacks.ThreadStarted -= OnThreadStarted; _callbacks.ProcessExited -= OnProcessExited; } if (_debugger != null) { _debugger.EndSession(DEBUG_END.ACTIVE_TERMINATE); _debugger.SetEventCallbacks(null); _debugger.SetOutputCallbacks(null); _debugger.SetInputCallbacks(null); } _callbacks = null; _messages.Dispose(); } if (_debugger != null) { while (Marshal.ReleaseComObject(_debugger) > 0) { } } _debugger = null; _control = null; _symbols = null; _spaces = null; _systemObjects = null; _advanced = null; _requestHelper = null; _isDisposed = true; } }