예제 #1
0
        public void SetUp()
        {
            var taskContext = new JoinableTaskContext();

            remoteThread = Substitute.For <RemoteThread>();
            mockThread   = Substitute.For <IDebugThread>();
            mockThread.GetRemoteThread().Returns(remoteThread);
            mockDebugEngineHandler            = Substitute.For <IDebugEngineHandler>();
            mockDebugThreadCreator            = Substitute.For <DebugProgram.ThreadCreator>();
            mockDebugDisassemblyStreamFactory = Substitute.For <DebugDisassemblyStream.Factory>();
            mockProcess = Substitute.For <IDebugProcess2>();
            var guid = new Guid();

            mockSbProcess              = Substitute.For <SbProcess>();
            mockRemoteTarget           = Substitute.For <RemoteTarget>();
            mockDocumentContextFactory = Substitute.For <DebugDocumentContext.Factory>();
            mockCodeContextFactory     = Substitute.For <DebugCodeContext.Factory>();
            threadEnumFactory          = new ThreadEnumFactory();
            moduleEnumFactory          = new ModuleEnumFactory();
            codeContextEnumFactory     = new CodeContextEnumFactory();

            mockDebugModuleCache = Substitute.For <IDebugModuleCache>();
            program = new DebugProgram.Factory(taskContext, mockDebugDisassemblyStreamFactory,
                                               mockDocumentContextFactory, mockCodeContextFactory, threadEnumFactory,
                                               moduleEnumFactory, codeContextEnumFactory)
                      .Create(mockDebugEngineHandler, mockDebugThreadCreator, mockProcess, guid,
                              mockSbProcess, mockRemoteTarget, mockDebugModuleCache, false);
        }
        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));
        }