Exemplo n.º 1
0
        public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
        {
            if (celtPrograms == 0)
                return VSConstants.S_OK;

            if (pCallback == null)
                throw new ArgumentNullException("pCallback");
            if (rgpPrograms == null || rgpPrograms.Length < celtPrograms)
                throw new ArgumentException();
            if (rgpProgramNodes == null || rgpProgramNodes.Length < celtPrograms)
                throw new ArgumentException();

            if (celtPrograms > 1)
                throw new NotImplementedException();

            if (dwReason != enum_ATTACH_REASON.ATTACH_REASON_LAUNCH)
                throw new NotImplementedException();

            JavaDebugProgram program = rgpProgramNodes[0] as JavaDebugProgram;
            if (program == null)
                throw new NotSupportedException();

            lock (_programs)
            {
                _programs.Add(program);
            }

            DebugEvent @event = new DebugEngineCreateEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, this);
            pCallback.Event(this, program.GetProcess(), program, null, @event);

            program.InitializeDebuggerChannel(this, pCallback);
            return VSConstants.S_OK;
        }
Exemplo n.º 2
0
        public static int GetProcessId(IDebugProgram2 program)
        {
            IDebugProcess2 process;
            RequireOk(program.GetProcess(out process));

            return GetProcessId(process);
        }
Exemplo n.º 3
0
        // Attach the debug engine to a program. 
        int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason)
        {
            int processId = EngineUtils.GetProcessId(rgpPrograms[0]);
            if (processId == 0)
            {
                return VSConstants.E_NOTIMPL;
            }

            pID = (uint)processId;

            events = ad7Callback;

            EngineUtils.RequireOk(rgpPrograms[0].GetProgramId(out m_ad7ProgramId));

            AD7EngineCreateEvent.Send(this);

            AD7ProgramCreateEvent.Send(this);

            debugThread = new AD7Thread(this);

            AD7ThreadCreateEvent.Send(this);

            // This event is optional
            AD7LoadCompleteEvent.Send(this);
           

            return VSConstants.S_OK;
        }
Exemplo n.º 4
0
        public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, 
			IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent, uint attributes)
        {
            if (!(debugEvent is IDebugProcessCreateEvent2) &&
                !(debugEvent is IDebugProcessDestroyEvent2))
                return VSConstants.S_OK;

            var target = GetTargetFromProcess(process);
            if (target == null)
            {
                _package.Reporter.ReportWarning("Can't find target from process {0} ({1}). Event: {2}.",
                    process.GetName(), process.GetProcessId(), TypeHelper.GetDebugEventTypeName(debugEvent));
                return VSConstants.S_OK;
            }

            if (debugEvent is IDebugProcessCreateEvent2)
            {
                target.IsAttached = true;
                _package.History.Items.AddFirst(target);
                _package.Ui.Update();
            }
            else
            {
                target.IsAttached = false;
                _package.Ui.Update();
            }

            return VSConstants.S_OK;
        }
Exemplo n.º 5
0
    public void Send(IDebugEvent2 eventObject, string iidEvent, IDebugProgram2 program, IDebugThread2 thread) {
      uint attributes;
      var riidEvent = new Guid(iidEvent);

      EngineUtils.RequireOk(eventObject.GetAttributes(out attributes));
      EngineUtils.RequireOk(m_ad7Callback.Event(m_engine, null, program, thread, eventObject, ref riidEvent, attributes));
    }
Exemplo n.º 6
0
        public BreakpointRequestInfo(IDebugBreakpointRequest2 request)
        {
            Contract.Requires<ArgumentNullException>(request != null, "request");

            _request = request;

            IDebugBreakpointRequest3 request3 = request as IDebugBreakpointRequest3;
            BP_REQUEST_INFO2[] requestInfo2 = new BP_REQUEST_INFO2[1];
            if (request3 != null && ErrorHandler.Succeeded(request3.GetRequestInfo2(enum_BPREQI_FIELDS.BPREQI_ALLFIELDS, requestInfo2)))
            {
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_PROGRAM) != 0)
                    _program = requestInfo2[0].pProgram;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_THREAD) != 0)
                    _thread = requestInfo2[0].pThread;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_LANGUAGE) != 0)
                    _languageGuid = requestInfo2[0].guidLanguage;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_VENDOR) != 0)
                    _vendorGuid = requestInfo2[0].guidVendor;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_CONSTRAINT) != 0)
                    _constraint = requestInfo2[0].bstrConstraint;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_PROGRAMNAME) != 0)
                    _programName = requestInfo2[0].bstrProgramName;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_THREADNAME) != 0)
                    _threadName = requestInfo2[0].bstrThreadName;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_TRACEPOINT) != 0)
                    _tracepoint = requestInfo2[0].bstrTracepoint;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_FLAGS) != 0)
                    _flags = requestInfo2[0].dwFlags;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_PASSCOUNT) != 0)
                    _passCount = requestInfo2[0].bpPassCount;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0)
                    _condition = requestInfo2[0].bpCondition;
                if ((requestInfo2[0].dwFields & enum_BPREQI_FIELDS.BPREQI_BPLOCATION) != 0)
                    _location = BreakpointLocation.FromNativeForm(requestInfo2[0].bpLocation, true);
            }
            else
            {
                BP_REQUEST_INFO[] requestInfo = new BP_REQUEST_INFO[1];
                ErrorHandler.ThrowOnFailure(request.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_ALLFIELDS, requestInfo));
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_PROGRAM) != 0)
                    _program = requestInfo[0].pProgram;
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_THREAD) != 0)
                    _thread = requestInfo[0].pThread;
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_LANGUAGE) != 0)
                    _languageGuid = requestInfo[0].guidLanguage;
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_PROGRAMNAME) != 0)
                    _programName = requestInfo[0].bstrProgramName;
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_THREADNAME) != 0)
                    _threadName = requestInfo[0].bstrThreadName;
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_FLAGS) != 0)
                    _flags = requestInfo[0].dwFlags;
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_PASSCOUNT) != 0)
                    _passCount = requestInfo[0].bpPassCount;
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0)
                    _condition = requestInfo[0].bpCondition;
                if ((requestInfo[0].dwFields & enum_BPREQI_FIELDS.BPREQI_BPLOCATION) != 0)
                    _location = BreakpointLocation.FromNativeForm(requestInfo[0].bpLocation, true);
            }
        }
        public static int Event(this IDebugEventCallback2 callback, IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, DebugEvent debugEvent)
        {
            Contract.Requires<ArgumentNullException>(callback != null, "callback");
            Contract.Requires<ArgumentNullException>(debugEvent != null, "debugEvent");
            Contract.Requires<ArgumentNullException>(engine != null, "engine");

            return callback.Event(engine, process, program, thread, debugEvent, debugEvent.EventGuid, (uint)debugEvent.Attributes);
        }
