示例#1
0
        int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
        {
            Debug.WriteLine("AD7Engine Attach");
            Guid id;

            if ((DebuggerManager.Instance != null) && (DebuggerManager.Instance.Debugger.IsRunning))
            {
                // If already running, abort.
                MessageBox.Show("Cannot start MySql Debugger. A MySql Debug session is already running", "Error");
                return(HRESULT.E_ATTACH_FAILED_ABORT_SILENTLY);
            }

            rgpPrograms[0].GetProgramId(out id);
            if (id == Guid.Empty)
            {
                return(VSConstants.E_NOTIMPL);
            }

            _events = new AD7Events(this, pCallback);

            try
            {
                DebuggerManager.Init(_events, _node, _breakpoint);
            }
            catch (Exception ex)
            {
                MessageBox.Show(_node.ParentWindow, ex.GetBaseException().Message, "Debugger Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(HRESULT.E_ATTACH_FAILED_ABORT_SILENTLY);
            }

            System.Threading.Thread thread = new System.Threading.Thread(() =>
            {
                DebuggerManager debugger        = DebuggerManager.Instance;
                _node.Debugger                  = debugger;
                debugger.SteppingType           = SteppingTypeEnum.StepInto;
                debugger.Breakpoint             = new AD7Breakpoint(_node, _events);
                debugger.OnEndDebugger         += () => { _events.ProgramDestroyed(_node); };
                debugger.Debugger.RestoreAtExit = true;
                debugger.Run();
            });
            thread.SetApartmentState(System.Threading.ApartmentState.STA);
            thread.Start();

            _node.Id = id;
            _events.EngineCreated();
            _events.ProgramCreated(_node);
            _events.EngineLoaded();
            _events.DebugEntryPoint();

            return(VSConstants.S_OK);
        }
示例#2
0
 /// <summary>
 /// Reinitializes the instance of debugger manager for a new debugging session.
 /// </summary>
 public static void Init(AD7Events events, AD7ProgramNode node, AD7Breakpoint breakpoint)
 {
     Instance = new DebuggerManager(events, node, breakpoint);
 }