示例#1
0
        int IDebugProgram2.Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
        {
            Debug.WriteLine("AD7ProgramNode: Entering Step");
            if (sk == enum_STEPKIND.STEP_BACKWARDS)
            {
                return(VSConstants.E_NOTIMPL);
            }

            Thread thread = new Thread(new ThreadStart(() => {
                // Just to ensure main method returns before running thread.
                Thread.Sleep(10);
                SteppingTypeEnum stepping = SteppingTypeEnum.None;
                switch (sk)
                {
                case enum_STEPKIND.STEP_INTO:
                    stepping = SteppingTypeEnum.StepInto;
                    break;

                case enum_STEPKIND.STEP_OVER:
                    stepping = SteppingTypeEnum.StepOver;
                    break;

                case enum_STEPKIND.STEP_OUT:
                    stepping = SteppingTypeEnum.StepOut;
                    break;
                }
                DebuggerManager.Instance.SteppingType = stepping;
                DebuggerManager.Instance.Run();
                //Debugger.Step();
            }));

            thread.Start();
            return(VSConstants.S_OK);
        }
示例#2
0
        public int Event(
            IDebugEngine2 pEngine,
            IDebugProcess2 pProcess,
            IDebugProgram2 pProgram,
            IDebugThread2 pThread,
            IDebugEvent2 pEvent,
            ref Guid riidEvent,
            uint dwAttrib
            )
        {
            if (riidEvent == typeof(IDebugProgramCreateEvent2).GUID)
            {
                RaiseStartEvent();
            }
            else if (riidEvent == typeof(IDebugMessageEvent2).GUID)
            {
                IDebugMessageEvent2 debugMessageEvent = pEvent as IDebugMessageEvent2;

                enum_MESSAGETYPE[] messageTypes = new enum_MESSAGETYPE[2];
                messageTypes[0] = enum_MESSAGETYPE.MT_OUTPUTSTRING;
                messageTypes[1] = enum_MESSAGETYPE.MT_REASON_TRACEPOINT;
                string message;
                uint   dwType;
                string helpFilename;
                uint   helpId;

                debugMessageEvent.GetMessage(messageTypes, out message, out dwType, out helpFilename, out helpId);

                // MessageEvents always have a \n on the end
                message = message.TrimEnd(Environment.NewLine.ToCharArray());

                RaiseDebugMessageEvent(message);
            }
            return(0);
        }
示例#3
0
        public int Step(IDebugThread2 pThread, enum_STEPKIND kind, enum_STEPUNIT unit)
        {
            AD7Thread thread = (AD7Thread)pThread;

            try
            {
                if (null == thread || null == thread.GetDebuggedThread())
                {
                    return(Constants.E_FAIL);
                }

                _debuggedProcess.WorkerThread.RunOperation(() => _debuggedProcess.Step(thread.GetDebuggedThread().Id, kind, unit));
            }
            catch (InvalidCoreDumpOperationException)
            {
                return(AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED);
            }
            catch (Exception e)
            {
                _engineCallback.OnError(EngineUtils.GetExceptionDescription(e));
                return(Constants.E_ABORT);
            }

            return(Constants.S_OK);
        }
示例#4
0
        protected BaseDebugStackFrame(DebugDocumentContext.Factory debugDocumentContextFactory,
                                      IChildrenProviderFactory childrenProviderFactory,
                                      DebugCodeContext.Factory debugCodeContextFactory,
                                      CreateDebugExpressionDelegate createExpressionDelegate,
                                      IVariableInformationFactory varInfoFactory,
                                      IVariableInformationEnumFactory varInfoEnumFactory,
                                      AD7FrameInfoCreator ad7FrameInfoCreator,
                                      IRegisterSetsBuilder registerSetsBuilder,
                                      IDebugEngineHandler debugEngineHandler, RemoteFrame frame,
                                      IDebugThread2 thread, IGgpDebugProgram debugProgram,
                                      ITaskExecutor taskExecutor)
        {
            this.debugDocumentContextFactory = debugDocumentContextFactory;
            this._childrenProviderFactory    = childrenProviderFactory;
            this.debugCodeContextFactory     = debugCodeContextFactory;
            this.createExpressionDelegate    = createExpressionDelegate;
            this.varInfoFactory      = varInfoFactory;
            this.varInfoEnumFactory  = varInfoEnumFactory;
            this.ad7FrameInfoCreator = ad7FrameInfoCreator;
            this.registerSetsBuilder = registerSetsBuilder;
            this.debugEngineHandler  = debugEngineHandler;
            this.debugProgram        = debugProgram;
            lldbFrame          = frame;
            this.thread        = thread;
            this._taskExecutor = taskExecutor;

            documentContext = new Lazy <IDebugDocumentContext2>(() => CreateDocumentContext());
            codeContext     = new Lazy <IDebugCodeContext2>(() => CreateCodeContext());
        }
