Example #1
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            IDebugPort2 port;

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

            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;

            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

            EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode((int)pi.dwProcessId)));

            if (this.m_ad7ProgramId == Guid.Empty)
            {
                Debug.Fail("Attaching failed");
                return(VSConstants.E_FAIL);
            }

            this._programCreateContinued.WaitOne();
            this.writeCommandQueue.Enqueue(new Command(CommandKind.DebuggerEnvironmentReady));

            NativeMethods.ResumeThread(threadHandle);
            return(0);
        }
Example #2
0
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 pProcess)
        {
            Debug.WriteLine("AD7Engine ResumeProcess");
            if (pProcess is AD7Process)
            {
                IDebugPort2 port;
                pProcess.GetPort(out port);

                var defaultPort = (IDebugDefaultPort2)port;
                IDebugPortNotify2 notify;

                defaultPort.GetPortNotify(out notify);

                AD7ProgramNode node   = (pProcess as AD7Process).Node;
                int            result = notify.AddProgramNode(node);
                if (node.Debugger == null)
                {
                    return(VSConstants.E_ABORT);
                }

                return(VSConstants.S_OK);
            }

            return(VSConstants.E_UNEXPECTED);
        }
Example #3
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            //Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId);

            /*Debug.Assert(m_pollThread != null);
             * Debug.Assert(m_engineCallback != null);
             * Debug.Assert(m_debuggedProcess != null);
             * Debug.Assert(m_ad7ProgramId == Guid.Empty);*/

            try
            {
                int processId = EngineUtils.GetProcessId(process);

                if (processId != debuggedProcess.Id)
                {
                    return(EngineConstants.S_FALSE);
                }

                // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
                // which will complete the hookup with AD7
                IDebugPort2 port;
                EngineUtils.RequireOk(process.GetPort(out port));

                IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

                IDebugPortNotify2 portNotify;
                EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

                EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(debuggedProcess.Id)));

                if (m_ad7ProgramId == Guid.Empty)
                {
                    Debug.Fail("Unexpected problem -- IDebugEngine2.Attach wasn't called");
                    return(EngineConstants.E_FAIL);
                }

                debuggedProcess.ResumeFromLaunch();

                // Resume the threads in the debuggee process

                /*m_pollThread.RunOperation(new Operation(delegate
                 * {
                 *  m_debuggedProcess.ResumeFromLaunch();
                 * }));*/

                return(EngineConstants.S_OK);
            }
            catch (ComponentException e)
            {
                return(e.HRESULT);
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
Example #4
0
        public int ResumeProcess(IDebugProcess2 process)
        {
            IDebugPort2 port;

            EngineUtils.RequireOk(process.GetPort(out port));
            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;

            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));
            EngineUtils.RequireOk(portNotify.AddProgramNode(_program));

            Debug.WriteLine("IDebugEngineLaunch2.ResumeProcess: returning S_OK");
            return(VSConstants.S_OK);
        }
Example #5
0
        /// <summary>
        ///     Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        /// </summary>
        /// <param name="process"></param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        public int ResumeProcess(IDebugProcess2 process)
        {
            IDebugPort2 port;

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

            var defaultPort = (IDebugDefaultPort2)port;
            IDebugPortNotify2 portNotify;

            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

            EngineUtils.RequireOk(portNotify.AddProgramNode(Program.Node));

            return(S_OK);
        }
Example #6
0
        public int ResumeProcess(IDebugProcess2 process)
        {
            IDebugPort2 port;

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

            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;
            IDebugPortNotify2  portNotify;

            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

            EngineUtils.RequireOk(portNotify.AddProgramNode(new MonoProgramNode(processId)));

            return(VSConstants.S_OK);
        }
Example #7
0
        public int ResumeProcess(IDebugProcess2 pProcess)
        {
            IDebugPort2 port;
            Guid        id;

            pProcess.GetPort(out port);
            pProcess.GetProcessId(out id);

            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 notify;

            defaultPort.GetPortNotify(out notify);

            return(notify.AddProgramNode(new MonoProgramNode(id)));
        }
