public void SetUp()
        {
            taskContext = new JoinableTaskContext();
            mockMemoryMappedFileFactory = Substitute.For <MemoryMappedFileFactory>();
            transportSessionFactory     = new LldbTransportSession.Factory(mockMemoryMappedFileFactory);
            mockManagedProcessFactory   = Substitute.For <ManagedProcess.Factory>();
            mockGrpcCallInvoker         = Substitute.ForPartsOf <PipeCallInvoker>(_numGrpcPipePairs);
            mockGrpcCallInvokerFactory  = Substitute.For <PipeCallInvokerFactory>();
            mockGrpcCallInvokerFactory.Create().Returns(mockGrpcCallInvoker);
            mockGrpcConnectionFactory = Substitute.For <GrpcConnectionFactory>();
            optionPageGrid            = Substitute.For <IExtensionOptions>();
            service = new YetiVSIService(optionPageGrid);
            var mockVsOutputWindow = Substitute.For <IVsOutputWindow>();

            mockDialogUtil     = Substitute.For <IDialogUtil>();
            yetiDebugTransport = new YetiDebugTransport(taskContext, transportSessionFactory,
                                                        mockGrpcCallInvokerFactory,
                                                        mockGrpcConnectionFactory,
                                                        onAsyncRpcCompleted: null,
                                                        managedProcessFactory:
                                                        mockManagedProcessFactory,
                                                        dialogUtil: mockDialogUtil,
                                                        vsOutputWindow: mockVsOutputWindow,
                                                        yetiVSIService: service);

            abortError = null;
            yetiDebugTransport.OnStop += e => { abortError = e; };
        }
Пример #2
0
        public void SetUp()
        {
            var callInvokerFactory = new PipeCallInvokerFactory();

            mainThreadContext = new FakeMainThreadContext();
            taskContext       = mainThreadContext.JoinableTaskContext;
            connection        = new GrpcConnection(taskContext.Factory, callInvokerFactory.Create());
        }
Пример #3
0
        public override IDebugEngineFactory CreateDebugEngineFactory()
        {
            ServiceManager serviceManager      = CreateServiceManager();
            var            joinableTaskContext = GetJoinableTaskContext();
            var            vsiService          = GetVsiService();

            joinableTaskContext.ThrowIfNotOnMainThread();

            var debugEngineCommands =
                new DebugEngineCommands(joinableTaskContext, null, false);

            var actionRecorder           = new ActionRecorder(GetDebugSessionMetrics());
            var backgroundProcessFactory = new BackgroundProcess.Factory();

            var processFactory = new ManagedProcess.Factory();
            var binaryFileUtil = new ElfFileUtil(processFactory);
            var lldbModuleUtil = new LldbModuleUtil();

            IModuleFileFinder moduleFileFinder = Substitute.For <IModuleFileFinder>();
            var moduleFileLoadRecorderFactory  =
                new ModuleFileLoadMetricsRecorder.Factory(lldbModuleUtil, moduleFileFinder);
            var grpcInterceptors = CreateGrpcInterceptors(vsiService.DebuggerOptions);
            var vsOutputWindow   =
                serviceManager.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            var callInvokerFactory      = new PipeCallInvokerFactory();
            var transportSessionFactory =
                new LldbTransportSession.Factory(new MemoryMappedFileFactory());
            var yetiTransport = new YetiDebugTransport(
                joinableTaskContext, transportSessionFactory, callInvokerFactory,
                new GrpcConnectionFactory(joinableTaskContext.Factory, grpcInterceptors.ToArray()),
                GetTaskExecutor().CancelAsyncOperationIfRequested, processFactory, _dialogUtil,
                vsOutputWindow, vsiService);

            var chromeLauncher            = new ChromeLauncher(backgroundProcessFactory);
            var testClientLauncherFactory = new ChromeClientsLauncher.Factory(
                new ChromeClientLaunchCommandFormatter(GetJsonUtil()), GetSdkConfigFactory(),
                chromeLauncher);

            var exitDialogUtil         = new ExitDialogUtil(_dialogUtil, GetDialogExecutionContext());
            var preflightBinaryChecker =
                new PreflightBinaryChecker(GetFileSystem(), binaryFileUtil);

            var paramsFactory = new YetiVSI.DebugEngine.DebugEngine.Params.Factory(GetJsonUtil());

            var  cancelableTaskFactory  = GetCancelableTaskFactory();
            bool deployLldbServer       = true;
            IDebugEngineFactory factory = new YetiVSI.DebugEngine.DebugEngine.Factory(
                joinableTaskContext, serviceManager, GetDebugSessionMetrics(), yetiTransport,
                actionRecorder, null, moduleFileLoadRecorderFactory, moduleFileFinder,
                testClientLauncherFactory, GetNatvis(), GetNatvisDiagnosticLogger(),
                exitDialogUtil, preflightBinaryChecker, _debugSessionLauncherFactory, paramsFactory,
                _remoteDeploy, cancelableTaskFactory, _dialogUtil,
                GetNatvisLoggerOutputWindowListener(), GetSolutionExplorer(), debugEngineCommands,
                GetDebugEventCallbackDecorator(vsiService.DebuggerOptions),
                GetSymbolSettingsProvider(), deployLldbServer, _gameLauncher);

            return(GetFactoryDecorator().Decorate(factory));
        }