示例#5
0
        // Continue is called from the SDM when it wants execution to continue in the debugee
        // but have stepping state remain. An example is when a tracepoint is executed,
        // and the debugger does not want to actually enter break mode.
        public int Continue(IDebugThread2 pThread)
        {
            // VS Code currently isn't providing a thread Id in certain cases. Work around this by handling null values.
            AD7Thread thread = pThread as AD7Thread;

            try
            {
                if (_pollThread.IsPollThread())
                {
                    _debuggedProcess.Continue(thread?.GetDebuggedThread());
                }
                else
                {
                    _pollThread.RunOperation(() => _debuggedProcess.Continue(thread?.GetDebuggedThread()));
                }
            }
            catch (InvalidCoreDumpOperationException)
            {
                return(AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED);
            }
            catch (Exception e)
            {
                _engineCallback.OnError(EngineUtils.GetExceptionDescription(e));
                return(Constants.E_ABORT);
            }

            return(Constants.S_OK);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int Continue(IDebugThread2 pThread)
        {
            //
            // Continues running this program from a stopped state. Any previous execution state is preserved.
            //

            LoggingUtils.PrintFunction();

            Exception rethrowable = null;

            try
            {
                LoggingUtils.RequireOk(AttachedEngine.NativeDebugger.NativeProgram.Continue(pThread));

                LoggingUtils.RequireOk(AttachedEngine.JavaDebugger.JavaProgram.Continue(pThread));

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

                rethrowable = e;

                return(Constants.E_FAIL);
            }
            finally
            {
                if (rethrowable != null)
                {
                    throw rethrowable;
                }
            }
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int Continue (IDebugThread2 pThread)
    {
      LoggingUtils.PrintFunction ();

      Exception rethrowable = null;

      try
      {
        if (!IsRunning)
        {
          m_debugger.Engine.Broadcast (new CLangDebuggerEvent.ContinueClient (), DebugProgram, null);
        }

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

        rethrowable = e;

        return Constants.E_FAIL;
      }
      finally
      {
        if (rethrowable != null)
        {
          throw rethrowable;
        }
      }
    }
示例#8
0
        public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
        {
            // This method is deprecated. Use the IDebugProcess3::Step method instead.

            mProcess.Step((enum_STEPKIND)sk);
            return(VSConstants.S_OK);
        }
示例#9
0
 private static void __Execute(IDebugThread2 thread, string expression)
 {
     try
     {
         if (thread != null)
         {
             var a_Context = (IEnumDebugFrameInfo2)null;
             if (thread.EnumFrameInfo(enum_FRAMEINFO_FLAGS.FIF_LANGUAGE | enum_FRAMEINFO_FLAGS.FIF_FRAME, 0, out a_Context) == VSConstants.S_OK)
             {
                 var a_Context1 = new FRAMEINFO[1];
                 var a_Context2 = (uint)0;
                 while ((a_Context.Next(1, a_Context1, ref a_Context2) == VSConstants.S_OK) && (a_Context2 > 0))
                 {
                     var a_Context3 = (IDebugExpressionContext2)null;
                     var a_Context4 = a_Context1[0].m_pFrame as IDebugStackFrame2;
                     if (a_Context4 != null)
                     {
                         a_Context4.GetExpressionContext(out a_Context3);
                     }
                     if (a_Context3 != null)
                     {
                         __Execute(a_Context3, expression);
                         break;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         service.Output.WriteError(ex.ToString());
     }
 }
示例#10
0
        private static async Task __AddTracePointAsync(IDebugThread2 thread)
        {
            await Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            try
            {
                if (thread != null)
                {
                    IEnumDebugFrameInfo2 frame;
                    thread.EnumFrameInfo(enum_FRAMEINFO_FLAGS.FIF_FUNCNAME, 0, out frame);
                    var  frameInfo    = new FRAMEINFO[1];
                    uint pceltFetched = 0;
                    while ((frame.Next(1, frameInfo, ref pceltFetched) == VSConstants.S_OK) && (pceltFetched > 0))
                    {
                        if (String.IsNullOrEmpty(frameInfo[0].m_bstrFuncName))
                        {
                            continue;
                        }
                        if (s_DTE != null)
                        {
                            s_DTE.Debugger.Breakpoints.Add(frameInfo[0].m_bstrFuncName);
                            Breakpoint2 breakpoint2 = s_DTE.Debugger.Breakpoints.Item(s_DTE.Debugger.Breakpoints.Count) as Breakpoint2;
                            breakpoint2.Message      = BREAKPOINT_MESSAGE;
                            breakpoint2.BreakWhenHit = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                service.Output.WriteError(ex.ToString());
            }
        }
示例#11
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;
        }
示例#12
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);
        }
示例#13
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #endregion

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region IDebugProgram3 Members

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int ExecuteOnThread(IDebugThread2 pThread)
        {
            //
            // ExecuteOnThread is called when the Session Debug Manager (SDM) wants execution to continue and have stepping state cleared.
            //

            LoggingUtils.PrintFunction();

            try
            {
                if (AttachedEngine == null)
                {
                    throw new InvalidOperationException();
                }

                LoggingUtils.RequireOk(AttachedEngine.NativeDebugger.NativeProgram.ExecuteOnThread(pThread));

                //LoggingUtils.RequireOk (AttachedEngine.JavaDebugger.JavaProgram.ExecuteOnThread (pThread));

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

                return(Constants.E_FAIL);
            }
        }
示例#14
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));
    }
示例#15
0
 /// <summary>
 /// Executes the program. The thread is returned to give the debugger information on which thread the user is viewing when executing.
 /// </summary>
 public int ExecuteOnThread(IDebugThread2 pThread)
 {
     DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.ExecuteOnThread");
     // Resume VM
     ResumeAsync();
     return(VSConstants.S_OK);
 }
示例#16
0
        /// <summary>
        /// Performs a step.
        /// </summary>
        public int Step(IDebugThread2 pThread, enum_STEPKIND stepKind, enum_STEPUNIT stepUnit)
        {
            // This method is deprecated. Use the IDebugProcess3::Step method instead.
            DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.Step kind={0}, step={1}", stepKind, stepUnit);
            Jdwp.StepDepth stepDepth;
            switch (stepKind)
            {
            case enum_STEPKIND.STEP_INTO:
                stepDepth = Jdwp.StepDepth.Into;
                break;

            case enum_STEPKIND.STEP_BACKWARDS:
                return(VSConstants.E_NOTIMPL);

            case enum_STEPKIND.STEP_OVER:
                stepDepth = Jdwp.StepDepth.Over;
                break;

            case enum_STEPKIND.STEP_OUT:
                stepDepth = Jdwp.StepDepth.Out;
                break;

            default:
                return(VSConstants.E_INVALIDARG);
            }

            var stepMode = stepUnit == enum_STEPUNIT.STEP_INSTRUCTION ? StepMode.SingleInstruction : StepMode.Line;

            StepAsync(new StepRequest((DalvikThread)pThread, stepDepth, stepMode));
            return(VSConstants.S_OK);
        }
        /// <summary>
        ///     Sends notification of debugging events to the SDM.
        /// </summary>
        /// <param name="engine">
        ///     An IDebugEngine2 object that represents the debug engine (DE) that is sending this event. A DE is
        ///     required to fill out this parameter.
        /// </param>
        /// <param name="process">
        ///     An IDebugProcess2 object that represents the process in which the event occurs. This parameter is
        ///     filled in by the session debug manager (SDM). A DE always passes a null value for this parameter.
        /// </param>
        /// <param name="program">
        ///     An IDebugProgram2 object that represents the program in which this event occurs. For most events,
        ///     this parameter is not a null value.
        /// </param>
        /// <param name="thread">
        ///     An IDebugThread2 object that represents the thread in which this event occurs. For stopping
        ///     events, this parameter cannot be a null value as the stack frame is obtained from this parameter.
        /// </param>
        /// <param name="event">An IDebugEvent2 object that represents the debug event.</param>
        /// <param name="riidEvent">GUID that identifies which event interface to obtain from the pEvent parameter.</param>
        /// <param name="attribs">A combination of flags from the EVENTATTRIBUTES enumeration.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        public int Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program,
                         IDebugThread2 thread, IDebugEvent2 @event, ref Guid riidEvent, uint attribs)
        {
            var ad7EventCallback = GetAd7EventCallback();

            return(ad7EventCallback.Event(engine, process, program, thread, @event, ref riidEvent, attribs));
        }
示例#18
0
 public EventModel(IDebugEvent2 eventObject, string iidEvent, IDebugProgram2 program, IDebugThread2 thread)
 {
     EventObject = eventObject;
     IidEvent    = iidEvent;
     Program     = program;
     Thread      = thread;
 }
示例#19
0
 /// <summary>
 /// Continues running this program from a stopped state. Any previous execution state (such as a step) is preserved, and the program starts executing again.
 /// </summary>
 public int Continue(IDebugThread2 pThread)
 {
     // This method is deprecated. Use the IDebugProcess3::Continue method instead.
     DLog.Debug(DContext.VSDebuggerComCall, "IDebugProgram2.Continue");
     Debugger.VirtualMachine.ResumeAsync();
     return(VSConstants.S_OK);
 }
示例#20
0
        public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
        {
            var thread = (MonoThread)pThread;

            _dispatcher.Queue(() => DebuggedProcess.Step(thread, sk));
            return(VSConstants.S_OK);
        }
示例#21
0
        private int Continue(IDebugThread2 pThread)
        {
            ThrowIfDisposed();

            if (_firstContinue)
            {
                _firstContinue = false;
            }
            else
            {
                // If _sentContinue is true, then this is a dummy Continue issued to notify the
                // debugger that user has explicitly entered something at the Browse prompt, and
                // we don't actually need to issue the command to R debugger.

                Func <CancellationToken, Task> continueMethod = null;
                lock (_browseLock) {
                    if (_sentContinue != true)
                    {
                        _sentContinue  = true;
                        continueMethod = ct => Tracer.ContinueAsync(ct);
                    }
                }

                if (continueMethod != null)
                {
                    TaskExtensions.RunSynchronouslyOnUIThread(continueMethod);
                }
            }

            return(VSConstants.S_OK);
        }
示例#22
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
        {
            //
            // Performs a step.
            //

            LoggingUtils.PrintFunction();

            try
            {
                if (AttachedEngine == null)
                {
                    throw new InvalidOperationException();
                }

                LoggingUtils.RequireOk(AttachedEngine.NativeDebugger.NativeProgram.Step(pThread, sk, Step));

                //LoggingUtils.RequireOk (AttachedEngine.JavaDebugger.JavaProgram.Step (pThread, sk, Step));

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

                return(Constants.E_FAIL);
            }
        }
示例#23
0
        public static int Id(this IDebugThread2 thread)
        {
            uint unsignedId;

            thread.GetThreadId(out unsignedId);
            return(unchecked ((int)unsignedId));
        }
示例#24
0
        // Token: 0x06000182 RID: 386 RVA: 0x000060AC File Offset: 0x000042AC
        public int Step(IDebugThread2 t, enum_STEPKIND u_kind, enum_STEPUNIT u_step)
        {
            Thread thread = (Thread)t;

            if (u_step == enum_STEPUNIT.STEP_INSTRUCTION)
            {
                Utils.Message("STEP INSTRUCTION !");
            }
            switch (u_kind)
            {
            case enum_STEPKIND.STEP_INTO:
                this.Session.StepLine();
                break;

            case enum_STEPKIND.STEP_OVER:
                this.Session.NextLine();
                break;

            case enum_STEPKIND.STEP_OUT:
                this.Session.Finish();
                break;

            default:
                return(1);
            }
            return(0);
        }
示例#25
0
        public int ExecuteOnThread(IDebugThread2 pThread)
        {
            var thread = (MonoThread)pThread;

            _dispatcher.Queue(() => DebuggedProcess.Execute(thread));
            return(VSConstants.S_OK);
        }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    #endregion

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    #region IDebugProgram3 Members

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public int ExecuteOnThread (IDebugThread2 pThread)
    {
      // 
      // Executes the debugger program. The thread is returned to give the debugger information on which thread the user is viewing when executing the program.
      // 

      LoggingUtils.PrintFunction ();

      try
      {
        uint threadId;

        CLangDebuggeeThread thread = pThread as CLangDebuggeeThread;

        LoggingUtils.RequireOk (thread.GetThreadId (out threadId));

        string command = "-thread-select " + threadId;

        MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand (command);

        MiResultRecord.RequireOk (resultRecord, command);

        CurrentThreadId = threadId;

        LoggingUtils.RequireOk (Execute ());

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

        return Constants.E_FAIL;
      }
    }
        /// <summary>
        /// Continues running this program from a stopped state. Any previous execution state (such
        /// as a step) is preserved, and the program starts executing again.
        /// </summary>
        /// <param name="pThread">An IDebugThread2 object that represents the thread.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// This method is called on this program regardless of how many programs are being debugged,
        /// or which program generated the stopping event. The implementation must retain the previous
        /// execution state (such as a step) and continue execution as though it had never stopped
        /// before completing its prior execution. That is, if a thread in this program was doing a
        /// step-over operation and was stopped because some other program stopped, and then this
        /// method was called, the program must complete the original step-over operation.
        ///
        /// Do not send a stopping event or an immediate (synchronous) event to IDebugEventCallback2.Event
        /// while handling this call; otherwise the debugger might stop responding.
        /// </remarks>
        public int Continue(IDebugThread2 pThread)
        {
#if true
            if (_suspended != 0)
            {
                Interlocked.Decrement(ref _suspended);
                Task.Factory.StartNew(VirtualMachine.Resume).HandleNonCriticalExceptions();
            }

            return(VSConstants.S_OK);
#else
            if (pThread == null)
            {
                Task.Factory.StartNew(VirtualMachine.Resume).HandleNonCriticalExceptions();
                return(VSConstants.S_OK);
            }

            JavaDebugThread javaThread = pThread as JavaDebugThread;
            if (javaThread == null)
            {
                return(VSConstants.E_INVALIDARG);
            }

            Task.Factory.StartNew(() => javaThread.Resume()).HandleNonCriticalExceptions();
            return(VSConstants.S_OK);
#endif
        }
        private IDebugStackFrame2 GetCurrentStackFrame(IDebugThread2 thread)
        {
            IEnumDebugFrameInfo2 enumDebugFrameInfo2;

            thread.EnumFrameInfo(enum_FRAMEINFO_FLAGS.FIF_FRAME, 10, out enumDebugFrameInfo2);

            uint pCeltFetched = 0;

            IDebugStackFrame2 stackFrame = null;

            uint count;

            enumDebugFrameInfo2.GetCount(out count);
            FRAMEINFO[] frameinfo = new FRAMEINFO[1];
            if (count > 0 && enumDebugFrameInfo2.Next(1, frameinfo, ref pCeltFetched) == VSConstants.S_OK)
            {
                stackFrame = frameinfo[0].m_pFrame;
            }
            else
            {
                throw new InvalidOperationException("IDebugStackFrame2 is not available");
            }

            return(stackFrame);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
        {
            //
            // Performs a step.
            //

            LoggingUtils.PrintFunction();

            try
            {
                CLangDebuggeeThread thread = pThread as CLangDebuggeeThread;

                LoggingUtils.RequireOk(thread.GetThreadId(out uint threadId));

                GdbClient.StepType stepType = (GdbClient.StepType)Step;

                switch (sk)
                {
                case enum_STEPKIND.STEP_INTO:
                {
                    m_debugger.GdbClient.StepInto(threadId, stepType, false);

                    break;
                }

                case enum_STEPKIND.STEP_OVER:
                {
                    m_debugger.GdbClient.StepOver(threadId, stepType, false);

                    break;
                }

                case enum_STEPKIND.STEP_OUT:
                {
                    m_debugger.GdbClient.StepOut(threadId, stepType, false);

                    break;
                }

                case enum_STEPKIND.STEP_BACKWARDS:
                {
                    throw new NotImplementedException();
                }
                }

                return(Constants.S_OK);
            }
            catch (NotImplementedException e)
            {
                LoggingUtils.HandleException(e);

                return(Constants.E_NOTIMPL);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                return(Constants.E_FAIL);
            }
        }
示例#30
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);
            }
        }