Exemplo n.º 8
0
        string _sessionName; // has no value assigned because the method that uses it is "[DEPRECATED. SHOULD ALWAYS RETURN E_NOTIMPL.]"

        #endregion Fields

        #region Constructors

        public AD7Process(EngineCallback aCallback, AD7Engine aEngine, IDebugPort2 aPort)
        {
            _callback = aCallback;
            _engine = aEngine;
            _port = aPort;
            m_program = aEngine.m_program;
            //                m_program = new AD7Program(this, _callback, _engine.eDispatcher);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Attaches a debug DebugEngine (DE) to a program or programs. Called by the session debug manager (SDM) when the DE is running in-process to the SDM.
 /// </summary>
 /// <param name="rgpPrograms">An array of IDebugProgram2 objects that represent programs to be attached to. These are port programs.</param>
 /// <param name="rgpProgramNodes">An array of IDebugProgramNode2 objects that represent program nodes, one for each program. The program nodes in this array represent the same programs as in pProgram. The program nodes are given so that the DE can identify the programs to attach to.</param>
 /// <param name="celtPrograms">Number of programs and/or program nodes in the pProgram and rgpProgramNodes arrays.</param>
 /// <param name="pCallback">The IDebugEventCallback2 object to be used to send debug events to the SDM.</param>
 /// <param name="dwReason">A value from the ATTACH_REASON enumeration that specifies the reason for attaching these programs. For more information, see the Remarks section.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>
 /// There are three reasons for attaching to a program, as follows:
 ///     ATTACH_REASON_LAUNCH indicates that the DE is attaching to the program because the user launched the process that contains it.
 ///     ATTACH_REASON_USER indicates that the user has explicitly requested the DE to attach to a program (or the process that contains a program).
 ///     ATTACH_REASON_AUTO indicates the DE is attaching to a particular program because it is already debugging other programs in a particular process. This is also called auto-attach
 /// 
 /// When this method is called, the DE needs to send these events in sequence:
 ///     IDebugEngineCreateEvent2 (if it has not already been sent for a particular instance of the debug DebugEngine)
 ///     IDebugProgramCreateEvent2
 ///     IDebugLoadCompleteEvent2
 /// 
 /// In addition, if the reason for attaching is ATTACH_REASON_LAUNCH, the DE needs to send the IDebugEntryPointEvent2 event.
 /// Once the DE gets the IDebugProgramNode2 object corresponding to the program being debugged, it can be queried for any private interface.
 /// Before calling the methods of a program node in the array given by pProgram or rgpProgramNodes, impersonation, if required, should be enabled on the IDebugProgram2 interface that represents the program node. Normally, however, this step is not necessary. For more information, see Security Issues.
 /// </remarks>
 public virtual int Attach( IDebugProgram2[] rgpPrograms,
     IDebugProgramNode2[] rgpProgramNodes,
     uint celtPrograms,
     IDebugEventCallback2 pCallback,
     enum_ATTACH_REASON dwReason)
 {
     Logger.Debug( string.Empty );
     return VSConstants.E_NOTIMPL;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Perform actual send
 /// </summary>
 private void Send(IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, BaseEvent @event)
 {
     var guid = @event.IID;
     DLog.Debug(DContext.VSDebuggerEvent, "DebugEngine Event {0} {1}", @event.GetType().Name, guid);
     var rc = callback.Event(engine, process, program, thread, @event, ref guid, (uint)@event.Attributes);
     if (!ErrorHandler.Succeeded(rc))
     {
         DLog.Error(DContext.VSDebuggerEvent, "DebugEngine Event failed {0}", rc);
     }
 }
Exemplo n.º 11
0
        public int Event(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, ref Guid riidEvent, uint dwAttrib)
        {
            if (pEvent is IRunspaceRequest)
            {
                var request = pEvent as IRunspaceRequest;
                request.SetRunspace(_runspace, _breakpoints);
            }

            return VSConstants.S_OK;
        }
Exemplo n.º 12
0
        public DebugBreakpointResolution(IDebugProgram2 program, IDebugThread2 thread, enum_BP_TYPE breakpointType, BreakpointResolutionLocation location)
        {
            Contract.Requires<ArgumentNullException>(program != null, "program");
            Contract.Requires<ArgumentNullException>(location != null, "location");

            _program = program;
            _thread = thread;
            _breakpointType = breakpointType;
            _location = location;
        }
        public int Event( IDebugEngine2 pEngine,
            IDebugProcess2 pProcess,
            IDebugProgram2 pProgram,
            IDebugThread2 pThread,
            IDebugEvent2 pEvent,
            ref Guid riidEvent,
            uint dwAttrib)
        {
            Logger.Debug( string.Empty );

            return VSConstants.S_OK;
        }
Exemplo n.º 14
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;
    }
Exemplo n.º 15
0
        public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms,
            IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
        {
            DebugHelper.TraceEnteringMethod();

            rgpPrograms[0].GetProgramId(out _programId);
            _dispatcher.Queue(() => DebuggedProcess.Attach());
            _dispatcher.Queue(() => DebuggedProcess.WaitForAttach());

            Events.EngineCreated();
            Events.ProgramCreated();

            return VSConstants.S_OK;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Attaches a debug engine (DE) to a program or programs. Called by the session debug manager (SDM) when the DE is running in-process to the SDM.
        /// </summary>
        public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
        {
            DLog.Debug(DContext.VSDebuggerComCall, "IDebugEngine2.Attach");

            // Save program
            program = rgpPrograms[0] as DebugProgram;
            if (program == null)
                return VSConstants.E_INVALIDARG;

            // Update program state
            CopyExceptionMapToProgramDelayed();

            //eventCallback.Send(process, new ProcessCreateEvent());
            eventCallback.Send(program, new ProgramCreateEvent());
            return VSConstants.S_OK;
        }
Exemplo n.º 17
0
        public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program,
            IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent, uint attributes)
        {
            if (process == null)
                return VSConstants.S_OK;
            string processName;
            if (process.GetName((uint) enum_GETNAME_TYPE.GN_FILENAME, out processName) != VSConstants.S_OK)
                return VSConstants.S_OK;
            if (processName.EndsWith("vshost.exe"))
                return VSConstants.S_OK;

            var shortName = Path.GetFileName(processName);

            if (debugEvent is IDebugProcessCreateEvent2)
            {
                Log.Instance.SetStatus("[attaching...] {0}", shortName);
                Storage.Instance.SubscribeProcess(processName);
            }
            if (debugEvent is IDebugProcessDestroyEvent2)
            {
                Log.Instance.SetStatus("[detached] {0}", shortName);
                Log.Instance.AppendLine("[detached] {0}", shortName);
            }
            if (debugEvent is  IDebugLoadCompleteEvent2)
            {
                if (program != null)
                {
                    string engineName;
                    Guid engineId;
                    if (program.GetEngineInfo(out engineName, out engineId) == VSConstants.S_OK)
                    {
                        var fields = new PROCESS_INFO[1];
                        if (process.GetInfo((uint)enum_PROCESS_INFO_FIELDS.PIF_PROCESS_ID, fields) != VSConstants.S_OK)
                            return VSConstants.S_OK;
                        Storage.Instance.SubscribeEngine(processName, engineId);
                        AttachCenter.Instance.Freeze();

                        Log.Instance.SetStatus("[attached] {0}", shortName);
                        Log.Instance.AppendLine("[attached] {0} ({1}) / {2}", shortName, fields[0].ProcessId.dwProcessId, engineName);
                    }
                }
            }
            return VSConstants.S_OK;
        }
        public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program,
            IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent, uint attributes)
        {
            // Ignore a few events right away.
            if (debugEvent is IDebugModuleLoadEvent2 ||
                debugEvent is IDebugThreadCreateEvent2 ||
                debugEvent is IDebugThreadDestroyEvent2)
                return VSConstants.S_OK;

            if (process == null)
                return VSConstants.S_OK;

            if (debugEvent is IDebugProcessCreateEvent2) {
                State.IsAttached = true;
            }
            else if (debugEvent is IDebugProcessDestroyEvent2) {
                State.IsAttached = false;
            }

            return VSConstants.S_OK;
        }