Example #8
0
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 aProcess)
        {
            // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
            try
            {
                // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
                // which will complete the hookup with AD7
                var xProcess = aProcess as AD7Process;
                if (xProcess == null)
                {
                    return(VSConstants.E_INVALIDARG);
                }
                IDebugPort2 xPort;
                EngineUtils.RequireOk(aProcess.GetPort(out xPort));
                var xDefPort = (IDebugDefaultPort2)xPort;
                IDebugPortNotify2 xNotify;
                EngineUtils.RequireOk(xDefPort.GetPortNotify(out xNotify));

                // This triggers Attach
                EngineUtils.RequireOk(xNotify.AddProgramNode(mProgNode));

                Callback.OnModuleLoad(mModule);
                Callback.OnSymbolSearch(mModule, xProcess.mISO.Replace("iso", "pdb"), enum_MODULE_INFO_FLAGS.MIF_SYMBOLS_LOADED);
                // Important!
                //
                // This call triggers setting of breakpoints that exist before run.
                // So it must be called before we resume the process.
                // If not called VS will call it after our 3 startup events, but thats too late.
                // This line was commented out in earlier Cosmos builds and caused problems with
                // breakpoints and timing.
                Callback.OnThreadStart(mThread);

                // Not sure what this does exactly. It was commented out before
                // but so was a lot of stuff we actually needed. If its uncommented it
                // throws:
                //  "Operation is not valid due to the current state of the object."
                //AD7EntrypointEvent.Send(this);

                // Now finally release our process to go after breakpoints are set
                mProcess.ResumeFromLaunch();
            }
            catch (Exception e)
            {
                return(EngineUtils.UnexpectedException(e));
            }
            return(VSConstants.S_OK);
        }
Example #9
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            Debug.Assert(_pollThread != null);
            Debug.Assert(_engineCallback != null);
            Debug.Assert(_debuggedProcess != null);
            Debug.Assert(_ad7ProgramId == Guid.Empty);

            try
            {
                AD_PROCESS_ID processId = EngineUtils.GetProcessId(process);

                if (!EngineUtils.ProcIdEquals(processId, _debuggedProcess.Id))
                {
                    return(Constants.S_FALSE);
                }

                // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
                // which will complete the hookup with AD7
                IDebugPort2 port;
                EngineUtils.RequireOk(process.GetPort(out port));

                IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

                IDebugPortNotify2 portNotify;
                EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

                EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(_debuggedProcess.Id, _engineGuid)));

                if (_ad7ProgramId == Guid.Empty)
                {
                    Debug.Fail("Unexpected problem -- IDebugEngine2.Attach wasn't called");
                    return(Constants.E_FAIL);
                }

                // NOTE: We wait for the program create event to be continued before we really resume the process

                return(Constants.S_OK);
            }
            catch (MIException e)
            {
                return(e.HResult);
            }
            catch (Exception e) when(ExceptionHelper.BeforeCatch(e, Logger, reportOnlyCorrupting: true))
            {
                return(EngineUtils.UnexpectedException(e));
            }
        }
Example #10
0
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 pProcess)
        {
            IDebugPort2 port;

            pProcess.GetPort(out port);
            Guid id;

            pProcess.GetProcessId(out id);
            var defaultPort = (IDebugDefaultPort2)port;
            IDebugPortNotify2 notify;

            defaultPort.GetPortNotify(out notify);

            int result = notify.AddProgramNode(new AD7ProgramNode(id));

            return(Constants.S_OK);
        }
Example #11
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            if (_events == null)
            {
                // process failed to start
                return(VSConstants.E_FAIL);
            }

            Debug.Assert(_events != null);
            Debug.Assert(_process != null);
            Debug.Assert(_process != null);
            Debug.Assert(_ad7ProgramId == Guid.Empty);

            int processId = EngineUtils.GetProcessId(process);

            if (processId != _process.Id)
            {
                Debug.WriteLine("ResumeProcess fails, wrong process");
                return(VSConstants.S_FALSE);
            }

            // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
            // which will complete the hookup with AD7
            IDebugPort2 port;

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

            var defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;

            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

            EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(_process.Id)));

            if (_ad7ProgramId == Guid.Empty)
            {
                Debug.WriteLine("ResumeProcess fails, empty program guid");
                Debug.Fail("Unexpected problem -- IDebugEngine2.Attach wasn't called");
                return(VSConstants.E_FAIL);
            }

            Debug.WriteLine("ResumeProcess return S_OK");
            return(VSConstants.S_OK);
        }
