public void SetUp()
        {
            SbBreakpointLocation mockBreakpointLocation = Substitute.For <SbBreakpointLocation>();

            mockBreakpointLocation.GetAddress().Returns((SbAddress)null);

            boundBreakpoint = new DebugBoundBreakpoint.Factory(null, null, null)
                              .Create(null, mockBreakpointLocation, null, Guid.Empty);
            boundBreakpoint.Delete();
        }
        public void SetUp()
        {
            string name = "";

            mockBreakpoint         = Substitute.For <RemoteBreakpoint>();
            lineEntry              = new LineEntryInfo();
            mockPendingBreakpoint  = Substitute.For <IDebugPendingBreakpoint2>();
            mockBreakpointLocation = Substitute.For <SbBreakpointLocation>();
            mockAddress            = Substitute.For <SbAddress>();
            mockAddress.GetLineEntry().Returns(lineEntry);
            mockBreakpointLocation.GetHitCount().Returns(HIT_COUNT);
            mockBreakpointLocation.GetLoadAddress().Returns(ADDRESS);
            mockBreakpointLocation.GetBreakpoint().Returns(mockBreakpoint);
            mockBreakpointLocation.GetId().Returns(ID);
            mockBreakpointLocation.GetAddress().Returns(mockAddress);
            mockprogram         = Substitute.For <IDebugProgram2>();
            mockDocumentContext = Substitute.For <IDebugDocumentContext2>();
            mockDocumentContext.GetName(enum_GETNAME_TYPE.GN_NAME, out name).Returns(
                x =>
            {
                x[1] = NAME;
                return(VSConstants.S_OK);
            });
            mockBreakpointResolution   = Substitute.For <IDebugBreakpointResolution2>();
            mockDocumentContextFactory = Substitute.For <DebugDocumentContext.Factory>();
            mockDocumentContextFactory.Create(lineEntry).Returns(mockDocumentContext);
            mockCodeContext        = Substitute.For <IDebugCodeContext2>();
            mockCodeContextFactory = Substitute.For <DebugCodeContext.Factory>();
            mockCodeContextFactory.Create(ADDRESS, NAME,
                                          mockDocumentContext, Guid.Empty).Returns(mockCodeContext);
            mockBreakpointResolutionFactory =
                Substitute.For <DebugBreakpointResolution.Factory>();
            mockBreakpointResolutionFactory.Create(mockCodeContext, mockprogram).Returns(
                mockBreakpointResolution);
            boundBreakpointFactory = new DebugBoundBreakpoint.Factory(mockDocumentContextFactory,
                                                                      mockCodeContextFactory, mockBreakpointResolutionFactory);
            boundBreakpoint = boundBreakpointFactory.Create(
                mockPendingBreakpoint, mockBreakpointLocation, mockprogram, Guid.Empty);
        }
        public void SetUp()
        {
            _mockSbListener         = Substitute.For <SbListener>();
            _mockSbProcess          = Substitute.For <SbProcess>();
            _mockSbEvent            = Substitute.For <SbEvent>();
            _mockRemoteThread       = Substitute.For <RemoteThread>();
            _mockBreakpointManager  = Substitute.For <IBreakpointManager>();
            _mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>();

            _mockPendingBreakpoint1 = Substitute.For <IPendingBreakpoint>();
            _mockPendingBreakpoint2 = Substitute.For <IPendingBreakpoint>();
            _mockBoundBreakpoint1   = Substitute.For <IBoundBreakpoint>();
            _mockBoundBreakpoint2   = Substitute.For <IBoundBreakpoint>();
            _mockBoundBreakpoint3   = Substitute.For <IBoundBreakpoint>();
            _mockWatchpoint         = Substitute.For <IWatchpoint>();
            _mockProgram            = Substitute.For <IGgpDebugProgram>();

            MockEvent(EventType.STATE_CHANGED, StateType.STOPPED, false);
            MockListener(_mockSbEvent, true);
            MockThread(_mockRemoteThread, StopReason.BREAKPOINT, _breakpointStopData);
            MockProcess(new List <RemoteThread> {
                _mockRemoteThread
            });
            MockBreakpointManager();

            _mockListenerSubscriber = Substitute.For <LldbListenerSubscriber>(_mockSbListener);

            var threadContext = new FakeMainThreadContext();

            _eventManager =
                new LldbEventManager
                .Factory(new BoundBreakpointEnumFactory(), threadContext.JoinableTaskContext)
                .Create(_mockDebugEngineHandler, _mockBreakpointManager, _mockProgram,
                        _mockSbProcess, _mockListenerSubscriber);

            var lldbEventManager = _eventManager as LldbEventManager;

            lldbEventManager?.SubscribeToChanges();
        }
Beispiel #4
0
        public void UpdateLocations()
        {
            var  remoteLocations           = new Dictionary <int, SbBreakpointLocation>();
            uint lldbBreakpointLocationNum = _lldbBreakpoint.GetNumLocations();

            for (uint i = 0; i < lldbBreakpointLocationNum; i++)
            {
                SbBreakpointLocation breakpointLocation = _lldbBreakpoint.GetLocationAtIndex(i);
                if (breakpointLocation == null)
                {
                    Trace.WriteLine("Failed to get breakpoint location.");
                    continue;
                }

                remoteLocations.Add(breakpointLocation.GetId(), breakpointLocation);
            }

            foreach (int boundBreakpointId in _boundBreakpoints.Keys.ToList())
            {
                if (!remoteLocations.ContainsKey(boundBreakpointId))
                {
                    _boundBreakpoints[boundBreakpointId].Delete();
                    _boundBreakpoints.Remove(boundBreakpointId);
                }
            }

            List <IDebugBoundBreakpoint2> newLocations = new List <IDebugBoundBreakpoint2>();

            foreach (SbBreakpointLocation remoteLocation in remoteLocations.Values)
            {
                if (!_boundBreakpoints.ContainsKey(remoteLocation.GetId()))
                {
                    // Make sure the newly created bound breakpoints have the same
                    // enabled state as the pending breakpoint.
                    IBoundBreakpoint boundBreakpoint =
                        _debugBoundBreakpointFactory.Create(Self, remoteLocation, _program,
                                                            _requestInfo.guidLanguage);
                    boundBreakpoint.Enable(Convert.ToInt32(_enabled));
                    if (_breakpointCondition.VariableCondition.HasValue)
                    {
                        boundBreakpoint.SetCondition(_breakpointCondition.VariableCondition.Value);
                    }

                    if (_breakpointCondition.PassCount.HasValue)
                    {
                        boundBreakpoint.SetPassCount(_breakpointCondition.PassCount.Value);
                    }

                    _boundBreakpoints.Add(remoteLocation.GetId(), boundBreakpoint);
                    newLocations.Add(boundBreakpoint);
                }
            }

            if (_boundBreakpoints.Count == 0)
            {
                SetError(enum_BP_ERROR_TYPE.BPET_GENERAL_WARNING, _breakpointLocationNotSet);
            }
            else
            {
                _breakpointError = null;
            }

            if (newLocations.Any())
            {
                _breakpointManager.EmitBreakpointBoundEvent(
                    Self, newLocations, _breakpointBoundEnumFactory);
            }
        }
Beispiel #5
0
 public bool GetBoundBreakpointById(int id, out IBoundBreakpoint boundBreakpoint) =>
 _boundBreakpoints.TryGetValue(id, out boundBreakpoint);