Example #1
0
        public async Task GetChildrenReturnsMoreElementWhenMoreThanRangeSizeRequestedAsync()
        {
            remoteValue.AddChild(RemoteValueFakeUtil.CreateSimpleString("child5", "value5"));

            int _countPerRange = 2;
            var childAdapter   = new RemoteValueChildAdapter.Factory().CreateForTesting(
                remoteValue, RemoteValueFormat.Default, varInfoBuilder, noFormatSpecifier,
                _countPerRange);

            IList <IVariableInformation> children = await childAdapter.GetChildrenAsync(0, 5);

            Assert.That(children.Count, Is.EqualTo(3));
            Assert.That(children[2].DisplayName, Is.EqualTo("[More]"));

            IVariableInformation more = children[2];

            CollectionAssert.AreEqual(new[] { "child3", "child4", "[More]" },
                                      await GetAllChildNamesAsync(more.GetChildAdapter()));

            IVariableInformation nextMore =
                (await more.GetChildAdapter().GetChildrenAsync(2, 1))[0];

            CollectionAssert.AreEqual(new[] { "child5" },
                                      await GetAllChildNamesAsync(nextMore.GetChildAdapter()));
        }
        public void GetPropertyInfoHexadecimalDisplay()
        {
            // 175 is hex AF!
            int    valueInt = 175;
            string valueHex = "0xaf";

            var childAdapterFactory = new RemoteValueChildAdapter.Factory();
            var remoteValue         = RemoteValueFakeUtil.CreateSimpleInt("test", valueInt);
            var varInfo             = new RemoteValueVariableInformation(
                null, "", RemoteValueFormat.Default, ValueFormat.Default, remoteValue, "test",
                CustomVisualizer.None, childAdapterFactory);

            var debugProperty = createPropertyDelegate.Invoke(varInfo);
            var propertyInfos = new DEBUG_PROPERTY_INFO[1];

            // Radix 16 -> Int should be formatted as hex.
            debugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE, 16, 0,
                                          null, 0, propertyInfos);

            Assert.AreEqual(propertyInfos[0].bstrValue, valueHex);

            // Radix 10 -> Int should be formatted as decimal.
            debugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE, 10, 0,
                                          null, 0, propertyInfos);

            Assert.AreEqual(propertyInfos[0].bstrValue, valueInt.ToString());

            // Radix 8 -> Not supported, should fall back to decimal.
            debugProperty.GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS.DEBUGPROP_INFO_VALUE, 8, 0,
                                          null, 0, propertyInfos);

            Assert.AreEqual(propertyInfos[0].bstrValue, valueInt.ToString());
        }
Example #3
0
        public void SetUp()
        {
            mockFrame = Substitute.For <RemoteFrame>();

            var childAdapterFactory = new RemoteValueChildAdapter.Factory();
            var varInfoFactory      = new LLDBVariableInformationFactory(childAdapterFactory);
            var varInfoBuilder      = new VarInfoBuilder(varInfoFactory);

            varInfoFactory.SetVarInfoBuilder(varInfoBuilder);
            var registerSetsBuilderFactory = new RegisterSetsBuilder.Factory(varInfoFactory);

            registerSetsBuilder = registerSetsBuilderFactory.Create(mockFrame);

            generalPurposeRegisters = Substitute.For <RemoteValue>();
            generalPurposeRegisters.GetName().Returns("General Purpose Registers");
            generalPurposeRegisters.GetNumChildren().Returns(0u);

            floatingPointRegisters = Substitute.For <RemoteValue>();
            floatingPointRegisters.GetName().Returns("Floating Point Registers");
            floatingPointRegisters.GetNumChildren().Returns(3u);
            xmm0 = Substitute.For <RemoteValue>();
            xmm0.GetName().Returns("xmm0");
            xmm8 = Substitute.For <RemoteValue>();
            xmm8.GetName().Returns("xmm8");
            other = Substitute.For <RemoteValue>();
            other.GetName().Returns("other");
            floatingPointRegisters.GetChildren(0, 3).Returns(
                new List <RemoteValue>()
            {
                xmm0, xmm8, other
            });
        }