Example #12
0
        public int ResumeProcess(IDebugProcess2 pProcess)
        {
            DebugHelper.TraceEnteringMethod();
            IDebugPort2 port;

            pProcess.GetPort(out port);
            Guid id;

            pProcess.GetProcessId(out id);
            var defaultPort = (IDebugDefaultPort2)port;
            IDebugPortNotify2 notify;

            defaultPort.GetPortNotify(out notify);

            int result = notify.AddProgramNode(Node = new MonoProgramNode(DebuggedProcess, id));

            return(VSConstants.S_OK);
        }
Example #13
0
        int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 pProcess)
        {
            _node.Debugger.DoEndProgram();
            Debug.WriteLine("AD7Engine TerminateProcess");

            IDebugPort2 port;

            pProcess.GetPort(out port);

            var defaultPort = (IDebugDefaultPort2)port;
            IDebugPortNotify2 notify;

            defaultPort.GetPortNotify(out notify);

            notify.RemoveProgramNode(_node);

            return(VSConstants.S_OK);
        }
Example #14
0
        // This function is used to terminate a process that the SampleEngine launched
        // The debugger will call IDebugEngineLaunch2::CanTerminateProcess before calling this method.
        int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 process)
        {
            Log.Debug("Engine: TerminateProcess");

            IDebugPort2 port;

            process.GetPort(out port);

            var defaultPort = (IDebugDefaultPort2)port;
            IDebugPortNotify2 notify;

            defaultPort.GetPortNotify(out notify);

            notify.RemoveProgramNode(_node);

            Debugger.Stop();

            return(VSConstants.S_OK);
        }
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            if (process is ScriptDebugProcess)
            {
                IDebugPort2 port;
                process.GetPort(out port);

                var defaultPort = (IDebugDefaultPort2)port;
                IDebugPortNotify2 notify;

                defaultPort.GetPortNotify(out notify);

                notify.AddProgramNode((process as ScriptDebugProcess).Node);

                return(VSConstants.S_OK);
            }

            return(VSConstants.E_UNEXPECTED);
        }
Example #16
0
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            var program = process as Program;

            if (program == null)
            {
                return(VSConstants.E_FAIL);
            }

            IDebugPort2 port;

            if (process.GetPort(out port) != VSConstants.S_OK)
            {
                return(VSConstants.E_FAIL);
            }

            string portName;

            port.GetPortName(out portName);

            Guid guidPort;

            port.GetPortId(out guidPort);

            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;

            if (defaultPort.GetPortNotify(out portNotify) != VSConstants.S_OK)
            {
                return(VSConstants.E_FAIL);
            }

            if (portNotify.AddProgramNode(program) != VSConstants.S_OK)
            {
                return(VSConstants.E_FAIL);
            }

            return(VSConstants.S_OK);
        }
        /// <summary>
        /// Resumes process execution.
        /// </summary>
        /// <param name="pProcess">An IDebugProcess2 object that represents the process to be resumed.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise returns an error code.
        /// </returns>
        public override int ResumeProcess(IDebugProcess2 pProcess)
        {
            Logger.Debug(string.Empty);
            var process = pProcess as PowerShellProcess;

            if (process == null)
            {
                return(VSConstants.E_UNEXPECTED);
            }

            IDebugPort2 port;

            pProcess.GetPort(out port);

            var defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;

            defaultPort.GetPortNotify(out portNotify);

            portNotify.AddProgramNode(Program);

            return(VSConstants.S_OK);
        }