示例#31
0
        private void ExtractFrameContent(IDebugThread2 pThread)
        {
            var props = new THREADPROPERTIES[1];

            pThread.GetThreadProperties(enum_THREADPROPERTY_FIELDS.TPF_ALLFIELDS, props);


            //IDebugThread2::EnumFrameInfo
            IEnumDebugFrameInfo2 frame;

            pThread.EnumFrameInfo(CreateMask(), 0, out frame);
            uint frames;

            frame.GetCount(out frames);
            var  frameInfo    = new FRAMEINFO[1];
            uint pceltFetched = 0;

            while (frame.Next(1, frameInfo, ref pceltFetched) == VSConstants.S_OK && pceltFetched > 0)
            {
                var fr = frameInfo[0].m_pFrame as IDebugStackFrame3;
                Trace.WriteLine(string.Format("Frame func {0}", frameInfo[0].m_bstrFuncName));
                continue;

                IDebugExpressionContext2 expressionContext;
                fr.GetExpressionContext(out expressionContext);
                IDebugExpression2 de; string error; uint errorCode;
                if (expressionContext != null)
                {
                    expressionContext.ParseText("exception.InnerException.StackTrace", enum_PARSEFLAGS.PARSE_EXPRESSION, 0, out de, out error, out errorCode);
                    IDebugProperty2 dp2;
                    var             res = de.EvaluateSync(enum_EVALFLAGS.EVAL_RETURNVALUE, 5000, null, out dp2);

                    var myInfo = new DEBUG_PROPERTY_INFO[1];
                    dp2.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, 5000, null, 0, myInfo);
                    var stackTrace = myInfo[0].bstrValue;

                    IDebugProperty2 dp;
                    fr.GetDebugProperty(out dp);
                    IEnumDebugPropertyInfo2 prop;
                    dp.EnumChildren(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, ref DebugFilterGuids.guidFilterAllLocals,
                                    enum_DBG_ATTRIB_FLAGS.DBG_ATTRIB_ACCESS_ALL,
                                    /*(uint)enum_DBGPROP_ATTRIB_FLAGS.DBGPROP_ATTRIB_ACCESS_PUBLIC,*/
                                    null, 5000, out prop);

                    EnumerateDebugPropertyChildren(prop);
                }
                //Guid filter = dbgGuids.guidFilterAllLocals; uint pElements; IEnumDebugPropertyInfo2 prop;
                //fr.EnumProperties(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL, 0, ref filter, 5000, out pElements, out prop);

                //fr.GetUnwindCodeContext

                //fr.EnumProperties(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_ALL);
                //fr.GetUnwindCodeContext
                //ulong intCookie;
                //fr.InterceptCurrentException(enum_INTERCEPT_EXCEPTION_ACTION.IEA_INTERCEPT, out intCookie);
                //fr.GetExpressionContext(
                //var s = fr.ToString();
            }
        }
