Example #1
0
        private void DoRun(Dictionary <string, StoreType> args)
        {
            Debugger.BreakpointHandler bph = (bp) =>
            {
                if (bp.IsFake)
                {
                    this.Breakpoint.CoreBreakpoint = bp;
                    this.BreakpointHitNull();
                }
                else
                {
                    this.Breakpoint = _breakpoints[bp];
                    this.Breakpoint.CoreBreakpoint = bp;
                    this.BreakpointHit();
                }
                // Sync primitives, wait for user input (like Setp Into, Step Out, etc.)
                _autoRE.WaitOne();
            };
            _debugger.OnBreakpoint -= bph;
            _debugger.OnBreakpoint += bph;

            // Setup args
            string[]      values      = new string[args.Count];
            List <string> inOutValues = new List <string>();
            int           i           = 0;

            foreach (StoreType st in args.Values)
            {
                if (st.ArgType == ArgTypeEnum.In)
                {
                    if (st.Value.ToString().Equals("NULL", StringComparison.OrdinalIgnoreCase))
                    {
                        values[i] = "NULL";
                    }
                    else
                    {
                        values[i] = "'" + st.Value.ToString().Trim('\'') + "'";
                    }
                }
                else
                {
                    values[i] = string.Format("@dbg_var{0}", i);
                    if (st.ArgType == ArgTypeEnum.InOut)
                    {
                        inOutValues.Add(string.Format("{0} = '{1}'", values[i], st.Value.ToString()));
                    }
                }
                i++;
            }
            try
            {
                _debugger.Run(values, inOutValues.ToArray());
            }
            catch (ThreadAbortException) { }
            catch (Exception ex)
            {
                MessageBox.Show(_node.ParentWindow, string.Format("Error while debugging: {0}", ex.GetBaseException().Message), "Debugger Error");
                _events.ProgramDestroyed(_node);
            }
        }
Example #2
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);
        }
Example #3
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;
    }