Example #18
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            Debug.Assert(m_engineCallback != null);

            try
            {
                var xProcess = process as AD7Process;
                if (xProcess == null)
                {
                    return VSConstants.E_INVALIDARG;
                }

                // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
                // which will complete the hookup with AD7
                IDebugPort2 port = null;
                EngineUtils.RequireOk(process.GetPort(out port));

                IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

                IDebugPortNotify2 portNotify = null;
                EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

                //EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(m_debuggedProcess.Id))); //Copy AD7ProgramNode from Cosmos
                EngineUtils.RequireOk(portNotify.AddProgramNode(m_progNode)); //Copy AD7ProgramNode from Cosmos

                Callback.OnModuleLoad(m_module);
                //Callback.OnSymbolSearch(m_module, xProcess.mISO.Replace("iso", "pdb"), enum_MODULE_INFO_FLAGS.MIF_SYMBOLS_LOADED); // from Cosmos

                // Important!
                //
                // This call triggers setting of breakpoints that exist before run.
                // So it must be called before we resume the process.
                // If not called VS will call it after our 3 startup events, but thats too late.
                // This line was commented out in earlier Cosmos builds and caused problems with
                // breakpoints and timing.
                Callback.OnThreadStart(currentThread());

                m_process.ResumeFromLaunch();
            }
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }
            return VSConstants.S_OK;
        }
Example #19
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            Debug.Assert(_pollThread != null);
            Debug.Assert(_engineCallback != null);
            Debug.Assert(_debuggedProcess != null);
            Debug.Assert(_ad7ProgramId == Guid.Empty);

            try
            {
                AD_PROCESS_ID processId = EngineUtils.GetProcessId(process);

                if (!EngineUtils.ProcIdEquals(processId, _debuggedProcess.Id))
                {
                    return Constants.S_FALSE;
                }

                // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
                // which will complete the hookup with AD7
                IDebugPort2 port;
                EngineUtils.RequireOk(process.GetPort(out port));

                IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

                IDebugPortNotify2 portNotify;
                EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

                EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(_debuggedProcess.Id)));

                if (_ad7ProgramId == Guid.Empty)
                {
                    Debug.Fail("Unexpected problem -- IDebugEngine2.Attach wasn't called");
                    return Constants.E_FAIL;
                }

                // NOTE: We wait for the program create event to be continued before we really resume the process

                return Constants.S_OK;
            }
            catch (MIException e)
            {
                return e.HResult;
            }
            catch (Exception e) when (ExceptionHelper.BeforeCatch(e, Logger, reportOnlyCorrupting: true))
            {
                return EngineUtils.UnexpectedException(e);
            }
        }
Example #20
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            if (_mixedMode) {
                return VSConstants.E_NOTIMPL;
            }

            Debug.WriteLine("Python Debugger ResumeProcess Begin");

            AssertMainThread();
            if (_events == null) {
                // process failed to start
                Debug.WriteLine("ResumeProcess fails, no events");
                return VSConstants.E_FAIL;
            }

            Debug.Assert(_process != null);
            Debug.Assert(_process != null);
            Debug.Assert(_ad7ProgramId == Guid.Empty);

            int processId = EngineUtils.GetProcessId(process);

            if (processId != _process.Id) {
                Debug.WriteLine("ResumeProcess fails, wrong process");
                return VSConstants.S_FALSE;
            }

            // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
            // which will complete the hookup with AD7
            IDebugPort2 port;
            EngineUtils.RequireOk(process.GetPort(out port));

            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;
            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

            EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(_process.Id)));

            if (_ad7ProgramId == Guid.Empty) {
                Debug.WriteLine("ResumeProcess fails, empty program guid");
                Debug.Fail("Unexpected problem -- IDebugEngine2.Attach wasn't called");
                return VSConstants.E_FAIL;
            }

            Debug.WriteLine("ResumeProcess return S_OK");
            return VSConstants.S_OK;
        }
Example #21
0
    int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 pProcess)
    {
      Debug.WriteLine("AD7Engine ResumeProcess");
      if (pProcess is AD7Process)
      {
        IDebugPort2 port;
        pProcess.GetPort(out port);

        var defaultPort = (IDebugDefaultPort2)port;
        IDebugPortNotify2 notify;

        defaultPort.GetPortNotify(out notify);

        AD7ProgramNode node = (pProcess as AD7Process).Node;
        int result = notify.AddProgramNode(node);
        if (node.Debugger == null)
          return VSConstants.E_FAIL;

        return VSConstants.S_OK;
      }

      return VSConstants.E_UNEXPECTED;
    }