示例#32
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int EnumThreads(out IEnumDebugThreads2 ppEnum)
        {
            //
            // Enumerates the threads that are running in this program.
            //

            LoggingUtils.PrintFunction();

            try
            {
                if (AttachedEngine == null)
                {
                    throw new InvalidOperationException();
                }

                List <IDebugThread2> threads = new List <IDebugThread2> ();

                uint count;

                {
                    LoggingUtils.RequireOk(AttachedEngine.NativeDebugger.NativeProgram.EnumThreads(out ppEnum));

                    LoggingUtils.RequireOk(ppEnum.GetCount(out count));

                    IDebugThread2 [] threadArray = new IDebugThread2 [count];

                    LoggingUtils.RequireOk(ppEnum.Next(count, threadArray, ref count));

                    threads.AddRange(threadArray);
                }

                {
                    LoggingUtils.RequireOk(AttachedEngine.JavaDebugger.JavaProgram.EnumThreads(out ppEnum));

                    LoggingUtils.RequireOk(ppEnum.GetCount(out count));

                    IDebugThread2 [] threadArray = new IDebugThread2 [count];

                    LoggingUtils.RequireOk(ppEnum.Next(count, threadArray, ref count));
                }

                ppEnum = new DebuggeeThread.Enumerator(threads);

                if (ppEnum == null)
                {
                    throw new InvalidOperationException();
                }

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

                ppEnum = null;

                return(Constants.E_FAIL);
            }
        }
