Example #1
0
 IBreakpoint Add(Breakpoint breakpoint)
 {
     if (_debugSessionContext.ProgramState == ProgramState.Terminated)
     {
         throw new InvalidOperationException(
                   "Breakpoint cannot be added because the program has terminated.");
     }
     _breakpoints.Add(breakpoint);
     if (_debugSessionContext.ProgramState == ProgramState.Running ||
         _debugSessionContext.ProgramState == ProgramState.AtBreak)
     {
         _jobQueue.Push(_bindBreakpointJobFactory.Create(() => Bind(breakpoint)));
     }
     return(breakpoint);
 }
Example #2
0
        // Note that this method can be called from a thread other than the test main thread.
        public int HandleCallbackEvent(IDebugEngine2 pEngine, IDebugProcess2 pProcess,
                                       IDebugProgram2 pProgram, IDebugThread2 pThread,
                                       IDebugEvent2 pEvent)
        {
            if (pEvent is IDebugBreakpointEvent2 || pEvent is IDebugBreakEvent2 ||
                pEvent is IDebugStepCompleteEvent2)
            {
                _queue.Push(
                    _programStoppedJobFactory.Create(pEngine, pEvent, _debugSessionContext,
                                                     pThread));
            }
            else if (pEvent is IDebugProgramDestroyEvent2)
            {
                _queue.Push(
                    _programTerminatedJobFactory.Create(pEngine, pEvent, _debugSessionContext));
            }

            var pProgram3 = pProgram as IDebugProgram3;

            if (pProgram3 == null)
            {
                // TODO: Ensure program can be cast to IDebugProgram3 without
                // throwing across the COM/interop boundary.
                throw new NotSupportedException(
                          "'pProgram' must be castable to type " +
                          $"{nameof(IDebugProgram3)} but is of type {pProgram.GetType()}");
            }

            _queue.Push(_broadcastDebugEventJobFactory.Create(() =>
            {
                DebugEventHandler handler = DebugEvent;
                handler?.Invoke(new DebugEventArgs
                {
                    DebugEngine = pEngine,
                    Process     = pProcess,
                    Program     = pProgram3,
                    Thread      = pThread,
                    Event       = pEvent
                });
            }, pEvent));

            return(VSConstants.S_OK);
        }
Example #3
0
        public IVariableEntry Refresh()
        {
            if (State == VariableState.Pending)
            {
                throw new InvalidOperationException("Another refresh operation is still pending.");
            }

            if (_debugSessionContext.SelectedStackFrame == null)
            {
                throw new InvalidOperationException(
                          $"No stack frame selected while trying to refresh {this}.");
            }

            State = VariableState.Pending;
            _jobQueue.Push(_refreshVariableJobFactory.Create(
                               () => _dataSource.GetCurrentState(this, CurrentStateRetrievalCallback)));
            return(this);
        }
 public void Start() => _jobQueue.Push(_launchAndAttachJobFactory.Create(LaunchAndAttach));
Example #5
0
 void TimerExpired(object sender, ElapsedEventArgs e)
 {
     _jobQueue.Push(this);
 }