Example #22
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            IDebugPort2 port;
            EngineUtils.RequireOk(process.GetPort(out port));

            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;
            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

            EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode((int)pi.dwProcessId)));

            if (this.m_ad7ProgramId == Guid.Empty)
            {
                Debug.Fail("Attaching failed");
                return VSConstants.E_FAIL;
            }

            this._programCreateContinued.WaitOne();
            this.writeCommandQueue.Enqueue(new Command(CommandKind.DebuggerEnvironmentReady));

            NativeMethods.ResumeThread(threadHandle);
            return 0;
        }
        public int ResumeProcess(IDebugProcess2 pProcess)
        {
            DebugHelper.TraceEnteringMethod();
            IDebugPort2 port;
            pProcess.GetPort(out port);
            Guid id;
            pProcess.GetProcessId(out id);
            var defaultPort = (IDebugDefaultPort2) port;
            IDebugPortNotify2 notify;
            defaultPort.GetPortNotify(out notify);

            int result = notify.AddProgramNode(new AD7ProgramNode(DebuggedProcess, id));

            return VSConstants.S_OK;
        }
Example #24
0
    int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 pProcess)
    {
      _node.Debugger.DoEndProgram();
      Debug.WriteLine("AD7Engine TerminateProcess");

      IDebugPort2 port;
      pProcess.GetPort(out port);

      var defaultPort = (IDebugDefaultPort2)port;
      IDebugPortNotify2 notify;

      defaultPort.GetPortNotify(out notify);

      notify.RemoveProgramNode(_node);
      
      return VSConstants.S_OK;
    }
Example #25
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            Debug.WriteLine("Python Debugger ResumeProcess Begin");

            AssertMainThread();
            if (_events == null)
            {
                // process failed to start
                Debug.WriteLine("ResumeProcess fails, no events");
                return(VSConstants.E_FAIL);
            }

            Debug.Assert(_events != null);
            Debug.Assert(_process != null);
            Debug.Assert(_process != null);
            Debug.Assert(_ad7ProgramId == Guid.Empty);

            int processId = EngineUtils.GetProcessId(process);

            if (processId != _process.Id)
            {
                Debug.WriteLine("ResumeProcess fails, wrong process");
                return(VSConstants.S_FALSE);
            }

            // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
            // which will complete the hookup with AD7
            IDebugPort2 port;

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

            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;

            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

            EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(_process.Id)));

            if (_ad7ProgramId == Guid.Empty)
            {
                Debug.WriteLine("ResumeProcess fails, empty program guid");
                Debug.Fail("Unexpected problem -- IDebugEngine2.Attach wasn't called");
                return(VSConstants.E_FAIL);
            }

            // wait for the load event to complete, and pump messages

            while (!_process.HasExited && !_loadComplete.WaitOne(100))
            {
                Debug.WriteLine("ResumeProcess waiting for load complete");
            }

            // Resume the threads in the debuggee process
            if (_process.HasExited)
            {
                Debug.WriteLine("ResumeProcess resume all");
                _process.Resume();
            }
            else
            {
                // return failure?
                Debug.WriteLine("Process exited");
            }

            Debug.WriteLine("ResumeProcess return S_OK");
            return(VSConstants.S_OK);
        }
Example #26
0
        // This function is used to terminate a process that the SampleEngine launched
        // The debugger will call IDebugEngineLaunch2::CanTerminateProcess before calling this method.
        int IDebugEngineLaunch2.TerminateProcess(IDebugProcess2 process)
        {
            Log.Debug("Engine: TerminateProcess");
            _events.ProgramDestroyed(_node);

            IDebugPort2 port;
            process.GetPort(out port);

            var defaultPort = (IDebugDefaultPort2)port;
            IDebugPortNotify2 notify;

            defaultPort.GetPortNotify(out notify);

            notify.RemoveProgramNode(_node);

            Debugger.Stop();

            return VSConstants.S_OK;
        }