Пример #4
0
        public void SetUp()
        {
            var factory = new GrpcPlatformFactoryFake(null);

            factory.AddFakeProcess("linux-remote", "myGame", 2222);
            factory.AddFakeProcess("linux-remote", "ssh", 443244);
            factory.AddFakeProcess("linux-remote", "blah", 4545);

            var callInvokerFactory = new PipeCallInvokerFactory();
            var grpcConnection     =
                new GrpcConnection(new JoinableTaskContext().Factory, callInvokerFactory.Create());

            platform       = factory.Create("linux-remote", grpcConnection);
            connectOptions = new GrpcPlatformConnectOptionsFactory()
                             .Create("http://any/url");
            shellCommandFactory = new GrpcPlatformShellCommandFactory();
        }
Пример #5
0
        private ServerInfo CreateServer(
            PipeCallInvokerFactory callInvokerFactory, GrpcConnectionFactory connectionFactory)
        {
            PipeCallInvoker callInvoker = callInvokerFactory.Create();
            GrpcConnection  connection  = connectionFactory.Create(callInvoker);

            string[] inPipeHandles, outPipeHandles;
            callInvoker.GetClientPipeHandles(out inPipeHandles, out outPipeHandles);

            // Note: The client's out handles are the server's in handles and vice versa.
            PipeServiceBinder server = new PipeServiceBinder(outPipeHandles, inPipeHandles);
            var stores        = new RemoteObjectStores();
            var mockFactories = new LldbMockFactories();

            BindServices(server, stores, mockFactories);
            server.Start();
            return(new ServerInfo(server, callInvoker, connection, stores, mockFactories));
        }
        public void SetUp()
        {
            var taskContext = new JoinableTaskContext();
            PipeCallInvokerFactory callInvokerFactory = new PipeCallInvokerFactory();
            PipeCallInvoker        callInvoker        = callInvokerFactory.Create();

            _grpcConnection  = new GrpcConnection(taskContext.Factory, callInvoker);
            _callback        = Substitute.For <IDebugEventCallback2>();
            _debuggerOptions = new YetiVSI.DebuggerOptions.DebuggerOptions
            {
                [DebuggerOption.CLIENT_LOGGING] = DebuggerOptionState.DISABLED
            };
            _libPaths = new HashSet <string> {
                "some/path", "some/other/path", _gameBinary
            };
            _programId   = Guid.Empty;
            _task        = Substitute.For <ICancelable>();
            _process     = new DebugProcessStub(enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM, _pid);
            _fileSystem  = new MockFileSystem();
            _debugEngine = Substitute.For <IDebugEngine3>();
            _gameLaunch  = Substitute.For <IVsiGameLaunch>();
        }
