internal AD7Breakpoint(AD7ProgramNode node, AD7Events callback) { Debug.WriteLine("AD7Breakpoint: ctor"); _node = node; _callback = callback; _breakpointRequest = null; }
public AD7Breakpoint(AD7ProgramNode node, AD7Events callback, IDebugBreakpointRequest2 breakpointRequest) { Debug.WriteLine("AD7Breakpoint: ctor"); _node = node; _callback = callback; _breakpointRequest = breakpointRequest; BP_REQUEST_INFO[] requestInfo = new BP_REQUEST_INFO[1]; _breakpointRequest.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_BPLOCATION | enum_BPREQI_FIELDS.BPREQI_CONDITION, requestInfo); _bpRequestInfo = requestInfo[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); }
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; }
int IDebugEngineLaunch2.LaunchSuspended(string pszServer, IDebugPort2 pPort, string pszExe, string pszArgs, string pszDir, string bstrEnv, string pszOptions, enum_LAUNCH_FLAGS dwLaunchFlags, uint hStdInput, uint hStdOutput, uint hStdError, IDebugEventCallback2 pCallback, out IDebugProcess2 ppProcess) { Debug.WriteLine("AD7Engine LaunchSuspended"); ppProcess = new AD7Process(pPort); _node = (ppProcess as AD7Process).Node; _node.FileName = pszExe; _node.ConnectionString = pszArgs; _events = new AD7Events(this, pCallback); // Gets active window handler to use in modals IntPtr handler = GetForegroundWindow(); _node.ParentWindow = new System.Windows.Forms.NativeWindow(); _node.ParentWindow.AssignHandle(handler); return(VSConstants.S_OK); }
private DebuggerManager(AD7Events events, AD7ProgramNode node, AD7Breakpoint breakpoint) { _breakpoints = new Dictionary <Breakpoint, AD7Breakpoint>(new BreakpointDictionaryComparer()); _events = events; _node = node; _breakpoint = breakpoint; _debugger = new Debugger(); _autoRE = new AutoResetEvent(false); if (string.IsNullOrEmpty(_node.ConnectionString)) { throw new Exception("Debugger expected a non-null connection string"); } _connection = new MySqlConnection(_node.ConnectionString); _debugger.Connection = new MySqlConnection(_connection.ConnectionString); _debugger.UtilityConnection = new MySqlConnection(_connection.ConnectionString); _debugger.Connection.Open(); _debugger.OnStartDebugger += () => { _debugger.CurrentScope.FileName = this.tempFileName; }; Moniker = _node.FileName; _debugger.SqlInput = _SpBody; }
/// <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); }
int IDebugEngineLaunch2.LaunchSuspended(string pszServer, IDebugPort2 pPort, string pszExe, string pszArgs, string pszDir, string bstrEnv, string pszOptions, enum_LAUNCH_FLAGS dwLaunchFlags, uint hStdInput, uint hStdOutput, uint hStdError, IDebugEventCallback2 pCallback, out IDebugProcess2 ppProcess) { Debug.WriteLine("AD7Engine LaunchSuspended"); ppProcess = new AD7Process(pPort); _node = (ppProcess as AD7Process).Node; _node.FileName = pszExe; _node.ConnectionString = pszArgs; _events = new AD7Events(this, pCallback); // Gets active window handler to use in modals IntPtr handler = GetForegroundWindow(); _node.ParentWindow = new System.Windows.Forms.NativeWindow(); _node.ParentWindow.AssignHandle(handler); return VSConstants.S_OK; }