コード例 #1
0
        public void SetUp()
        {
            logSpy = new LogSpy();
            logSpy.Attach();

            taskContext = new JoinableTaskContext();

            returnObjectMock = Substitute.For <SbCommandReturnObject>();
            returnObjectMock.GetDescription().Returns(COMMAND_DESCRIPTION);

            commandInterpreterMock = Substitute.For <SbCommandInterpreter>();
            commandInterpreterMock.WhenForAnyArgs(x => x.HandleCommand(DUMMY_COMMAND,
                                                                       out returnObjectMock)).Do(x => x[1] = returnObjectMock);

            debuggerMock = Substitute.For <SbDebugger>();
            debuggerMock.GetCommandInterpreter().Returns(commandInterpreterMock);

            commandWindowText = "";

            commandWindowMock = Substitute.For <IVsCommandWindow>();
            commandWindowMock.Print(Arg.Do <string>(x => commandWindowText += x));

            commandWindowWriter = new CommandWindowWriter(taskContext, commandWindowMock);

            shell = new YetiVSI.LLDBShell.LLDBShell(taskContext, commandWindowWriter);
            shell.AddDebugger(debuggerMock);
        }
コード例 #2
0
ファイル: SymbolLoader.cs プロジェクト: googlestadia/vsi-lldb
 public SymbolLoader(ILldbModuleUtil moduleUtil, IBinaryFileUtil binaryFileUtil,
                     IModuleFileFinder moduleFileFinder, SbCommandInterpreter lldbCommandInterpreter)
 {
     this.moduleUtil             = moduleUtil;
     this.binaryFileUtil         = binaryFileUtil;
     this.moduleFileFinder       = moduleFileFinder;
     this.lldbCommandInterpreter = lldbCommandInterpreter;
 }
コード例 #3
0
        void SetHandleCommandReturnValue(SbCommandInterpreter mockCommandInterpreter,
                                         string command, ReturnStatus returnStatus,
                                         SbCommandReturnObject returnObject)
        {
            SbCommandReturnObject _;

            mockCommandInterpreter.HandleCommand(command, out _).Returns(x => {
                x[1] = returnObject;
                return(returnStatus);
            });
        }
コード例 #4
0
        public static void HandleAndLogCommand(this SbCommandInterpreter commandInterpreter,
                                               string command)
        {
            SbCommandReturnObject commandResult;

            commandInterpreter.HandleCommand(command, out commandResult);
            if (commandResult == null)
            {
                Trace.WriteLine(
                    $"WARNING: The LLDB command '{command}' failed to return a result.");
                return;
            }
            Trace.WriteLine($"Executed LLDB command '{command}' with result: " +
                            $"{Environment.NewLine} {commandResult.GetDescription()}" +
                            $"{Environment.NewLine} Command error: {commandResult.GetError()}" +
                            $"{Environment.NewLine} Command output: {commandResult.GetOutput()}");
        }
コード例 #5
0
        public void SetUp()
        {
            searchLog = new StringWriter();

            mockBinaryFileUtil = Substitute.For <IBinaryFileUtil>();

            mockSuccessCommandReturnObject = Substitute.For <SbCommandReturnObject>();
            mockSuccessCommandReturnObject.GetOutput().Returns(LLDB_OUTPUT);
            mockSuccessCommandReturnObject.GetDescription().Returns("Success: " + LLDB_OUTPUT);
            mockSuccessCommandReturnObject.Succeeded().Returns(true);

            mockCommandInterpreter = Substitute.For <SbCommandInterpreter>();
            SetHandleCommandReturnValue(mockCommandInterpreter, COMMAND_WITH_MODULE_PATH,
                                        ReturnStatus.SuccessFinishResult,
                                        mockSuccessCommandReturnObject);

            mockPlatformFileSpec = Substitute.For <SbFileSpec>();
            mockPlatformFileSpec.GetDirectory().Returns(PLATFORM_DIRECTORY);
            mockPlatformFileSpec.GetFilename().Returns(BINARY_FILENAME);

            mockSymbolFileSpec = Substitute.For <SbFileSpec>();
            mockSymbolFileSpec.GetDirectory().Returns("");
            mockSymbolFileSpec.GetFilename().Returns(SYMBOL_FILE_NAME);

            mockBinaryFileSpec = Substitute.For <SbFileSpec>();
            mockBinaryFileSpec.GetDirectory().Returns(BINARY_DIRECTORY);
            mockBinaryFileSpec.GetFilename().Returns(BINARY_FILENAME);

            mockModuleFileFinder = Substitute.For <IModuleFileFinder>();
            SetFindFileReturnValue(PATH_IN_STORE);
            mockModuleUtil = Substitute.For <ILldbModuleUtil>();
            mockModuleUtil.HasSymbolsLoaded(Arg.Any <SbModule>()).Returns(false);

            symbolLoader = new SymbolLoader(mockModuleUtil, mockBinaryFileUtil,
                                            mockModuleFileFinder, mockCommandInterpreter);

            symbolFileInStore = Substitute.For <IFileReference>();
            symbolFileInStore.IsFilesystemLocation.Returns(true);
            symbolFileInStore.Location.Returns(PATH_IN_STORE);

            logSpy = new LogSpy();
            logSpy.Attach();
        }