Exemplo n.º 19
0
        public int Event(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, ref Guid riidEvent, uint dwAttrib)
        {
            if (riidEvent == typeof(IDebugOutputStringEvent2).GUID)
            {
                IDebugOutputStringEvent2 ev = pEvent as IDebugOutputStringEvent2;
                if (ev != null)
                {
                    string message;
                    if (ErrorHandler.Succeeded(ev.GetString(out message)))
                    {
                        var lines = message.Split(sp, StringSplitOptions.RemoveEmptyEntries);

                        foreach(var line in lines)
                        {
                            HandleMessage(line);
                        }
                    }
                }
            }

            return VSConstants.S_OK;
        }
Exemplo n.º 20
0
        public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, 
			IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent, uint attributes)
        {
            // Ignore a few events right away.
            if (debugEvent is IDebugModuleLoadEvent2 ||
                debugEvent is IDebugThreadCreateEvent2 ||
                debugEvent is IDebugThreadDestroyEvent2)
                return VSConstants.S_OK;

            // Trace.WriteLine(TypeHelper.GetDebugEventTypeName(debugEvent)); // TODO: Remove me.

            if (process == null)
                return VSConstants.S_OK;

            var target = GetTargetFromProcess(process);

            if (target == null)
            {
                _package.Reporter.ReportWarning("Can't find target from process {0} ({1}). Event: {2}.",
                    process.GetName(), process.GetProcessId(), TypeHelper.GetDebugEventTypeName(debugEvent));
                return VSConstants.S_OK;
            }
            if (debugEvent is IDebugProcessCreateEvent2)
            {
                target.IsAttached = true;
                _package.History.Items.AddFirst(target);
                _package.Ui.Update();
                return VSConstants.S_OK;
            }

            if (debugEvent is IDebugProcessDestroyEvent2)
            {
                target.IsAttached = false;
                _package.Ui.Update();
                return VSConstants.S_OK;
            }

            return VSConstants.S_OK;
        }
        /// <summary>
        /// Attaches a debug DebugEngine (DE) to a program or programs. Called by the session debug manager (SDM) when the DE is running in-process to the SDM.
        /// </summary>
        /// <param name="rgpPrograms">An array of IDebugProgram2 objects that represent programs to be attached to. These are port programs.</param>
        /// <param name="rgpProgramNodes">An array of IDebugProgramNode2 objects that represent program nodes, one for each program. The program nodes in this array represent the same programs as in pProgram. The program nodes are given so that the DE can identify the programs to attach to.</param>
        /// <param name="celtPrograms">Number of programs and/or program nodes in the pProgram and rgpProgramNodes arrays.</param>
        /// <param name="pCallback">The IDebugEventCallback2 object to be used to send debug events to the SDM.</param>
        /// <param name="dwReason">A value from the ATTACH_REASON enumeration that specifies the reason for attaching these programs. For more information, see the Remarks section.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise, returns an error code.
        /// </returns>
        public override int Attach( IDebugProgram2[] rgpPrograms,
            IDebugProgramNode2[] rgpProgramNodes,
            uint celtPrograms,
            IDebugEventCallback2 pCallback,
            enum_ATTACH_REASON dwReason)
        {
            Logger.Debug( string.Empty );
            if ( celtPrograms != 1 )
            {
                Debug.Fail( "PowerStudio Engine only expects to see one program in a process." );
                throw new ArgumentException( "celtPrograms" );
            }

            CreateOrInitializeEventSource( pCallback );
            Program = new PowerShellProgramNode( Process );

            EngineEventSource.OnDebugEngineCreate();
            EngineEventSource.OnProgramCreate( Program );
            EngineEventSource.OnLoadComplete();

            return VSConstants.S_OK;
        }
