public int GetWatchpointRefCount(IWatchpoint watchpoint) { int currentCount = 0; int id = watchpoint.GetId(); if (id != -1) { watchpointsCount.TryGetValue(id, out currentCount); } return(currentCount); }
public void CanBindConditionWhenChanged() { SetCondition(enum_BP_COND_STYLE.BP_COND_WHEN_CHANGED, "true"); watchpoint = watchpointFactory.Create(mockBreakpointManager, mockBreakpointRequest, mockTarget, mockProgram, mockMarshal); IEnumDebugErrorBreakpoints2 errorBreakpointsEnum; Assert.AreEqual(VSConstants.S_FALSE, watchpoint.CanBind(out errorBreakpointsEnum)); uint errorCount; errorBreakpointsEnum.GetCount(out errorCount); Assert.AreEqual(1, errorCount); }
public void CanBindUnsupportedType() { SetBreakpointType(enum_BP_LOCATION_TYPE.BPLT_NONE); watchpoint = watchpointFactory.Create(mockBreakpointManager, mockBreakpointRequest, mockTarget, mockProgram, mockMarshal); IEnumDebugErrorBreakpoints2 errorBreakpointsEnum; Assert.AreEqual(VSConstants.S_FALSE, watchpoint.CanBind(out errorBreakpointsEnum)); uint errorCount; errorBreakpointsEnum.GetCount(out errorCount); Assert.AreEqual(1, errorCount); }
public void BindUnsupportedType() { // Set a unsupported breakpoint type and create a new pending watchpoint. SetBreakpointType(enum_BP_LOCATION_TYPE.BPLT_NONE); watchpoint = watchpointFactory.Create(mockBreakpointManager, mockBreakpointRequest, mockTarget, mockProgram, mockMarshal); var result = watchpoint.Bind(); IDebugErrorBreakpoint2 breakpointError = GetWatchpointError(); mockBreakpointManager.Received().ReportBreakpointError( Arg.Any <DebugBreakpointError>()); Assert.AreNotEqual(null, breakpointError); Assert.AreEqual(VSConstants.S_FALSE, result); }
public void BindPassCountEqualOrGreater() { const uint PASS_COUNT = 3u; SetPassCount(enum_BP_PASSCOUNT_STYLE.BP_PASSCOUNT_EQUAL_OR_GREATER, PASS_COUNT); watchpoint = watchpointFactory.Create(mockBreakpointManager, mockBreakpointRequest, mockTarget, mockProgram, mockMarshal); var result = watchpoint.Bind(); IDebugErrorBreakpoint2 watchpointError = GetWatchpointError(); mockBreakpointManager.Received().RegisterWatchpoint(watchpoint); Assert.AreEqual(null, watchpointError); Assert.AreEqual(VSConstants.S_OK, result); mockLldbWatchpoint.Received(1).SetIgnoreCount(PASS_COUNT - 1); }
public void BindCondition() { const string testCondition = "true"; SetCondition(enum_BP_COND_STYLE.BP_COND_WHEN_TRUE, testCondition); watchpoint = watchpointFactory.Create(mockBreakpointManager, mockBreakpointRequest, mockTarget, mockProgram, mockMarshal); var result = watchpoint.Bind(); IDebugErrorBreakpoint2 watchpointError = GetWatchpointError(); mockBreakpointManager.Received().RegisterWatchpoint(watchpoint); Assert.AreEqual(null, watchpointError); Assert.AreEqual(VSConstants.S_OK, result); mockLldbWatchpoint.Received(1).SetCondition(testCondition); }
public void BindPassCountMod() { const uint PASS_COUNT = 5u; const uint HIT_COUNT = 6u; SetPassCount(enum_BP_PASSCOUNT_STYLE.BP_PASSCOUNT_MOD, PASS_COUNT); watchpoint = watchpointFactory.Create(mockBreakpointManager, mockBreakpointRequest, mockTarget, mockProgram, mockMarshal); mockLldbWatchpoint.GetHitCount().Returns(HIT_COUNT); var result = watchpoint.Bind(); IDebugErrorBreakpoint2 watchpointError = GetWatchpointError(); mockBreakpointManager.Received().RegisterWatchpoint(watchpoint); Assert.AreEqual(null, watchpointError); Assert.AreEqual(VSConstants.S_OK, result); mockLldbWatchpoint.Received().SetIgnoreCount(9u); }
public void RegisterWatchpoint(IWatchpoint watchpoint) { int id = watchpoint.GetId(); if (id != -1) { watchpoints[id] = watchpoint; int currentCount; watchpointsCount.TryGetValue(id, out currentCount); watchpointsCount[id] = currentCount + 1; } else { Trace.WriteLine( "Failed to register pending watchpoint: watchpoint does not have an ID."); } debugEngineHandler.OnWatchpointBound(watchpoint, debugProgram); }
public void SetUp() { var taskContext = new JoinableTaskContext(); mockBreakpointManager = Substitute.For <IBreakpointManager>(); mockBreakpointRequest = Substitute.For <IDebugBreakpointRequest2>(); mockProgram = Substitute.For <IDebugProgram2>(); mockResolution = Substitute.For <IDebugBreakpointResolution2>(); mockResolutionFactory = Substitute.For <DebugWatchpointResolution.Factory>(); mockResolutionFactory.Create(TEST_ADDRESS_STR, mockProgram).Returns(mockResolution); mockTarget = Substitute.For <RemoteTarget>(); SbError error; mockError = Substitute.For <SbError>(); mockTarget.WatchAddress(TEST_ADDRESS, WATCH_SIZE, false, true, out error).Returns(x => { x[4] = mockError; return(mockLldbWatchpoint); }); mockMarshal = Substitute.For <Marshal>(); mockMarshal.GetStringFromIntPtr(Arg.Any <IntPtr>()).Returns(TEST_ADDRESS_STR); mockLldbWatchpoint = Substitute.For <SbWatchpoint>(); requestInfo = new BP_REQUEST_INFO(); requestInfo.bpLocation.unionmember4 = (IntPtr)4; mockBreakpointRequest.GetRequestInfo(Arg.Any <enum_BPREQI_FIELDS>(), Arg.Any <BP_REQUEST_INFO[]>()).Returns(x => { enum_BPREQI_FIELDS fields = (enum_BPREQI_FIELDS)x[0]; BP_REQUEST_INFO[] breakpointRequestInfo = (BP_REQUEST_INFO[])x[1]; if (breakpointRequestInfo == null || breakpointRequestInfo.Length == 0) { return(1); } return(BuildBreakpointRequestInfo(fields, out breakpointRequestInfo[0])); }); mockLldbWatchpoint.GetId().Returns(EXPECTED_ID); SetBreakpointType(enum_BP_LOCATION_TYPE.BPLT_DATA_STRING); watchpointFactory = new DebugWatchpoint.Factory(taskContext, mockResolutionFactory, new BreakpointErrorEnumFactory(), new BoundBreakpointEnumFactory()); watchpoint = watchpointFactory.Create(mockBreakpointManager, mockBreakpointRequest, mockTarget, mockProgram, mockMarshal); }
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(); }
public void SetUp() { taskContext = new JoinableTaskContext(); mockBreakpointRequest = Substitute.For <IDebugBreakpointRequest2>(); mockTarget = Substitute.For <RemoteTarget>(); mockProgram = Substitute.For <IGgpDebugProgram>(); mockPendingBreakpoint = Substitute.For <IPendingBreakpoint>(); mockPendingBreakpoint.GetId().Returns(ID); mockWatchpoint = Substitute.For <IWatchpoint>(); mockWatchpoint.GetId().Returns(ID); mockPendingBreakpointFactory = Substitute.For <DebugPendingBreakpoint.Factory>(); mockWatchpointFactory = Substitute.For <DebugWatchpoint.Factory>(); var mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>(); breakpointManager = new LldbBreakpointManager.Factory(taskContext, mockPendingBreakpointFactory, mockWatchpointFactory).Create(mockDebugEngineHandler, mockProgram); mockPendingBreakpointFactory.Create(breakpointManager, mockProgram, mockBreakpointRequest, mockTarget).ReturnsForAnyArgs(mockPendingBreakpoint); mockWatchpointFactory.Create(breakpointManager, mockBreakpointRequest, mockTarget, mockProgram).ReturnsForAnyArgs(mockWatchpoint); }
public void UnregisterWatchpoint(IWatchpoint watchpoint) { int id = watchpoint.GetId(); if (id != -1) { int currentCount; watchpointsCount.TryGetValue(id, out currentCount); if (currentCount > 1) { watchpointsCount[id] = currentCount - 1; } else if (currentCount == 1) { watchpointsCount.Remove(id); watchpoints.Remove(id); } } else { Trace.WriteLine( "Failed to unregister pending watchpoint: watchpoint does not have an ID."); } }
public bool GetWatchpointById(int id, out IWatchpoint watchpoint) { return(watchpoints.TryGetValue(id, out watchpoint)); }
/// <summary> /// Send a watchpoint bound event to the SDM. /// </summary> public static void OnWatchpointBound(this IDebugEngineHandler handler, IWatchpoint pendingWatchpoint, IGgpDebugProgram program) => handler.SendEvent(new BreakpointBoundEvent(pendingWatchpoint), program);