private void MockFunctionData(uint startPosition, uint endPosition, string directory, string fileName) { SbBreakpointLocation location = mockBreakpoint.GetLocationAtIndex(0); SbAddress mockBreakpointAddress = Substitute.For <SbAddress>(); SbAddress mockStartAddress = Substitute.For <SbAddress>(); SbAddress mockFunctionEndAddress = Substitute.For <SbAddress>(); SbAddress mockActualEndAddress = Substitute.For <SbAddress>(); SbLineEntry mockStartLineEntry = Substitute.For <SbLineEntry>(); SbLineEntry mockEndLineEntry = Substitute.For <SbLineEntry>(); ulong address = 0x1234567; location.GetAddress().Returns(mockBreakpointAddress); mockBreakpointAddress.GetFunction().Returns(mockFunction); mockFunction.GetStartAddress().Returns(mockStartAddress); mockFunction.GetEndAddress().Returns(mockFunctionEndAddress); mockFunctionEndAddress.GetLoadAddress(mockTarget).Returns(address); mockTarget.ResolveLoadAddress(address - 1).Returns(mockActualEndAddress); mockStartAddress.GetLineEntry().Returns(mockStartLineEntry); mockActualEndAddress.GetLineEntry().Returns(mockEndLineEntry); mockStartLineEntry.GetLine().Returns(startPosition); mockStartLineEntry.GetDirectory().Returns(directory); mockStartLineEntry.GetFileName().Returns(fileName); mockEndLineEntry.GetLine().Returns(endPosition); }
public virtual IBoundBreakpoint Create( IDebugPendingBreakpoint2 pendingBreakpoint, SbBreakpointLocation breakpointLocation, IDebugProgram2 program, Guid languageGuid) => new DebugBoundBreakpoint(_documentContextFactory, _codeContextFactory, _breakpointResolutionFactory, pendingBreakpoint, breakpointLocation, program, languageGuid);
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 override Task <GetHitCountResponse> GetHitCount( GetHitCountRequest request, ServerCallContext context) { SbBreakpointLocation location = GetBreakpointLocation(request.BreakpointLocation); uint result = location.GetHitCount(); return(Task.FromResult(new GetHitCountResponse { Result = result })); }
public void GetBreakpointResolutionNullAddress() { SbBreakpointLocation breakpointLocationNullAddress = Substitute.For <SbBreakpointLocation>(); const SbAddress NULL_ADDRESS = null; breakpointLocationNullAddress.GetAddress().Returns(NULL_ADDRESS); IDebugBoundBreakpoint2 boundBreakpointNullAddress = boundBreakpointFactory.Create( mockPendingBreakpoint, breakpointLocationNullAddress, mockprogram, Guid.Empty); IDebugBreakpointResolution2 breakpointResolutionNullAddress; Assert.AreEqual(VSConstants.E_FAIL, boundBreakpointNullAddress.GetBreakpointResolution( out breakpointResolutionNullAddress)); Assert.AreEqual(null, breakpointResolutionNullAddress); }
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); }
// Constructor with factories for tests. DebugBoundBreakpoint(DebugDocumentContext.Factory documentContextFactory, DebugCodeContext.Factory codeContextFactory, DebugBreakpointResolution.Factory breakpointResolutionFactory, IDebugPendingBreakpoint2 pendingBreakpoint, SbBreakpointLocation breakpointLocation, IDebugProgram2 program, Guid languageGuid) { _pendingBreakpoint = pendingBreakpoint; _breakpointLocation = breakpointLocation; _enabled = true; _deleted = false; _disabledByPassCount = false; SbAddress address = breakpointLocation.GetAddress(); if (address != null) { LineEntryInfo lineEntry = address.GetLineEntry(); IDebugDocumentContext2 documentContext = null; string name = ""; // |lineEntry| is null if the breakpoint is set on an external function. if (lineEntry != null) { documentContext = documentContextFactory.Create(lineEntry); documentContext.GetName(enum_GETNAME_TYPE.GN_NAME, out name); } IDebugCodeContext2 codeContext = codeContextFactory.Create( breakpointLocation.GetLoadAddress(), name, documentContext, languageGuid); _breakpointResolution = breakpointResolutionFactory.Create(codeContext, program); } else { Trace.WriteLine("Warning: Unable to obtain address from breakpoint location." + " No breakpoint resolution created."); } }
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); } }