Example #4
0
        public void SetUp()
        {
            var childAdapterFactory = new RemoteValueChildAdapter.Factory();
            var varInfoFactory      = new LLDBVariableInformationFactory(childAdapterFactory);

            varInfoBuilder = new VarInfoBuilder(varInfoFactory);
            varInfoFactory.SetVarInfoBuilder(varInfoBuilder);
        }
Example #5
0
        public async Task UninheritableFormatSpecifiersAreNotInheritedAsync()
        {
            Assert.That(RemoteValueDefaultFormat.DefaultFormatter.ShouldInheritFormatSpecifier(),
                        Is.False);

            var childAdapter = new RemoteValueChildAdapter.Factory().Create(
                remoteValue, RemoteValueFormat.Default, varInfoBuilder, formatSpecifier: "na");

            CollectionAssert.AreEqual(
                new[] { string.Empty, string.Empty, string.Empty, string.Empty },
                await GetAllChildFormatSpecifiersAsync(childAdapter));
        }
Example #6
0
        public async Task InheritableFormatSpecifiersAreInheritedAsync()
        {
            IRemoteValueFormat lldbFormat = RemoteValueFormatProvider.Get("x");

            Assert.That(lldbFormat, Is.Not.Null);
            Assert.That(lldbFormat.ShouldInheritFormatSpecifier(), Is.True);

            var childAdapter = new RemoteValueChildAdapter.Factory().Create(
                remoteValue, lldbFormat, varInfoBuilder, formatSpecifier: "x");

            CollectionAssert.AreEqual(new[] { "x", "x", "x", "x" },
                                      await GetAllChildFormatSpecifiersAsync(childAdapter));
        }
Example #7
0
        public void SetUp()
        {
            remoteValue = RemoteValueFakeUtil.CreateClass("int[]", "array", "");
            remoteValue.AddChild(RemoteValueFakeUtil.CreateSimpleString("child1", "value1"));
            remoteValue.AddChild(RemoteValueFakeUtil.CreateSimpleString("child2", "value2"));
            remoteValue.AddChild(RemoteValueFakeUtil.CreateSimpleString("child3", "value3"));
            remoteValue.AddChild(RemoteValueFakeUtil.CreateSimpleString("child4", "value4"));

            var childAdapterFactory = new RemoteValueChildAdapter.Factory();
            var varInfoFactory      = new LLDBVariableInformationFactory(childAdapterFactory);

            varInfoBuilder = new VarInfoBuilder(varInfoFactory);
            varInfoFactory.SetVarInfoBuilder(varInfoBuilder);
        }
Example #8
0
        public void SetUp()
        {
            _mockRemoteFrame = Substitute.For <RemoteFrame>();
            var childAdapterFactory = new RemoteValueChildAdapter.Factory();

            _varInfoFactory      = new LLDBVariableInformationFactory(childAdapterFactory);
            _registerSetsBuilder = new RegisterSetsBuilder.Factory(_varInfoFactory)
                                   .Create(_mockRemoteFrame);

            _frameVariablesProvider = new FrameVariablesProvider(_registerSetsBuilder,
                                                                 _mockRemoteFrame, _varInfoFactory);

            SetupAllVariables();
        }
Example #9
0
        public async Task GetChildrenReturnsChildrenInTheSelectedRangeAsync()
        {
            var childAdapter = new RemoteValueChildAdapter.Factory().Create(
                remoteValue, RemoteValueFormat.Default, varInfoBuilder, noFormatSpecifier);

            CollectionAssert.AreEqual(new[] { "child1", "child2" },
                                      await GetChildNamesAsync(childAdapter, 0, 2));

            CollectionAssert.AreEqual(new[] { "child2" },
                                      await GetChildNamesAsync(childAdapter, 1, 1));

            CollectionAssert.AreEqual(new[] { "child1", "child2", "child3", "child4" },
                                      await GetAllChildNamesAsync(childAdapter));

            CollectionAssert.AreEqual(new[] { "child1", "child2", "child3", "child4" },
                                      await GetChildNamesAsync(childAdapter, 0, 100));
        }