示例#33
0
        public int ExecuteOnThread(IDebugThread2 pThread)
        {
            DebugHelper.TraceEnteringMethod();
            var thread = (AD7Thread)pThread;

            _dispatcher.Queue(() => DebuggedProcess.Execute(thread));
            return(VSConstants.S_OK);
        }
        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);
        }
        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;
        }
示例#36
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;
        }
示例#37
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);
     }
 }
示例#38
0
        public void Send(IDebugEvent2 eventObject, string iidEvent, IDebugThread2 thread)
        {
            IDebugProgram2 program = _engine;
            if (!_engine.ProgramCreateEventSent)
            {
                // Any events before programe create shouldn't include the program
                program = null;
            }

            Send(eventObject, iidEvent, program, thread);
        }
        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;
        }
示例#40
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;
        }
        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;
        }
示例#43
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;
        }
示例#44
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;
        }
示例#45
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;
        }
示例#46
0
        // Continue is called from the SDM when it wants execution to continue in the debugee
        // but have stepping state remain. An example is when a tracepoint is executed,
        // and the debugger does not want to actually enter break mode.
        public int Continue(IDebugThread2 pThread)
        {
            // VS Code currently isn't providing a thread Id in certain cases. Work around this by handling null values.
            AD7Thread thread = pThread as AD7Thread;

            try
            {
                if (_pollThread.IsPollThread())
                {
                    _debuggedProcess.Continue(thread?.GetDebuggedThread());
                }
                else
                {
                    _pollThread.RunOperation(() => _debuggedProcess.Continue(thread?.GetDebuggedThread()));
                }
            }
            catch (InvalidCoreDumpOperationException)
            {
                return AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED;
            }

            return Constants.S_OK;
        }
