/// <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(); }
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); }
public static void SetDefaultLLDBSettings(this SbDebugger debugger) { foreach (string s in DefaultLLDBSettings) { debugger.GetCommandInterpreter().HandleAndLogCommand(s); } }
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)); }
public static void SetLibrarySearchPath(this SbDebugger debugger, string path) { debugger.GetCommandInterpreter().HandleAndLogCommand( CreateSetLibrarySearchPathCommand(path)); }
public static void EnableFastExpressionEvaluation(this SbDebugger debugger) { Trace.WriteLine("Enabling fast expression evaluation."); debugger.GetCommandInterpreter().HandleAndLogCommand(FastExpressionEvaluationCommand); }