/// <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 async Task TestInitFilesNotSourcedAsync([Values] bool stadiaPlatformAvailable) { // Ensure that local ~/.lldbinit doesn't exist. var lldbinitPath = SbDebuggerExtensions.GetLLDBInitPath(); Assert.IsFalse(_fileSystem.FileExists(lldbinitPath)); var launcherFactory = CreateLauncherFactory(stadiaPlatformAvailable); var launcher = launcherFactory.Create(_debugEngine, LaunchOption.AttachToCore, "some/core/path", "", "", _gameLaunch); await LaunchAsync(launcher); Assert.IsFalse(_debuggerFactory.Debugger.IsInitFileSourced); }
public async Task TestInitFilesSourcedAsync([Values] bool stadiaPlatformAvailable) { // Add ~/.lldbinit file, LLDB debugger should try loading it. var lldbinitPath = SbDebuggerExtensions.GetLLDBInitPath(); _fileSystem.AddFile(lldbinitPath, MockFileData.NullObject); var launcherFactory = CreateLauncherFactory(stadiaPlatformAvailable); var launcher = launcherFactory.Create(_debugEngine, LaunchOption.AttachToCore, "some/core/path", "", "", _gameLaunch); await LaunchAsync(launcher); Assert.IsTrue(_debuggerFactory.Debugger.IsInitFileSourced); }