Пример #7
0
        public YetiDebugTransport(JoinableTaskContext taskContext,
                                  LldbTransportSession.Factory transportSessionFactory,
                                  PipeCallInvokerFactory grpcCallInvokerFactory,
                                  GrpcConnectionFactory grpcConnectionFactory,
                                  Action onAsyncRpcCompleted,
                                  ManagedProcess.Factory managedProcessFactory,
                                  IDialogUtil dialogUtil, IVsOutputWindow vsOutputWindow,
                                  IYetiVSIService yetiVSIService)
        {
            taskContext.ThrowIfNotOnMainThread();

            this.taskContext             = taskContext;
            this.grpcCallInvokerFactory  = grpcCallInvokerFactory;
            this.grpcConnectionFactory   = grpcConnectionFactory;
            this.onAsyncRpcCompleted     = onAsyncRpcCompleted;
            this.managedProcessFactory   = managedProcessFactory;
            this.transportSessionFactory = transportSessionFactory;
            this.dialogUtil = dialogUtil;

            Guid debugPaneGuid = VSConstants.GUID_OutWindowDebugPane;

            vsOutputWindow?.GetPane(ref debugPaneGuid, out debugPane);
            this.yetiVSIService = yetiVSIService;
        }
        /// <summary>
        /// Creates a new debug engine factory.
        /// </summary>
        /// <param name="self">The external identity of the debug engine.</param>
        public virtual IDebugEngineFactory CreateDebugEngineFactory()
        {
            ServiceManager serviceManager = CreateServiceManager();

            GetJoinableTaskContext().ThrowIfNotOnMainThread();

            var vsExpressionCreator = new VsExpressionCreator();

            if (GetVsiService().Options.LLDBVisualizerSupport == LLDBVisualizerSupport.ENABLED)
            {
                GetNatvis().VisualizerScanner.LoadProjectFiles();
            }

            var debugEngineCommands = new DebugEngineCommands(
                GetJoinableTaskContext(), GetNatvis(),
                GetVsiService().Options.LLDBVisualizerSupport == LLDBVisualizerSupport.ENABLED);

            var actionRecorder           = new ActionRecorder(GetDebugSessionMetrics());
            var backgroundProcessFactory = new BackgroundProcess.Factory();

            var processFactory = new ManagedProcess.Factory();
            var binaryFileUtil = new ElfFileUtil(processFactory);
            var lldbModuleUtil = new LldbModuleUtil();

            var symbolServerRequestHandler = new WebRequestHandler()
            {
                AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip,
                UseDefaultCredentials  = true,
                CachePolicy            = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore),
            };
            var symbolServerHttpClient = new HttpClient(symbolServerRequestHandler);
            var symbolPathParser       = new SymbolPathParser(
                GetFileSystem(), binaryFileUtil, symbolServerHttpClient,
                new CrashReportClient(GetCloudRunner()),
                SDKUtil.GetDefaultSymbolCachePath(), SDKUtil.GetDefaultSymbolStorePath(),
                YetiConstants.SymbolServerExcludeList);
            IModuleFileFinder        moduleFileFinder        = new ModuleFileFinder(symbolPathParser);
            IModuleFileLoaderFactory moduleFileLoaderFactory = new ModuleFileLoader.Factory();

            var moduleFileLoadRecorderFactory =
                new ModuleFileLoadMetricsRecorder.Factory(lldbModuleUtil, moduleFileFinder);

            var symbolLoaderFactory =
                new SymbolLoader.Factory(lldbModuleUtil, binaryFileUtil, moduleFileFinder);
            var binaryLoaderFactory = new BinaryLoader.Factory(lldbModuleUtil, moduleFileFinder);

            var cancelableTaskFactory = GetCancelableTaskFactory();

            var exceptionManagerFactory =
                new LldbExceptionManager.Factory(LinuxSignals.GetDefaultSignalsMap());

            DebugModule.Factory debugModuleFactory =
                GetFactoryDecorator().Decorate(new DebugModule.Factory(
                                                   cancelableTaskFactory, actionRecorder, moduleFileLoadRecorderFactory,
                                                   lldbModuleUtil, GetSymbolSettingsProvider()));
            var debugModuleCacheFactory   = new DebugModuleCache.Factory(GetDispatcher());
            var debugMemoryContextFactory =
                GetFactoryDecorator().Decorate(new DebugMemoryContext.Factory());

            var debugDocumentContextFactory =
                GetFactoryDecorator().Decorate(new DebugDocumentContext.Factory());

            var debugCodeContextFactory = GetFactoryDecorator().Decorate(
                new DebugCodeContext.Factory(debugMemoryContextFactory));

            var varInfoEnumFactory =
                GetFactoryDecorator().Decorate <IVariableInformationEnumFactory>(
                    new VariableInformationEnum.Factory(GetTaskExecutor()));

            var concreteChildrenProviderFactory = new ChildrenProvider.Factory();
            var childrenProviderFactory         = GetFactoryDecorator().Decorate <IChildrenProviderFactory>(
                concreteChildrenProviderFactory);

            // TODO: Add test for this: (internal)
            bool asyncInterfacesEnabled =
                GetVsiService().Options.AsyncInterfaces == AsyncInterfaces.ENABLED;

            var debugPropertyFactory = GetFactoryDecorator().Decorate(new DebugProperty.Factory(
                                                                          varInfoEnumFactory, childrenProviderFactory, debugCodeContextFactory,
                                                                          vsExpressionCreator, GetTaskExecutor()));
            var debugPropertyAsyncFactory =
                GetFactoryDecorator().Decorate(new DebugAsyncProperty.Factory(
                                                   varInfoEnumFactory, childrenProviderFactory, debugCodeContextFactory,
                                                   vsExpressionCreator, GetTaskExecutor()));

            var createDebugPropertyDelegate =
                asyncInterfacesEnabled
                ?(CreateDebugPropertyDelegate)
                debugPropertyAsyncFactory.Create : debugPropertyFactory.Create;

            concreteChildrenProviderFactory.Initialize(createDebugPropertyDelegate);

            var asyncEvaluatorFactory =
                GetFactoryDecorator().Decorate(new AsyncExpressionEvaluator.Factory(
                                                   createDebugPropertyDelegate, GetVarInfoBuilder(), vsExpressionCreator,
                                                   new ErrorDebugProperty.Factory(), debugEngineCommands,
                                                   GetVsiService().Options, GetExpressionEvaluationRecorder(), GetTimeSource()));

            var debugExpressionFactory = GetFactoryDecorator().Decorate(
                new DebugExpression.Factory(asyncEvaluatorFactory, GetTaskExecutor()));
            var debugAsyncExpressionFactory = GetFactoryDecorator().Decorate(
                new DebugAsyncExpression.Factory(asyncEvaluatorFactory, GetTaskExecutor()));
            var debugExpressionCreator =
                asyncInterfacesEnabled
                ?(CreateDebugExpressionDelegate)
                debugAsyncExpressionFactory.Create : debugExpressionFactory.Create;
            var registerSetsBuilderFactory = GetFactoryDecorator().Decorate(
                new RegisterSetsBuilder.Factory(GetVariableInformationFactory()));
            var debugStackFrameFactory = GetFactoryDecorator().Decorate(new DebugStackFrame.Factory(
                                                                            debugDocumentContextFactory, childrenProviderFactory, debugCodeContextFactory,
                                                                            debugExpressionCreator, GetVariableInformationFactory(), varInfoEnumFactory,
                                                                            registerSetsBuilderFactory, GetTaskExecutor()));
            var debugStackFrameFactoryAsync =
                GetFactoryDecorator().Decorate(new DebugStackFrameAsync.Factory(
                                                   debugDocumentContextFactory, childrenProviderFactory, debugCodeContextFactory,
                                                   debugExpressionCreator, GetVariableInformationFactory(), varInfoEnumFactory,
                                                   registerSetsBuilderFactory, GetTaskExecutor()));
            var debugStackFrameCreator =
                asyncInterfacesEnabled ?(CreateDebugStackFrameDelegate)
                debugStackFrameFactoryAsync.Create : debugStackFrameFactory.Create;
            var debugThreadFactory = GetFactoryDecorator().Decorate(new DebugThread.Factory(
                                                                        GetFactoryDecorator().Decorate(new FrameEnumFactory()), _taskExecutor));
            var debugThreadAsyncFactory =
                GetFactoryDecorator().Decorate(new DebugThreadAsync.Factory(
                                                   GetFactoryDecorator().Decorate(new FrameEnumFactory()), _taskExecutor));
            var debugThreadCreator = asyncInterfacesEnabled ?(CreateDebugThreadDelegate)
                                     debugThreadAsyncFactory.Create : debugThreadFactory.Create;
            var gameletFactory        = GetGameletClientFactory();
            var launchParamsConverter =
                new LaunchGameParamsConverter(GetSdkConfigFactory(), new QueryParametersParser());
            var gameLaunchManager = new GameLaunchBeHelper(gameletFactory.Create(GetCloudRunner()),
                                                           launchParamsConverter);
            var debugProgramFactory =
                GetFactoryDecorator().Decorate <IDebugProgramFactory>(new DebugProgram.Factory(
                                                                          GetJoinableTaskContext(),
                                                                          GetFactoryDecorator().Decorate(new DebugDisassemblyStream.Factory(
                                                                                                             debugCodeContextFactory, debugDocumentContextFactory)),
                                                                          debugDocumentContextFactory, debugCodeContextFactory,
                                                                          GetFactoryDecorator().Decorate(new ThreadEnumFactory()),
                                                                          GetFactoryDecorator().Decorate(new ModuleEnumFactory()),
                                                                          GetFactoryDecorator().Decorate(new CodeContextEnumFactory())));
            var breakpointErrorEnumFactory =
                GetFactoryDecorator().Decorate(new BreakpointErrorEnumFactory());
            var boundBreakpointEnumFactory =
                GetFactoryDecorator().Decorate(new BoundBreakpointEnumFactory());
            var breakpointManagerFactory = new LldbBreakpointManager.Factory(
                GetJoinableTaskContext(),
                GetFactoryDecorator().Decorate(new DebugPendingBreakpoint.Factory(
                                                   GetJoinableTaskContext(),
                                                   GetFactoryDecorator().Decorate(new DebugBoundBreakpoint.Factory(
                                                                                      debugDocumentContextFactory, debugCodeContextFactory,
                                                                                      GetFactoryDecorator().Decorate(new DebugBreakpointResolution.Factory()))),
                                                   breakpointErrorEnumFactory, boundBreakpointEnumFactory)),
                GetFactoryDecorator().Decorate(new DebugWatchpoint.Factory(
                                                   GetJoinableTaskContext(),
                                                   GetFactoryDecorator().Decorate(new DebugWatchpointResolution.Factory()),
                                                   breakpointErrorEnumFactory, boundBreakpointEnumFactory)));
            var eventManagerFactory =
                new LldbEventManager.Factory(boundBreakpointEnumFactory, GetJoinableTaskContext());
            var lldbDebuggerFactory               = new GrpcDebuggerFactory();
            var lldbListenerFactory               = new GrpcListenerFactory();
            var lldbPlatformShellCommandFactory   = new GrpcPlatformShellCommandFactory();
            var lldbPlatformFactory               = new GrpcPlatformFactory();
            var lldbPlatformConnectOptionsFactory = new GrpcPlatformConnectOptionsFactory();
            var grpcInterceptors = CreateGrpcInterceptors(GetVsiService().DebuggerOptions);
            var vsOutputWindow   =
                serviceManager.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            var callInvokerFactory      = new PipeCallInvokerFactory();
            var transportSessionFactory =
                new LldbTransportSession.Factory(new MemoryMappedFileFactory());
            var yetiTransport = new YetiDebugTransport(
                GetJoinableTaskContext(), transportSessionFactory, callInvokerFactory,
                new GrpcConnectionFactory(GetJoinableTaskContext().Factory,
                                          grpcInterceptors.ToArray()),
                GetTaskExecutor().CancelAsyncOperationIfRequested, processFactory, GetDialogUtil(),
                vsOutputWindow, GetVsiService());

            var testClientLauncherFactory = new ChromeClientsLauncher.Factory(
                new ChromeClientLaunchCommandFormatter(GetJsonUtil()), GetSdkConfigFactory(),
                GetChromeLauncher(backgroundProcessFactory));

            var exitDialogUtil         = new ExitDialogUtil(GetDialogUtil(), GetDialogExecutionContext());
            var preflightBinaryChecker =
                new PreflightBinaryChecker(GetFileSystem(), binaryFileUtil);
            var lldbShell = serviceManager.GetGlobalService(typeof(SLLDBShell)) as ILLDBShell;
            var attachedProgramFactory =
                GetFactoryDecorator().Decorate <ILldbAttachedProgramFactory>(
                    new LldbAttachedProgram.Factory(
                        GetJoinableTaskContext(),
                        GetFactoryDecorator().Decorate <IDebugEngineHandlerFactory>(
                            new DebugEngineHandler.Factory(GetJoinableTaskContext())),
                        GetTaskExecutor(), eventManagerFactory, debugProgramFactory,
                        debugModuleCacheFactory, debugModuleFactory, debugThreadCreator,
                        debugStackFrameCreator, lldbShell, breakpointManagerFactory,
                        symbolLoaderFactory, binaryLoaderFactory, moduleFileLoaderFactory));
            bool fastExpressionEvaluation = GetVsiService().Options.FastExpressionEvaluation ==
                                            FastExpressionEvaluation.ENABLED;
            var dumpModulesProvider     = new DumpModulesProvider(GetFileSystem());
            var moduleSearchLogHolder   = new ModuleSearchLogHolder();
            var coreAttachWarningDialog = new CoreAttachWarningDialogUtil(
                GetJoinableTaskContext(),
                GetDialogUtil());
            var debugSessionLauncherFactory = new DebugSessionLauncher.Factory(
                GetJoinableTaskContext(), lldbDebuggerFactory, lldbListenerFactory,
                lldbPlatformFactory, lldbPlatformConnectOptionsFactory,
                lldbPlatformShellCommandFactory, attachedProgramFactory, actionRecorder,
                moduleFileLoadRecorderFactory, exceptionManagerFactory, GetFileSystem(),
                fastExpressionEvaluation, moduleFileFinder, dumpModulesProvider,
                moduleSearchLogHolder, GetSymbolSettingsProvider(), coreAttachWarningDialog);
            var paramsFactory    = new Params.Factory(GetJsonUtil());
            var vsiLaunchFactory = new VsiGameLaunchFactory(gameletFactory.Create(GetCloudRunner()),
                                                            GetCancelableTaskFactory(),
                                                            gameLaunchManager, actionRecorder,
                                                            GetDialogUtil());
            var gameLauncher = new GameLauncher(gameletFactory.Create(GetCloudRunner()),
                                                GetVsiService(), launchParamsConverter,
                                                GetCancelableTaskFactory(), actionRecorder,
                                                GetDialogUtil(), vsiLaunchFactory);

            var remoteCommand = new RemoteCommand(processFactory);
            var remoteFile    = new RemoteFile(processFactory);
            var remoteDeploy  = new RemoteDeploy(remoteCommand, remoteFile, processFactory,
                                                 GetFileSystem());
            bool deployLldbServer       = IsInternalEngine();
            IDebugEngineFactory factory = new DebugEngine.Factory(
                GetJoinableTaskContext(), serviceManager, GetDebugSessionMetrics(), yetiTransport,
                actionRecorder, symbolServerHttpClient, moduleFileLoadRecorderFactory,
                moduleFileFinder, testClientLauncherFactory, GetNatvis(),
                GetNatvisDiagnosticLogger(), exitDialogUtil, preflightBinaryChecker,
                debugSessionLauncherFactory, paramsFactory, remoteDeploy, cancelableTaskFactory,
                GetDialogUtil(), GetNatvisLoggerOutputWindowListener(), GetSolutionExplorer(),
                debugEngineCommands,
                GetDebugEventCallbackDecorator(GetVsiService().DebuggerOptions),
                GetSymbolSettingsProvider(), deployLldbServer, gameLauncher);

            return(GetFactoryDecorator().Decorate(factory));
        }