Exemplo n.º 22
0
        public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, 
			IDebugThread2 thread, IDebugEvent2 debugEvent, ref Guid riidEvent, uint attributes)
        {
            // _package.Reporter.ReportTrace(TypeHelper.GetDebugEventTypeName(debugEvent));

            if (!(debugEvent is IDebugProcessCreateEvent2) &&
                !(debugEvent is IDebugProcessDestroyEvent2))
                return VSConstants.S_OK;

            var target = GetTargetFromProcess(process);
            if (target == null)
            {
                _package.Reporter.ReportWarning("Can't find target from process {0} ({1}). Event: {2}.",
                    process.GetName(), process.GetProcessId(), TypeHelper.GetDebugEventTypeName(debugEvent));
                return VSConstants.S_OK;
            }

            if (debugEvent is IDebugProcessCreateEvent2)
            {
                var engines = target.Engines.Where(e => _engines.ContainsKey(e)).Select(e => _engines[e]).ToArray();

                var mode = new DBGMODE[1];
                _debugger.GetMode(mode);
                if (mode[0] == DBGMODE.DBGMODE_Design)
                    return VSConstants.S_OK;

                target.IsAttached = true;
                _package.History.Items.AddFirst(target);
                _package.Ui.Update();
            }
            else
            {
                target.IsAttached = false;
                _package.Ui.Update();
            }

            return VSConstants.S_OK;
        }
