Example #1
0
        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();
        }
Example #2
0
        /// <summary>
        /// Gets the files containing supporting information that were used when opening the current dump target.
        /// </summary>
        /// <param name="client">The debug client.</param>
        /// <param name="index">Specifies which file to describe. Index can take values between zero and the number of files minus one; the number of files can be found by using <see cref="IDebugClient4.GetNumberDumpFiles"/>.</param>
        /// <returns>Returns the file name.</returns>
        public static string GetDumpFile(this IDebugClient4 client, uint index)
        {
            ulong         handle;
            DebugDumpFile type;

            return(GetDumpFile(client, index, out handle, out type));
        }
Example #3
0
        /// <summary>
        /// Gets the files containing supporting information that were used when opening the current dump target.
        /// </summary>
        /// <param name="client">The debug client.</param>
        /// <param name="index">Specifies which file to describe. Index can take values between zero and the number of files minus one; the number of files can be found by using <see cref="IDebugClient4.GetNumberDumpFiles"/>.</param>
        /// <param name="handle">Receives the file handle of the file.</param>
        /// <param name="type">Receives the type of the file.</param>
        /// <returns>Returns the file name.</returns>
        public static string GetDumpFile(this IDebugClient4 client, uint index, out ulong handle, out DebugDumpFile type)
        {
            uint nameSize;

            client.GetDumpFileWide(index, null, 0, out nameSize, out handle, out type);

            StringBuilder buffer = new StringBuilder((int)nameSize);

            client.GetDumpFileWide(index, buffer, (uint)buffer.Capacity, out nameSize, out handle, out type);
            return(buffer.ToString());
        }
Example #4
0
        /// <summary>
        /// Gets all files containing supporting information that were used when opening the current dump target.
        /// The number of files can be found by using <see cref="IDebugClient4.GetNumberDumpFiles"/>.
        /// </summary>
        /// <param name="client">The debug client.</param>
        /// <returns>Returns array of file names.</returns>
        public static string[] GetDumpFiles(this IDebugClient4 client)
        {
            uint dumpCount = client.GetNumberDumpFiles();

            string[] dumps = new string[dumpCount];

            for (uint i = 0; i < dumpCount; i++)
            {
                dumps[i] = GetDumpFile(client, i);
            }
            return(dumps);
        }
Example #5
0
        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;
            }
        }