public int Bind() { if (_requestInfo.bpLocation.bpLocationType != (uint)enum_BP_LOCATION_TYPE.BPLT_DATA_STRING) { SetError(enum_BP_ERROR_TYPE.BPET_GENERAL_WARNING, _watchpointNotSupported); return(VSConstants.S_FALSE); } string dataExpression = _marshal.GetStringFromIntPtr(_requestInfo.bpLocation.unionmember3); uint size = (uint)_requestInfo.bpLocation.unionmember4; _lldbWatchpoint = _target.WatchAddress(Convert.ToInt64(dataExpression, 16), size, false /* read */, true /* write */, out SbError error); if (error.Fail()) { SetError(enum_BP_ERROR_TYPE.BPET_GENERAL_WARNING, error.GetCString()); return(VSConstants.S_FALSE); } _lldbWatchpoint.SetEnabled(_enabled); if ((_requestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_CONDITION) != 0) { SetCondition(_requestInfo.bpCondition); } if ((_requestInfo.dwFields & enum_BPREQI_FIELDS.BPREQI_PASSCOUNT) != 0) { SetPassCount(_requestInfo.bpPassCount); } _resolution = _resolutionFactory.Create(dataExpression, _program); _breakpointManager.RegisterWatchpoint(Self); return(VSConstants.S_OK); }
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 BindWatchpointFailed() { SbError error; SbError mockError = Substitute.For <SbError>(); mockError.Fail().Returns(true); mockTarget.WatchAddress(TEST_ADDRESS, WATCH_SIZE, false, true, out error).Returns( x => { x[4] = mockError; return(null); }); var result = watchpoint.Bind(); IDebugErrorBreakpoint2 watchpointError = GetWatchpointError(); mockBreakpointManager.Received().ReportBreakpointError( Arg.Any <DebugBreakpointError>()); Assert.AreNotEqual(null, watchpointError); Assert.AreEqual(VSConstants.S_FALSE, result); }