Exemplo n.º 23
0
        public int Event(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, ref Guid riidEvent, uint dwAttrib) {
            if (riidEvent == typeof(IDebugProgramCreateEvent2).GUID) {
                Guid processId;

                // A program was created and attached
                if (pProcess != null) {
                    if (VSConstants.S_OK == pProcess.GetProcessId(out processId)) {
                        DkmProcess dkmProcess = DkmProcess.FindProcess(processId);

                        if (dkmProcess != null) {
                            var debugTrigger = DkmExceptionCodeTrigger.Create(DkmExceptionProcessingStage.Thrown, null, DkmExceptionCategory.Win32, RemoteDebugStartExceptionCode);
                            var attachTrigger = DkmExceptionCodeTrigger.Create(DkmExceptionProcessingStage.Thrown, null, DkmExceptionCategory.Win32, RemoteDebugAttachExceptionCode);

                            // Try to add exception trigger for when a remote debugger server is started for Python
                            dkmProcess.AddExceptionTrigger(RemoteDebugExceptionGuid, debugTrigger);
                            dkmProcess.AddExceptionTrigger(RemoteDebugExceptionGuid, attachTrigger);
                        }
                    }
                }
            }

            return VSConstants.S_OK;
        }
Exemplo n.º 24
0
 int IDebugProgram3.Execute()
 {
     return(IDebugProgram2.Execute());
 }
