public void RegisterAndRetrievePendingBreakpoint()
        {
            IPendingBreakpoint pendingBreakpoint;
            bool result = breakpointManager.GetPendingBreakpointById(ID, out pendingBreakpoint);

            Assert.IsFalse(result);
            breakpointManager.RegisterPendingBreakpoint(mockPendingBreakpoint);
            result = breakpointManager.GetPendingBreakpointById(ID, out pendingBreakpoint);
            Assert.IsTrue(result);
            Assert.AreEqual(ID, pendingBreakpoint.GetId());
        }
        public void OnBreakpointChanged(BreakpointEventType eventType)
        {
            IPendingBreakpoint[] breakpoints =
            {
                GetBreakpointSubstitute(1), GetBreakpointSubstitute(2),
                GetBreakpointSubstitute(3)
            };
            _breakpointManager.GetPendingBreakpointById(Arg.Any <int>(), out IPendingBreakpoint _)
            .Returns(x =>
            {
                x[1] = breakpoints.First(b => b.GetId() == (int)x[0]);
                return(true);
            });
            SbEvent evnt = Substitute.For <SbEvent>();
            IEventBreakpointData breakpointData = Substitute.For <IEventBreakpointData>();

            evnt.IsBreakpointEvent.Returns(true);
            evnt.BreakpointData.Returns(breakpointData);
            breakpointData.BreakpointId.Returns(2);
            breakpointData.EventType.Returns(eventType);

            _attachedProgram.Start(Substitute.For <IDebugEngine2>());
            _listenerSubscriber.BreakpointChanged +=
                Raise.EventWith(null, new BreakpointChangedEventArgs(evnt));

            breakpoints[0].DidNotReceive().UpdateLocations();
            breakpoints[1].Received(1).UpdateLocations();
            breakpoints[2].DidNotReceive().UpdateLocations();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handle a breakpoint stop event.
        /// </summary>
        DebugEvent HandleBreakpointStop(RemoteThread thread)
        {
            uint stopReasonDataCount = thread.GetStopReasonDataCount();
            List <IDebugBoundBreakpoint2> boundBreakpoints = new List <IDebugBoundBreakpoint2>();

            for (uint i = 0; i < stopReasonDataCount; i += 2)
            {
                int pendingId = (int)thread.GetStopReasonDataAtIndex(i);
                int boundId   = (int)thread.GetStopReasonDataAtIndex(i + 1);
                if (!_lldbBreakpointManager.GetPendingBreakpointById(
                        pendingId,out IPendingBreakpoint pendingBreakpoint))
                {
                    Trace.WriteLine($"Warning: Missing pending breakpoint with ID {pendingId}");
                    continue;
                }

                if (!pendingBreakpoint.GetBoundBreakpointById(boundId,
                                                              out IBoundBreakpoint boundBreakpoint))
                {
                    Trace.WriteLine(
                        $"Warning: Missing bound breakpoint with ID {pendingId}.{boundId}");
                    continue;
                }
                boundBreakpoint.OnHit();
                boundBreakpoints.Add(boundBreakpoint);
            }
            if (boundBreakpoints.Count <= 0)
            {
                return(null);
            }
            return(new BreakpointEvent(
                       _boundBreakpointEnumFactory.Create(boundBreakpoints.ToArray())));
        }
Exemplo n.º 4
0
        /// <summary>
        /// If a remote breakpoint gets bound, binds local breakpoint as well.
        /// </summary>
        void OnBreakpointChanged(object sender, BreakpointChangedEventArgs args)
        {
            IEventBreakpointData breakpointData = args.Event.BreakpointData;

            if (breakpointData.EventType.HasFlag(BreakpointEventType.LOCATIONS_ADDED) ||
                breakpointData.EventType.HasFlag(BreakpointEventType.LOCATIONS_REMOVED))
            {
                if (_breakpointManager.GetPendingBreakpointById(
                        breakpointData.BreakpointId, out IPendingBreakpoint pendingBreakpoint))
                {
                    pendingBreakpoint.UpdateLocations();
                }
            }
        }
        public void HandleEventInvalidPendingBreakpoint()
        {
            // Return null and false for one of the pending breakpoints.
            _mockBreakpointManager
            .GetPendingBreakpointById(Arg.Any <int>(), out IPendingBreakpoint _)
            .ReturnsForAnyArgs(x => {
                int id = (int)x[0];
                switch (id)
                {
                case 1:
                    x[1] = _mockPendingBreakpoint1;
                    return(true);

                default:
                    x[1] = null;
                    return(false);
                }
            });

            // We want to inspect the BreakpointEvent further, so capture it when OnSendEvent is
            // called.
            BreakpointEvent resultEvent = null;

            _mockDebugEngineHandler.SendEvent(
                Arg.Do(delegate(DebugEvent x) { resultEvent = (BreakpointEvent)x; }), _mockProgram,
                _mockRemoteThread);

            RaiseSingleStateChanged();

            _mockDebugEngineHandler.Received(1).SendEvent(
                Arg.Is <DebugEvent>(x => x is BreakpointEvent), _mockProgram, _mockRemoteThread);
            AssertBreakpointEvent(
                resultEvent,
                new List <IDebugBoundBreakpoint2> {
                _mockBoundBreakpoint2, _mockBoundBreakpoint3
            });
        }