public void EnumCodeContexts(int numLocations) { var mockDocumentPosition = Substitute.For <IDebugDocumentPosition2>(); mockDocumentPosition.GetRange(Arg.Any <TEXT_POSITION[]>(), null).Returns(x => { var startPositions = x[0] as TEXT_POSITION[]; startPositions[0].dwLine = LINE; return(VSConstants.S_OK); }); mockDocumentPosition.GetFileName(out string _).Returns(x => { x[0] = Path.Combine(DIRECTORY, FILE_NAME); return(VSConstants.S_OK); }); var mockBreakpoint = Substitute.For <RemoteBreakpoint>(); var mockCodeContexts = new IDebugCodeContext2[numLocations]; for (uint i = 0; i < numLocations; ++i) { var mockAddress = Substitute.For <SbAddress>(); mockAddress.GetLoadAddress(mockRemoteTarget).Returns(ADDRESS + i); var mockFunction = Substitute.For <SbFunction>(); mockFunction.GetName().Returns(NAME + i); mockAddress.GetFunction().Returns(mockFunction); var lineEntry = new LineEntryInfo(); mockAddress.GetLineEntry().Returns(lineEntry); var mockDocumentContext = Substitute.For <IDebugDocumentContext2>(); mockDocumentContextFactory.Create(lineEntry).Returns(mockDocumentContext); var mockCodeContext = Substitute.For <IDebugCodeContext2>(); mockCodeContextFactory .Create(ADDRESS + i, NAME + i, mockDocumentContext, Guid.Empty) .Returns(mockCodeContext); var mockBreakpointLocation = Substitute.For <SbBreakpointLocation>(); mockBreakpointLocation.GetAddress().Returns(mockAddress); mockBreakpoint.GetLocationAtIndex(i).Returns(mockBreakpointLocation); mockCodeContexts[i] = mockCodeContext; } mockBreakpoint.GetNumLocations().Returns((uint)numLocations); mockRemoteTarget.BreakpointCreateByLocation(Path.Combine(DIRECTORY, FILE_NAME), LINE + 1).Returns(mockBreakpoint); int result = program.EnumCodeContexts(mockDocumentPosition, out IEnumDebugCodeContexts2 enumCodeContexts); Assert.AreEqual(VSConstants.S_OK, result); enumCodeContexts.GetCount(out uint count); Assert.AreEqual(numLocations, count); IDebugCodeContext2[] codeContexts = new IDebugCodeContext2[count]; uint actual = 0; enumCodeContexts.Next(count, codeContexts, ref actual); Assert.AreEqual(count, actual); Assert.AreEqual(mockCodeContexts, codeContexts); }
public void SetUp() { lineEntry = new LineEntryInfo(); mockDocumentContext = Substitute.For <IDebugDocumentContext2>(); mockThread = Substitute.For <IDebugThread>(); mockDocumentContextFactory = Substitute.For <DebugDocumentContext.Factory>(); mockDocumentContextFactory.Create(lineEntry).Returns(mockDocumentContext); mockDebuggerStackFrame = Substitute.For <RemoteFrame>(); mockDebuggerStackFrame.GetLineEntry().Returns(lineEntry); mockDebuggerStackFrame.GetPC().Returns(TEST_PC); mockDebuggerStackFrame.GetFunctionName().Returns(NAME); mockDebuggerStackFrame.GetFunctionNameWithSignature().Returns(NAME); mockCodeContextFactory = Substitute.For <DebugCodeContext.Factory>(); mockExpressionFactory = Substitute.For <DebugExpression.Factory>(); mockModuleCache = Substitute.For <IDebugModuleCache>(); mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>(); mockProgram = Substitute.For <IGgpDebugProgram>(); taskExecutor = new TaskExecutor(new JoinableTaskContext().Factory); var childAdapterFactory = new RemoteValueChildAdapter.Factory(); var varInfoFactory = new LLDBVariableInformationFactory(childAdapterFactory); var varInfoEnumFactory = new VariableInformationEnum.Factory(taskExecutor); var childrenProviderFactory = new ChildrenProvider.Factory(); var propertyFactory = new DebugProperty.Factory(varInfoEnumFactory, childrenProviderFactory, Substitute.For <DebugCodeContext.Factory>(), new VsExpressionCreator(), taskExecutor); childrenProviderFactory.Initialize(propertyFactory.Create); var registerSetsBuilderFactory = new RegisterSetsBuilder.Factory(varInfoFactory); stackFrame = new DebugStackFrame.Factory(mockDocumentContextFactory, childrenProviderFactory, mockCodeContextFactory, mockExpressionFactory.Create, varInfoFactory, varInfoEnumFactory, registerSetsBuilderFactory, taskExecutor) .Create(new AD7FrameInfoCreator(mockModuleCache), mockDebuggerStackFrame, mockThread, mockDebugEngineHandler, mockProgram); stackFrameAsync = new DebugStackFrameAsync.Factory(mockDocumentContextFactory, childrenProviderFactory, mockCodeContextFactory, mockExpressionFactory.Create, varInfoFactory, varInfoEnumFactory, registerSetsBuilderFactory, taskExecutor) .Create(new AD7FrameInfoCreator(mockModuleCache), mockDebuggerStackFrame, mockThread, mockDebugEngineHandler, mockProgram); }
public void GetCodeContext() { const ulong newAddress = 0x123456789a; SbAddress address = Substitute.For <SbAddress>(); var documentContext = Substitute.For <IDebugDocumentContext2>(); var newCodeContext = Substitute.For <IDebugCodeContext2>(); _mockTarget.ResolveLoadAddress(newAddress).Returns(address); _documentContextFactory.Create(address.GetLineEntry()).Returns(documentContext); _codeContextFactory .Create(newAddress, Arg.Any <Lazy <string> >(), documentContext, Guid.Empty) .Returns(newCodeContext); Assert.AreEqual(VSConstants.S_OK, _disassemblyStream.GetCodeContext( newAddress, out IDebugCodeContext2 codeContext)); Assert.AreEqual(newCodeContext, codeContext); }
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() { lineEntry = new LineEntryInfo(); documentContextFactory = new DebugDocumentContext.Factory(); documentContext = documentContextFactory.Create(lineEntry); }