/// <summary>
        /// LoadLocalLldbInit looks for a local LLDB config (~/.lldbinit), logs its contents and
        /// then issues RPCs to load it in LLDB.  Internally LLDB will try to load one of the
        /// following files: ~/.lldbinit-{PROGRAM_NAME}, ~/.lldbinit, {CWD}/.lldbinit (in that
        /// order).  We check only for ~/.lldbinit and don't call `SourceInitFileInHomeDirectory`
        /// if it doesn't exist.
        /// </summary>
        void LoadLocalLldbInit(SbDebugger debugger)
        {
            var    lldbinitPath = SbDebuggerExtensions.GetLLDBInitPath();
            string lldbinit;

            try
            {
                lldbinit = _fileSystem.File.ReadAllText(lldbinitPath);
            }
            catch (FileNotFoundException)
            {
                Trace.WriteLine("No local ~/.lldbinit found, don't try loading it in LLDB.");
                return;
            }
            catch (Exception e)
            {
                Trace.WriteLine($"Unexpected error while reading {lldbinitPath}: {e}");
                return;
            }

            Trace.WriteLine($"Found ~/.lldbinit ({lldbinitPath}), LLDB will try to load it:" +
                            $"{Environment.NewLine}{lldbinit}{Environment.NewLine}EOF");

            debugger.SkipLLDBInitFiles(false);
            debugger.GetCommandInterpreter().SourceInitFileInHomeDirectory();
        }
示例#2
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);
        }
示例#3
0
 public static void SetDefaultLLDBSettings(this SbDebugger debugger)
 {
     foreach (string s in DefaultLLDBSettings)
     {
         debugger.GetCommandInterpreter().HandleAndLogCommand(s);
     }
 }
示例#4
0
        public void ExecuteCommandWithNoCommandInterpreter()
        {
            debuggerMock.GetCommandInterpreter().Returns((SbCommandInterpreter)null);

            shell.ExecuteCommand(DUMMY_COMMAND);

            Assert.That(commandWindowText, Does.Contain("ERROR"));
            Assert.That(logSpy.GetOutput(), Does.Contain("ERROR"));
            commandInterpreterMock.DidNotReceiveWithAnyArgs().HandleCommand(Arg.Any <string>(),
                                                                            out dummyReturnObject);
        }
        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));
        }
示例#6
0
 public static void SetLibrarySearchPath(this SbDebugger debugger, string path)
 {
     debugger.GetCommandInterpreter().HandleAndLogCommand(
         CreateSetLibrarySearchPathCommand(path));
 }
示例#7
0
 public static void EnableFastExpressionEvaluation(this SbDebugger debugger)
 {
     Trace.WriteLine("Enabling fast expression evaluation.");
     debugger.GetCommandInterpreter().HandleAndLogCommand(FastExpressionEvaluationCommand);
 }