Example #27
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            if (process is ScriptDebugProcess)
            {
                IDebugPort2 port;
                process.GetPort(out port);

                var defaultPort = (IDebugDefaultPort2)port;
                IDebugPortNotify2 notify;

                defaultPort.GetPortNotify(out notify);

                notify.AddProgramNode((process as ScriptDebugProcess).Node);

                return VSConstants.S_OK;
            }

            return VSConstants.E_UNEXPECTED;
        }
        /// <summary>
        /// Resumes process execution.
        /// </summary>
        /// <param name="pProcess">An IDebugProcess2 object that represents the process to be resumed.</param>
        /// <returns>
        /// If successful, returns S_OK; otherwise returns an error code.
        /// </returns>
        public override int ResumeProcess( IDebugProcess2 pProcess )
        {
            Logger.Debug( string.Empty );
            var process = pProcess as PowerShellProcess;
            if ( process == null )
            {
                return VSConstants.E_UNEXPECTED;
            }

            IDebugPort2 port;
            pProcess.GetPort( out port );

            var defaultPort = (IDebugDefaultPort2) port;

            IDebugPortNotify2 portNotify;
            defaultPort.GetPortNotify( out portNotify );

            portNotify.AddProgramNode( Program );

            return VSConstants.S_OK;
        }
Example #29
0
        /// <summary>
        /// Resume a process launched by IDebugEngineLaunch2.LaunchSuspended. (http://msdn.microsoft.com/en-us/library/bb146261.aspx)
        /// </summary>
        /// <param name="process"> An IDebugProcess2 object that represents the process to be resumed. </param>
        /// <returns> An IDebugProcess2 object that represents the process to be resumed. </returns>
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            Debug.Assert(m_engineCallback != null);

            try
            {
                var xProcess = process as AD7Process;
                if (xProcess == null)
                {
                    return VSConstants.E_INVALIDARG;
                }

                // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
                // which will complete the hookup with AD7
                IDebugPort2 port = null;
                EngineUtils.RequireOk(process.GetPort(out port));

                IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

                IDebugPortNotify2 portNotify = null;
                EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

                EngineUtils.RequireOk(portNotify.AddProgramNode(m_progNode));

                Callback.OnModuleLoad(m_module);

                Callback.OnThreadStart(currentThread());
            }
            catch (Exception e)
            {
                return EngineUtils.UnexpectedException(e);
            }
            return VSConstants.S_OK;
        }
Example #30
0
        // Resume a process launched by IDebugEngineLaunch2.LaunchSuspended
        int IDebugEngineLaunch2.ResumeProcess(IDebugProcess2 process)
        {
            //Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId);
            Debug.Assert(m_pollThread != null);
            Debug.Assert(m_engineCallback != null);
            Debug.Assert(m_debuggedProcess != null);
            Debug.Assert(m_ad7ProgramId == Guid.Empty);

            try {
                var processId = EngineUtils.GetProcessId(process);

                if (processId != m_debuggedProcess.Id) {
                    return Constants.S_FALSE;
                }

                // Send a program node to the SDM. This will cause the SDM to turn around and call IDebugEngine2.Attach
                // which will complete the hookup with AD7
                IDebugPort2 port;
                EngineUtils.RequireOk(process.GetPort(out port));

                var defaultPort = (IDebugDefaultPort2)port;

                IDebugPortNotify2 portNotify;
                EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));

                EngineUtils.RequireOk(portNotify.AddProgramNode(new AD7ProgramNode(m_debuggedProcess.Id)));

                if (m_ad7ProgramId == Guid.Empty) {
                    Debug.Fail("Unexpected problem -- IDebugEngine2.Attach wasn't called");
                    return Constants.E_FAIL;
                }

                // Resume the threads in the debuggee process
                m_pollThread.RunOperation(() => m_debuggedProcess.ResumeFromLaunch());

                return Constants.S_OK;
            } catch (Exception e) {
                return EngineUtils.UnexpectedException(e);
            }
        }