示例#47
0
 /// <summary>
 /// Executes the debugger program. The thread is returned to give the debugger information on which
 /// thread the user is viewing when executing the program.
 /// </summary>
 /// <param name="pThread">An IDebugThread2 object.</param>
 /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
 /// <remarks>
 /// There are three different ways that a debugger can resume execution after stopping:
 ///
 /// <list type="bullet">
 /// <item>Execute: Cancel any previous step, and run until the next breakpoint and so on.</item>
 /// <item>Step: Cancel any old step, and run until the new step completes.</item>
 /// <item>Continue: Run again, and leave any old step active.</item>
 /// </list>
 ///
 /// The thread passed to ExecuteOnThread is useful when deciding which step to cancel. If you do not
 /// know the thread, running execute cancels all steps. With knowledge of the thread, you only need
 /// to cancel the step on the active thread.
 /// </remarks>
 public int ExecuteOnThread(IDebugThread2 pThread)
 {
     Task.Factory.StartNew(() => _causeBreakRequest.IsEnabled = false);
     return Continue(pThread);
 }
示例#48
0
        public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
        {
            JavaDebugThread thread = pThread as JavaDebugThread;
            if (thread == null)
                return VSConstants.E_INVALIDARG;

            StepSize size;
            StepDepth depth;
            switch (Step)
            {
            case enum_STEPUNIT.STEP_INSTRUCTION:
                size = StepSize.Instruction;
                break;

            case enum_STEPUNIT.STEP_LINE:
                size = StepSize.Line;
                break;

            case enum_STEPUNIT.STEP_STATEMENT:
                size = VirtualMachine.GetCanStepByStatement() ? StepSize.Statement : StepSize.Line;
                break;

            default:
                throw new NotSupportedException();
            }

            switch (sk)
            {
            case enum_STEPKIND.STEP_INTO:
                depth = StepDepth.Into;
                break;

            case enum_STEPKIND.STEP_OUT:
                depth = StepDepth.Out;
                break;

            case enum_STEPKIND.STEP_OVER:
                depth = StepDepth.Over;
                break;

            case enum_STEPKIND.STEP_BACKWARDS:
            default:
                throw new NotSupportedException();
            }

            IStepRequest stepRequest = thread.GetStepRequest(size, depth);
            if (stepRequest == null)
                throw new InvalidOperationException();

            Task.Factory.StartNew(() =>
                {
                    // make sure the global "Break All" step request is disabled
                    this._causeBreakRequest.IsEnabled = false;
                    stepRequest.IsEnabled = true;
                    VirtualMachine.Resume();
                    Interlocked.Decrement(ref _suspended);
                }).HandleNonCriticalExceptions();

            return VSConstants.S_OK;
        }