Example #10
0
        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);
        }
Example #11
0
        public void SetUp()
        {
            _mockDebuggerStackFrame = Substitute.For <RemoteFrame>();
            var childAdapterFactory = new RemoteValueChildAdapter.Factory();
            var varInfoFactory      = new LLDBVariableInformationFactory(childAdapterFactory);

            _vsExpressionCreator = new VsExpressionCreator();

            _metrics = Substitute.For <IMetrics>();
            var eventScheduler        = new EventSchedulerFake();
            var eventSchedulerFactory = Substitute.For <IEventSchedulerFactory>();

            eventSchedulerFactory.Create(Arg.Do <System.Action>(a => eventScheduler.Callback = a))
            .Returns(eventScheduler);
            var       timer = new TimerFake();
            const int minimumBatchSeparationMilliseconds = 1;
            var       batchEventAggregator =
                new BatchEventAggregator <ExpressionEvaluationBatch, ExpressionEvaluationBatchParams,
                                          ExpressionEvaluationBatchSummary>(minimumBatchSeparationMilliseconds,
                                                                            eventSchedulerFactory, timer);

            _expressionEvaluationRecorder =
                new ExpressionEvaluationRecorder(batchEventAggregator, _metrics);
            _timeSource = new MonotonicTimeSource();

            _taskExecutor = Substitute.ForPartsOf <FakeTaskExecutor>();

            var enumFactory = new VariableInformationEnum.Factory(_taskExecutor);

            var childrenProviderFactory = new ChildrenProvider.Factory();
            var debugPropertyFactory    = new DebugProperty.Factory(
                enumFactory, childrenProviderFactory, null, _vsExpressionCreator, _taskExecutor);

            _createPropertyDelegate = debugPropertyFactory.Create;

            childrenProviderFactory.Initialize(_createPropertyDelegate);

            _varInfoBuilder = new VarInfoBuilder(varInfoFactory);
            varInfoFactory.SetVarInfoBuilder(_varInfoBuilder);

            _engineCommandsMock = Substitute.For <IDebugEngineCommands>();

            _mockDebugEngineHandler = Substitute.For <IDebugEngineHandler>();
            _mockProgram            = Substitute.For <IGgpDebugProgram>();
            _mockThread             = Substitute.For <IDebugThread2>();
        }
        DebugSessionLauncher.Factory CreateLauncherFactory(bool stadiaPlatformAvailable,
                                                           PlatformFactoryFakeConnectRecorder
                                                           connectRecorder = null)
        {
            _debuggerFactory =
                new GrpcDebuggerFactoryFake(new TimeSpan(0), stadiaPlatformAvailable);
            _platformFactory = new GrpcPlatformFactoryFake(connectRecorder);
            var taskContext = new JoinableTaskContext();

            _listenerFactory = new GrpcListenerFactoryFake();

            // If stadiaPlatformAvailable is True the DebugSessionLauncher will connect
            // to the platform 'remote-stadia', otherwise it will use 'remote-linux'
            var platformName = stadiaPlatformAvailable
                ? "remote-stadia"
                : "remote-linux";

            _platformFactory.AddFakeProcess(platformName, _gameBinary, 44);
            var exceptionManagerFactory =
                new LldbExceptionManager.Factory(new Dictionary <int, Signal>());
            var connectOptionsFactory       = new GrpcPlatformConnectOptionsFactory();
            var platformShellCommandFactory = new GrpcPlatformShellCommandFactory();

            var childAdapterFactory = new RemoteValueChildAdapter.Factory();
            var varInfoFactory      = new LLDBVariableInformationFactory(childAdapterFactory);

            var taskExecutor = new TaskExecutor(taskContext.Factory);

            var debugCodeContextFactory =
                new DebugCodeContext.Factory(new DebugMemoryContext.Factory());

            var debugDocumentContextFactory = new DebugDocumentContext.Factory();
            var threadsEnumFactory          = new ThreadEnumFactory();
            var moduleEnumFactory           = new ModuleEnumFactory();
            var frameEnumFactory            = new FrameEnumFactory();
            var codeContextEnumFactory      = new CodeContextEnumFactory();

            var lldbModuleUtil   = new LldbModuleUtil();
            var moduleFileFinder = Substitute.For <IModuleFileFinder>();
            var moduleFileLoadRecorderFactory =
                new ModuleFileLoadMetricsRecorder.Factory(lldbModuleUtil, moduleFileFinder);
            var mockBinaryFileUtil     = Substitute.For <IBinaryFileUtil>();
            var lldbShell              = Substitute.For <ILLDBShell>();
            var actionRecorder         = new ActionRecorder(Substitute.For <IMetrics>());
            var symbolSettingsProvider = Substitute.For <ISymbolSettingsProvider>();
            var attachedProgramFactory = new LldbAttachedProgram.Factory(
                taskContext, new DebugEngineHandler.Factory(taskContext), taskExecutor,
                new LldbEventManager.Factory(new BoundBreakpointEnumFactory(), taskContext),
                new DebugProgram.Factory(taskContext,
                                         new DebugDisassemblyStream.Factory(
                                             debugCodeContextFactory, debugDocumentContextFactory),
                                         debugDocumentContextFactory, debugCodeContextFactory,
                                         threadsEnumFactory, moduleEnumFactory,
                                         codeContextEnumFactory),
                new DebugModuleCache.Factory(new SynchronousDispatcher()),
                new DebugModule.Factory(
                    FakeCancelableTask.CreateFactory(new JoinableTaskContext(), false),
                    actionRecorder, moduleFileLoadRecorderFactory, lldbModuleUtil,
                    symbolSettingsProvider),
                new DebugThread.Factory(frameEnumFactory, taskExecutor).Create,
                new DebugStackFrame.Factory(debugDocumentContextFactory,
                                            new ChildrenProvider.Factory(), debugCodeContextFactory,
                                            Substitute.For <DebugExpression.Factory>().Create,
                                            varInfoFactory,
                                            new VariableInformationEnum.Factory(taskExecutor),
                                            new RegisterSetsBuilder.Factory(varInfoFactory),
                                            taskExecutor).Create, lldbShell,
                new LldbBreakpointManager.Factory(taskContext,
                                                  new DebugPendingBreakpoint.Factory(
                                                      taskContext,
                                                      new DebugBoundBreakpoint.Factory(
                                                          debugDocumentContextFactory,
                                                          debugCodeContextFactory,
                                                          new DebugBreakpointResolution.Factory()),
                                                      new BreakpointErrorEnumFactory(),
                                                      new BoundBreakpointEnumFactory()),
                                                  new DebugWatchpoint.Factory(
                                                      taskContext,
                                                      new DebugWatchpointResolution.Factory(),
                                                      new BreakpointErrorEnumFactory(),
                                                      new BoundBreakpointEnumFactory())),
                new SymbolLoader.Factory(lldbModuleUtil, mockBinaryFileUtil, moduleFileFinder),
                new BinaryLoader.Factory(lldbModuleUtil, moduleFileFinder),
                Substitute.For <IModuleFileLoaderFactory>());

            var coreAttachWarningDialog = new CoreAttachWarningDialogUtil(
                taskContext, Substitute.For <IDialogUtil>());

            return(new DebugSessionLauncher.Factory(
                       taskContext, _debuggerFactory, _listenerFactory, _platformFactory,
                       connectOptionsFactory, platformShellCommandFactory, attachedProgramFactory,
                       actionRecorder, moduleFileLoadRecorderFactory, exceptionManagerFactory, _fileSystem,
                       false, moduleFileFinder, new DumpModulesProvider(_fileSystem),
                       new ModuleSearchLogHolder(), symbolSettingsProvider, coreAttachWarningDialog));
        }