Exemplo n.º 25
0
 int IDebugProgram3.CauseBreak()
 {
     return(IDebugProgram2.CauseBreak());
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public async Task <int> OnError(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, Guid riidEvent, uint dwAttrib)
        {
            LoggingUtils.PrintFunction();

            try
            {
                DebugEngineEvent.Error errorEvent = pEvent as DebugEngineEvent.Error;

                enum_MESSAGETYPE [] messageType = new enum_MESSAGETYPE [1];

                string errorFormat, errorHelpFileName;

                int errorReason;

                uint errorType, errorHelpId;

                LoggingUtils.RequireOk(errorEvent.GetErrorMessage(messageType, out errorFormat, out errorReason, out errorType, out errorHelpFileName, out errorHelpId));

                LoggingUtils.RequireOk(await m_debuggerConnectionService.LaunchDialogUpdate(errorFormat, true));

                return(VSConstants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(VSConstants.E_FAIL);
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public async Task <int> OnProgramDestroy(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, Guid riidEvent, uint dwAttrib)
        {
            LoggingUtils.PrintFunction();

            try
            {
                if (m_adbLogcatProcess != null)
                {
                    m_adbLogcatProcess.Kill();

                    m_adbLogcatProcess.Dispose();

                    m_adbLogcatProcess = null;
                }

                return(VSConstants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(VSConstants.E_FAIL);
            }
        }
Exemplo n.º 28
0
        // These methods are not called by the Visual Studio debugger, so they don't need to be implemented

        int IDebugProgramNode2.Attach_V7(IDebugProgram2 pMDMProgram, IDebugEventCallback2 pCallback, uint dwReason)
        {
            Debug.Fail("This function is not called by the debugger");

            return(VSConstants.E_NOTIMPL);
        }
Exemplo n.º 29
0
 int IDebugProgram3.GetENCUpdate(out object ppUpdate)
 {
     return(IDebugProgram2.GetENCUpdate(out ppUpdate));
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public async Task <int> OnProgramCreate(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, Guid riidEvent, uint dwAttrib)
        {
            LoggingUtils.PrintFunction();

            try
            {
                /*DebuggeeProgram p = pProgram as DebuggeeProgram;
                 *
                 * bool worked = false;
                 *
                 * if (pProgram is DebuggeeProgram)
                 * {
                 * worked = true;
                 * }
                 *
                 * Type t = pProgram.GetType ();
                 *
                 * IntPtr pUnk = Marshal.GetIUnknownForObject (pProgram);
                 *
                 * Guid guidDebuggeeProgram = ComUtils.GuidOf (typeof (IDebugProgram2));
                 *
                 * IDebugProgram2 debuggeeProgramObj = (IDebugProgram2) Marshal.GetTypedObjectForIUnknown (pUnk, typeof (IDebugProgram2));
                 *
                 * DebuggeeProgram debuggeeProgram = debuggeeProgramObj as DebuggeeProgram;
                 *
                 * debuggeeProgram = (DebuggeeProgram) Marshal.CreateWrapperOfType (debuggeeProgramObj, typeof (IDebugProgram2));
                 */

                return(VSConstants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(VSConstants.E_FAIL);
            }
        }
Exemplo n.º 31
0
 int IDebugEngine2.DestroyProgram(IDebugProgram2 pProgram)
 {
     ThrowIfDisposed();
     return(DebuggerConstants.E_PROGRAM_DESTROY_PENDING);
 }
Exemplo n.º 32
0
        // Attach the debug engine to a program.
        int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason)
        {
            Debug.Assert(_ad7ProgramId == Guid.Empty);

            if (celtPrograms != 1)
            {
                Debug.Fail("SampleEngine only expects to see one program in a process");
                throw new ArgumentException();
            }

            try
            {
                AD_PROCESS_ID processId = EngineUtils.GetProcessId(rgpPrograms[0]);

                EngineUtils.RequireOk(rgpPrograms[0].GetProgramId(out _ad7ProgramId));

                // Attach can either be called to attach to a new process, or to complete an attach
                // to a launched process
                if (_pollThread == null)
                {
                    // We are being asked to debug a process when we currently aren't debugging anything
                    _pollThread = new WorkerThread(Logger);

                    _engineCallback = new EngineCallback(this, ad7Callback);

                    // Complete the win32 attach on the poll thread
                    _pollThread.RunOperation(new Operation(delegate
                    {
                        throw new NotImplementedException();
                    }));

                    _pollThread.PostedOperationErrorEvent += _debuggedProcess.OnPostedOperationError;
                }
                else
                {
                    if (!EngineUtils.ProcIdEquals(processId, _debuggedProcess.Id))
                    {
                        Debug.Fail("Asked to attach to a process while we are debugging");
                        return Constants.E_FAIL;
                    }
                }

                AD7EngineCreateEvent.Send(this);
                AD7ProgramCreateEvent.Send(this);
                this.ProgramCreateEventSent = true;

                return Constants.S_OK;
            }
            catch (MIException e)
            {
                return e.HResult;
            }
            catch (Exception e) when (ExceptionHelper.BeforeCatch(e, Logger, reportOnlyCorrupting: true))
            {
                return EngineUtils.UnexpectedException(e);
            }
        }
Exemplo n.º 33
0
 // WatchForExpressionEvaluationOnThread is used to cooperate between two different engines debugging
 // the same process. The sample engine doesn't cooperate with other engines, so it has nothing
 // to do here.
 public int WatchForExpressionEvaluationOnThread(IDebugProgram2 pOriginatingProgram, uint dwTid, uint dwEvalFlags, IDebugEventCallback2 pExprCallback, int fWatch)
 {
     return Constants.S_OK;
 }
Exemplo n.º 34
0
        /// <summary>
        /// Watches for execution (or stops watching for execution) to occur on the given thread.
        /// </summary>
        /// <param name="pOriginatingProgram">An IDebugProgram2 object representing the program being stepped.</param>
        /// <param name="dwTid">Specifies the identifier of the thread to watch.</param>
        /// <param name="fWatch">Non-zero (TRUE) means start watching for execution on the thread identified by dwTid; otherwise, zero (FALSE) means stop watching for execution on dwTid.</param>
        /// <param name="dwFrame">
        /// Specifies a frame index that controls the step type. When this is value is zero (0), the step type is
        /// "step into" and the program should stop whenever the thread identified by dwTid executes. When dwFrame
        /// is non-zero, the step type is "step over" and the program should stop only if the thread identified by
        /// dwTid is running in a frame whose index is equal to or higher on the stack than dwFrame.
        /// </param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// When the session debug manager (SDM) steps a program, identified by the pOriginatingProgram parameter,
        /// it notifies all other attached programs by calling this method.
        /// 
        /// This method is applicable only to same-thread stepping.
        /// </remarks>
        public int WatchForThreadStep(IDebugProgram2 pOriginatingProgram, uint dwTid, int fWatch, uint dwFrame)
        {
            JavaDebugProgram javaProgram = pOriginatingProgram as JavaDebugProgram;
            if (javaProgram == null)
                return VSConstants.S_OK;

            throw new NotImplementedException();
        }
Exemplo n.º 35
0
 int IDebugProgram3.EnumModules(out IEnumDebugModules2 ppEnum)
 {
     return(IDebugProgram2.EnumModules(out ppEnum));
 }
Exemplo n.º 36
0
 int IDebugProgram3.GetEngineInfo(out string pbstrEngine, out Guid pguidEngine)
 {
     return(IDebugProgram2.GetEngineInfo(out pbstrEngine, out pguidEngine));
 }
Exemplo n.º 37
0
 int IDebugProgram3.Attach(IDebugEventCallback2 pCallback)
 {
     return(IDebugProgram2.Attach(pCallback));
 }
Exemplo n.º 38
0
 int IDebugProgram3.GetDebugProperty(out IDebugProperty2 ppProperty)
 {
     return(IDebugProgram2.GetDebugProperty(out ppProperty));
 }
Exemplo n.º 39
0
 int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 pProcess)
 {
     return(IDebugProgram2.Detach());
 }
Exemplo n.º 40
0
        /// <summary>
        /// Send the given event to all event sinks
        /// </summary>
        private void SendEvent(IDebugCoreServer2 server, IDebugPort2 port, IDebugProcess2 process, IDebugProgram2 program, BaseEvent @event)
        {
            var iid = @event.IID;

            DLog.Debug(DContext.VSDebuggerEvent, "DebugPort Event {0} {1}", @event.GetType().Name, iid);
            foreach (var eventSink in eventSinks)
            {
                var events = eventSink as IDebugPortEvents2;
                if (events != null)
                {
                    var rc = events.Event(server, port, process, program, @event, ref iid);
                    if (!ErrorHandler.Succeeded(rc))
                    {
                        DLog.Error(DContext.VSDebuggerEvent, "DebugPort Event failed {0}", rc);
                    }
                }
            }
        }
Exemplo n.º 41
0
 public int Attach_V7(IDebugProgram2 pMDMProgram, IDebugEventCallback2 pCallback, uint dwReason)
 {
     DebugHelper.TraceEnteringMethod();
     return(VSConstants.E_NOTIMPL);
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public async Task <int> OnDebuggerConnectionEvent(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, Guid riidEvent, uint dwAttrib)
        {
            LoggingUtils.PrintFunction();

            try
            {
                DebugEngineEvent.DebuggerConnectionEvent debuggerConnectionEvent = pEvent as DebugEngineEvent.DebuggerConnectionEvent;

                switch (debuggerConnectionEvent.Type)
                {
                case DebugEngineEvent.DebuggerConnectionEvent.EventType.ShowDialog:
                {
                    LoggingUtils.RequireOk(await m_debuggerConnectionService.LaunchDialogShow());

                    break;
                }

                case DebugEngineEvent.DebuggerConnectionEvent.EventType.CloseDialog:
                {
                    LoggingUtils.RequireOk(await m_debuggerConnectionService.LaunchDialogClose());

                    break;
                }

                case DebugEngineEvent.DebuggerConnectionEvent.EventType.LogStatus:
                case DebugEngineEvent.DebuggerConnectionEvent.EventType.LogError:
                {
                    bool isError = (debuggerConnectionEvent.Type == DebugEngineEvent.DebuggerConnectionEvent.EventType.LogError);

                    LoggingUtils.RequireOk(await m_debuggerConnectionService.LaunchDialogUpdate(debuggerConnectionEvent.Message, isError));

                    break;
                }
                }

                return(VSConstants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(VSConstants.E_FAIL);
            }
        }
Exemplo n.º 43
0
 int IDebugProgram3.EnumCodePaths(string pszHint, IDebugCodeContext2 pStart, IDebugStackFrame2 pFrame, int fSource, out IEnumCodePaths2 ppEnum, out IDebugCodeContext2 ppSafety)
 {
     return(IDebugProgram2.EnumCodePaths(pszHint, pStart, pFrame, fSource, out ppEnum, out ppSafety));
 }
Exemplo n.º 44
0
 int IDebugProgram3.GetDisassemblyStream(enum_DISASSEMBLY_STREAM_SCOPE dwScope, IDebugCodeContext2 pCodeContext, out IDebugDisassemblyStream2 ppDisassemblyStream)
 {
     return(IDebugProgram2.GetDisassemblyStream(dwScope, pCodeContext, out ppDisassemblyStream));
 }
Exemplo n.º 45
0
 public int DestroyProgram(IDebugProgram2 pProgram)
 {
     DebugHelper.TraceEnteringMethod();
     return(VSConstants.S_OK);
 }
Exemplo n.º 46
0
 int IDebugProgram3.EnumCodeContexts(IDebugDocumentPosition2 pDocPos, out IEnumDebugCodeContexts2 ppEnum)
 {
     return(IDebugProgram2.EnumCodeContexts(pDocPos, out ppEnum));
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public async Task <int> OnDebuggerLogcatEvent(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, Guid riidEvent, uint dwAttrib)
        {
            LoggingUtils.PrintFunction();

            try
            {
                DebugEngineEvent.DebuggerLogcatEvent debuggerLogcatEvent = pEvent as DebugEngineEvent.DebuggerLogcatEvent;

                using (SyncRedirectProcess command = AndroidAdb.AdbCommand(debuggerLogcatEvent.HostDevice, "logcat", "-c"))
                {
                    command.StartAndWaitForExit();
                }

                m_adbLogcatProcess = AndroidAdb.AdbCommandAsync(debuggerLogcatEvent.HostDevice, "logcat", "");

                m_adbLogcatListener = new DeviceLogcatListener();

                m_adbLogcatProcess.Start(m_adbLogcatListener);

                return(VSConstants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(VSConstants.E_FAIL);
            }
        }
Exemplo n.º 48
0
 int IDebugProgram3.Detach()
 {
     return(IDebugProgram2.Detach());
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public async Task <int> OnAttachComplete(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, Guid riidEvent, uint dwAttrib)
        {
            LoggingUtils.PrintFunction();

            return(VSConstants.E_NOTIMPL);
        }
Exemplo n.º 50
0
 int IDebugProgram3.Continue(IDebugThread2 pThread)
 {
     return(IDebugProgram2.Continue(pThread));
 }
Exemplo n.º 51
0
 int IDebugProgram3.GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes)
 {
     return(IDebugProgram2.GetMemoryBytes(out ppMemoryBytes));
 }
Exemplo n.º 52
0
 int IDebugProgram3.EnumThreads(out IEnumDebugThreads2 ppEnum)
 {
     return(IDebugProgram2.EnumThreads(out ppEnum));
 }
Exemplo n.º 53
0
        /// <summary>
        /// Allows (or disallows) expression evaluation to occur on the given thread, even if the program has stopped.
        /// </summary>
        /// <param name="pOriginatingProgram">An IDebugProgram2 object representing the program that is evaluating an expression.</param>
        /// <param name="dwTid">Specifies the identifier of the thread.</param>
        /// <param name="dwEvalFlags">A combination of flags from the EVALFLAGS enumeration that specify how the evaluation is to be performed.</param>
        /// <param name="pExprCallback">An IDebugEventCallback2 object to be used to send debug events that occur during expression evaluation.</param>
        /// <param name="fWatch">If non-zero (TRUE), allows expression evaluation on the thread identified by dwTid; otherwise, zero (FALSE) disallows expression evaluation on that thread.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// When the session debug manager (SDM) asks a program, identified by the <paramref name="pOriginatingProgram"/>
        /// parameter, to evaluate an expression, it notifies all other attached programs by calling this method.
        /// 
        /// Expression evaluation in one program may cause code to run in another, due to function evaluation or
        /// evaluation of any IDispatch properties. Because of this, this method allows expression evaluation to
        /// run and complete even though the thread may be stopped in this program.
        /// </remarks>
        public int WatchForExpressionEvaluationOnThread(IDebugProgram2 pOriginatingProgram, uint dwTid, uint dwEvalFlags, IDebugEventCallback2 pExprCallback, int fWatch)
        {
            JavaDebugProgram javaProgram = pOriginatingProgram as JavaDebugProgram;
            if (javaProgram == null)
                return VSConstants.S_OK;

            throw new NotImplementedException();
        }
Exemplo n.º 54
0
 int IDebugProgram3.GetName(out string pbstrName)
 {
     return(IDebugProgram2.GetName(out pbstrName));
 }
Exemplo n.º 55
0
 int IDebugProgramNode2.Attach_V7(IDebugProgram2 pMDMProgram, IDebugEventCallback2 pCallback, uint dwReason)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 56
0
 int IDebugProgram3.GetProcess(out IDebugProcess2 ppProcess)
 {
     return(IDebugProgram2.GetProcess(out ppProcess));
 }
Exemplo n.º 57
0
        // Informs a DE that the program specified has been atypically terminated and that the DE should
        // clean up all references to the program and send a program destroy event.
        int IDebugEngine2.DestroyProgram(IDebugProgram2 pProgram)
        {
            // Tell the SDM that the engine knows that the program is exiting, and that the
            // engine will send a program destroy. We do this because the Win32 debug api will always
            // tell us that the process exited, and otherwise we have a race condition.

            return (AD7_HRESULT.E_PROGRAM_DESTROY_PENDING);
        }
Exemplo n.º 58
0
 int IDebugProgram3.Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
 {
     return(IDebugProgram2.Step(pThread, sk, Step));
 }
Exemplo n.º 59
0
 // WatchForThreadStep is used to cooperate between two different engines debugging the same process.
 // The sample engine doesn't cooperate with other engines, so it has nothing to do here.
 public int WatchForThreadStep(IDebugProgram2 pOriginatingProgram, uint dwTid, int fWatch, uint dwFrame)
 {
     return Constants.S_OK;
 }
Exemplo n.º 60
0
        // Attach the debug engine to a program.
        public int Attach(IDebugProgram2[] portProgramArray, IDebugProgramNode2[] programNodeArray, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason)
        {
            Debug.Assert(_ad7ProgramId == Guid.Empty);

            Logger.LoadMIDebugLogger(_configStore);

            if (celtPrograms != 1)
            {
                Debug.Fail("SampleEngine only expects to see one program in a process");
                throw new ArgumentException();
            }
            IDebugProgram2 portProgram = portProgramArray[0];

            Exception exception = null;

            try
            {
                IDebugProcess2 process;
                EngineUtils.RequireOk(portProgram.GetProcess(out process));

                AD_PROCESS_ID processId = EngineUtils.GetProcessId(process);

                EngineUtils.RequireOk(portProgram.GetProgramId(out _ad7ProgramId));

                // Attach can either be called to attach to a new process, or to complete an attach
                // to a launched process
                if (_pollThread == null)
                {
                    if (processId.ProcessIdType != (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM)
                    {
                        Debug.Fail("Invalid process to attach to");
                        throw new ArgumentException();
                    }

                    IDebugPort2 port;
                    EngineUtils.RequireOk(process.GetPort(out port));

                    Debug.Assert(_engineCallback == null);
                    Debug.Assert(_debuggedProcess == null);

                    _engineCallback = new EngineCallback(this, ad7Callback);
                    LaunchOptions launchOptions = CreateAttachLaunchOptions(processId.dwProcessId, port);
                    if (port is IDebugUnixShellPort)
                    {
                        _unixPort = (IDebugUnixShellPort)port;
                    }
                    StartDebugging(launchOptions);
                }
                else
                {
                    if (!EngineUtils.ProcIdEquals(processId, _debuggedProcess.Id))
                    {
                        Debug.Fail("Asked to attach to a process while we are debugging");
                        return(Constants.E_FAIL);
                    }
                }

                AD7EngineCreateEvent.Send(this);
                AD7ProgramCreateEvent.Send(this);
                this.ProgramCreateEventSent = true;

                return(Constants.S_OK);
            }
            catch (Exception e) when(ExceptionHelper.BeforeCatch(e, Logger, reportOnlyCorrupting: true))
            {
                exception = e;
            }

            // If we just return the exception as an HRESULT, we will lose our message, so we instead send up an error event, and
            // return that the attach was canceled
            OnStartDebuggingFailed(exception);
            return(AD7_HRESULT.E_ATTACH_USER_CANCELED);
        }