示例#49
0
 public int EnumCodePaths(IDebugThread2 pThread, IDebugCodeContext2 pStart, /*enum_STEPUNIT*/uint stepUnit, out IEnumDebugCodePaths90 ppEnum)
 {
     throw new NotImplementedException();
 }
示例#50
0
        /// <summary>
        /// Continues running this program from a stopped state. Any previous execution state (such
        /// as a step) is preserved, and the program starts executing again.
        /// </summary>
        /// <param name="pThread">An IDebugThread2 object that represents the thread.</param>
        /// <returns>If successful, returns S_OK; otherwise, returns an error code.</returns>
        /// <remarks>
        /// This method is called on this program regardless of how many programs are being debugged,
        /// or which program generated the stopping event. The implementation must retain the previous
        /// execution state (such as a step) and continue execution as though it had never stopped
        /// before completing its prior execution. That is, if a thread in this program was doing a
        /// step-over operation and was stopped because some other program stopped, and then this
        /// method was called, the program must complete the original step-over operation.
        /// 
        /// Do not send a stopping event or an immediate (synchronous) event to IDebugEventCallback2.Event
        /// while handling this call; otherwise the debugger might stop responding.
        /// </remarks>
        public int Continue(IDebugThread2 pThread)
        {
#if true
            if (_suspended != 0)
            {
                Interlocked.Decrement(ref _suspended);
                Task.Factory.StartNew(VirtualMachine.Resume).HandleNonCriticalExceptions();
            }

            return VSConstants.S_OK;
#else
            if (pThread == null)
            {
                Task.Factory.StartNew(VirtualMachine.Resume).HandleNonCriticalExceptions();
                return VSConstants.S_OK;
            }

            JavaDebugThread javaThread = pThread as JavaDebugThread;
            if (javaThread == null)
                return VSConstants.E_INVALIDARG;

            Task.Factory.StartNew(() => javaThread.Resume()).HandleNonCriticalExceptions();
            return VSConstants.S_OK;
#endif
        }
示例#51
0
 /// <summary>
 /// Performs a step. This method is deprecated. Use the IDebugProcess3::Step method instead. 
 /// (http://msdn.microsoft.com/en-us/library/bb162134.aspx)
 /// Not implemented because this class is not used by the debug engine. Read the description of this class at the top.
 /// </summary>
 /// <param name="pThread"> An IDebugThread2 object that represents the thread being stepped. </param>
 /// <param name="sk"> A value from the STEPKIND enumeration that specifies the kind of step. </param>
 /// <param name="Step"> A value from the STEPUNIT enumeration that specifies the unit of step. </param>
 /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns>
 public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
 {
     return VSConstants.S_OK;
 }
 public int Step(IDebugThread2 pThread, enum_STEPKIND sk, enum_STEPUNIT Step)
 {
   Debug.WriteLine("AD7Process: Step");
   
   return VSConstants.S_OK;
 }