コード例 #6
0
        public override Task <GetCommandInterpreterResponse> GetCommandInterpreter(
            GetCommandInterpreterRequest request,
            ServerCallContext context)
        {
            SbDebuggerPreconditionCheck();
            SbCommandInterpreter interpreter = sbDebugger.GetCommandInterpreter();

            if (interpreter == null)
            {
                return(Task.FromResult(new GetCommandInterpreterResponse()));
            }

            var response = new GetCommandInterpreterResponse()
            {
                Interpreter = new GrpcSbCommandInterpreter {
                    Id = interpreterStore.AddObject(interpreter)
                }
            };

            return(Task.FromResult(response));
        }
コード例 #7
0
            public ILldbAttachedProgram Create(
                IDebugProcess2 debugProcess, Guid programId, IDebugEngine2 debugEngine,
                IDebugEventCallback2 callback, SbDebugger debugger, RemoteTarget target,
                LldbListenerSubscriber listenerSubscriber, SbProcess process,
                SbCommandInterpreter commandInterpreter, bool isCoreAttach,
                IExceptionManager exceptionManager, IModuleSearchLogHolder moduleSearchLogHolder,
                uint remotePid)
            {
                // Required due to an issue triggered by the proxy used to wrap debugProgramFactory.
                // TODO: Remove assertion once the issue with Castle.DynamicProxy is
                // fixed.
                _taskContext.ThrowIfNotOnMainThread();

                var debugEngineHandler = _debugEngineHandlerFactory.Create(debugEngine, callback);

                var binaryLoader     = _binaryLoaderFactory.Create(target);
                var symbolLoader     = _symbolLoaderFactory.Create(commandInterpreter);
                var moduleFileLoader = _moduleFileLoaderFactory.Create(symbolLoader, binaryLoader,
                                                                       moduleSearchLogHolder);

                var debugModuleCache = _debugModuleCacheFactory.Create(
                    (lldbModule, loadOrder, ggpProgram) => _debugModuleFactory.Create(
                        moduleFileLoader, moduleSearchLogHolder, lldbModule, loadOrder,
                        debugEngineHandler, ggpProgram));
                var ad7FrameInfoCreator = new AD7FrameInfoCreator(debugModuleCache);

                var stackFrameCreator = new StackFramesProvider.StackFrameCreator(
                    (frame, thread, program) => _debugStackFrameCreator(
                        ad7FrameInfoCreator, frame, thread, debugEngineHandler, program));
                var threadCreator = new DebugProgram.ThreadCreator(
                    (thread, program) => _debugThreadCreatorDelegate(
                        ad7FrameInfoCreator, stackFrameCreator, thread, program));
                var debugProgram = _debugProgramFactory.Create(
                    debugEngineHandler, threadCreator, debugProcess, programId, process, target,
                    debugModuleCache, isCoreAttach);

                _taskExecutor.StartAsyncTasks(
                    ex => debugEngineHandler.Abort(debugProgram, ExitInfo.Error(ex)));

                var breakpointManager =
                    _breakpointManagerFactory.Create(debugEngineHandler, debugProgram);
                var eventManager =
                    _eventManagerFactory.Create(debugEngineHandler, breakpointManager, debugProgram,
                                                process, listenerSubscriber);

                // TODO: Listen for module load/unload events from LLDB
                binaryLoader.LldbModuleReplaced += (o, args) =>
                {
                    debugModuleCache.GetOrCreate(args.AddedModule, debugProgram);
                    debugModuleCache.Remove(args.RemovedModule);
                };
                debugModuleCache.ModuleAdded += (o, args) =>
                                                debugEngineHandler.OnModuleLoad(args.Module, debugProgram);
                debugModuleCache.ModuleRemoved += (o, args) =>
                                                  debugEngineHandler.OnModuleUnload(args.Module, debugProgram);

                return(new LldbAttachedProgram(breakpointManager, eventManager, _lldbShell,
                                               moduleFileLoader, debugEngineHandler, _taskExecutor,
                                               debugProgram, debugger, target, process,
                                               exceptionManager, debugModuleCache,
                                               listenerSubscriber, remotePid));
            }
コード例 #8
0
ファイル: SymbolLoader.cs プロジェクト: googlestadia/vsi-lldb
 public virtual ISymbolLoader Create(SbCommandInterpreter lldbCommandInterpreter) =>
 new SymbolLoader(moduleUtil, binaryFileUtil, moduleFileFinder,
                  lldbCommandInterpreter);