示例#53
0
 // Gets the thread associated with a stack frame.
 int IDebugStackFrame2.GetThread(out IDebugThread2 thread)
 {
     thread = Thread;
     return Constants.S_OK;
 }
示例#54
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public void Broadcast (IDebugEventCallback2 callback, IDebugEvent2 debugEvent, IDebugProgram2 program, IDebugThread2 thread)
    {
      LoggingUtils.PrintFunction ();

      if (callback == null)
      {
        throw new ArgumentNullException ("callback");
      }

      Guid eventGuid = ComUtils.GuidOf (debugEvent);

      uint eventAttributes = 0;

      LoggingUtils.RequireOk (debugEvent.GetAttributes (out eventAttributes));

      if (((eventAttributes & (uint) enum_EVENTATTRIBUTES.EVENT_STOPPING) != 0) && (thread == null))
      {
        throw new ArgumentNullException ("thread", "For stopping events, this parameter cannot be a null value as the stack frame is obtained from this parameter.");
      }

      try
      {
        int handle = callback.Event (this, null, program, thread, debugEvent, ref eventGuid, eventAttributes);

        if (handle != Constants.E_NOTIMPL)
        {
          LoggingUtils.RequireOk (handle);
        }
      }
      catch (Exception e)
      {
        LoggingUtils.HandleException (e);

        throw;
      }
      finally
      {
        if ((eventAttributes & (uint) enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS) != 0)
        {
          while (!m_broadcastHandleLock.WaitOne (0))
          {
            Thread.Sleep (100);
          }
        }
      }
    }
示例#55
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public void Broadcast (IDebugEvent2 debugEvent, IDebugProgram2 program, IDebugThread2 thread)
    {
      Guid eventGuid = ComUtils.GuidOf (debugEvent);

      if ((m_cLangCallback != null) && (m_cLangCallback.IsRegistered (ref eventGuid)))
      {
        Broadcast (m_cLangCallback, debugEvent, program, thread);
      }
      else if ((m_javaLangCallback != null) && (m_javaLangCallback.IsRegistered (ref eventGuid)))
      {
        Broadcast (m_javaLangCallback, debugEvent, program, thread);
      }
      else
      {
        Broadcast (m_sdmCallback, debugEvent, program, thread);
      }
    }
示例#56
0
        // ExecuteOnThread is called when the SDM wants execution to continue and have
        // stepping state cleared.
        public int ExecuteOnThread(IDebugThread2 pThread)
        {
            AD7Thread thread = (AD7Thread)pThread;

            try
            {
                _pollThread.RunOperation(() => _debuggedProcess.Execute(thread?.GetDebuggedThread()));
            }
            catch (InvalidCoreDumpOperationException)
            {
                return AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED;
            }

            return Constants.S_OK;
        }
示例#57
0
        public int Step(IDebugThread2 pThread, enum_STEPKIND kind, enum_STEPUNIT unit)
        {
            AD7Thread thread = (AD7Thread)pThread;

            try
            {
                if (null == thread || null == thread.GetDebuggedThread())
                {
                    return Constants.E_FAIL;
                }

                _debuggedProcess.WorkerThread.RunOperation(() => _debuggedProcess.Step(thread.GetDebuggedThread().Id, kind, unit));
            }
            catch (InvalidCoreDumpOperationException)
            {
                return AD7_HRESULT.E_CRASHDUMP_UNSUPPORTED;
            }

            return Constants.S_OK;
        }
 public int Continue(IDebugThread2 pThread)
 {
   Debug.WriteLine("AD7Process: Continue");
   return VSConstants.E_NOTIMPL;
 }
 public int Execute(IDebugThread2 pThread)
 {
   Debug.WriteLine("AD7Process: Execute");
   return VSConstants.E_NOTIMPL;
 }
示例#60
0
 /// <summary>
 /// Continues running this program from a stopped state. Any previous execution state (such as a step) is preserved, and 
 /// the program starts executing again. (http://msdn.microsoft.com/en-us/library/bb162148.aspx).
 /// Not implemented because this class is not used by the debug engine. Read the description of this class at the top.
 /// </summary>
 /// <param name="pThread"> An IDebugThread2 object that represents the thread. </param>
 /// <returns> VSConstants.S_OK. </returns>
 public int Continue(IDebugThread2 pThread)
 {
     // This method is not called by the debug engine.
     return VSConstants.S_OK;
 }