public async Task LoadSymbols_SymbolFileCustomDirSuccessAsync(bool useSymbolStores) { string customFileName = "x.debug"; string customFileDir = @"C:\custom"; string expectedCommand = "target symbols add -s \"/path/bin/test\" \"C:\\\\custom\\\\x.debug\""; var mockModule = CreateMockModule(); mockModule.GetSymbolFileSpec().Returns(mockBinaryFileSpec); mockBinaryFileUtil .ReadSymbolFileNameAsync(Path.Combine(BINARY_DIRECTORY, BINARY_FILENAME)) .Returns(customFileName); mockBinaryFileUtil .ReadSymbolFileDirAsync(Path.Combine(BINARY_DIRECTORY, BINARY_FILENAME)) .Returns(customFileDir); mockBinaryFileUtil.ReadBuildIdAsync(Path.Combine(customFileDir, customFileName)) .Returns(UUID); SetHandleCommandReturnValue(mockCommandInterpreter, expectedCommand, ReturnStatus.SuccessFinishResult, mockSuccessCommandReturnObject); Assert.IsTrue( await symbolLoader.LoadSymbolsAsync(mockModule, searchLog, useSymbolStores)); }
async Task <bool> VerifySymbolFileAsync(string filepath, BuildId buildId, bool isDebugInfoFile, TextWriter log) { try { await _binaryFileUtil.VerifySymbolFileAsync(filepath, isDebugInfoFile); if (buildId != BuildId.Empty) { var actualBuildId = await _binaryFileUtil.ReadBuildIdAsync(filepath); if (actualBuildId != buildId) { string errorMessage = Strings.BuildIdMismatch(filepath, buildId, actualBuildId); Trace.WriteLine(errorMessage); await log.WriteLineAsync(errorMessage); return(false); } } } catch (BinaryFileUtilException e) { Trace.WriteLine(e.Message); await log.WriteLineAsync(e.Message); return(false); } return(true); }
public override async Task <IFileReference> FindFileAsync(string filename, BuildId buildId, bool isDebugInfoFile, TextWriter log) { if (string.IsNullOrEmpty(filename)) { throw new ArgumentException(Strings.FilenameNullOrEmpty, "filename"); } string filepath; try { filepath = Path.Combine(_path, filename); } catch (ArgumentException e) { Trace.WriteLine(Strings.FailedToSearchFlatStore(_path, filename, e.Message)); await log.WriteLineAsync( Strings.FailedToSearchFlatStore(_path, filename, e.Message)); return(null); } if (!_fileSystem.File.Exists(filepath)) { Trace.WriteLine(Strings.FileNotFound(filepath)); await log.WriteLineAsync(Strings.FileNotFound(filepath)); return(null); } if (buildId != BuildId.Empty) { try { BuildId actualBuildId = await _binaryFileUtil.ReadBuildIdAsync(filepath); if (actualBuildId != buildId) { Trace.WriteLine(Strings.BuildIdMismatch(filepath, buildId, actualBuildId)); await log.WriteLineAsync( Strings.BuildIdMismatch(filepath, buildId, actualBuildId)); return(null); } } catch (BinaryFileUtilException e) { Trace.WriteLine(e.ToString()); await log.WriteLineAsync(e.Message); return(null); } } Trace.WriteLine(Strings.FileFound(filepath)); await log.WriteLineAsync(Strings.FileFound(filepath)); return(new FileReference(_fileSystem, filepath)); }
public async Task CheckRemoteBinaryOnAttachSucceedsAsync() { binaryFileUtil.ReadBuildIdAsync(remoteTargetPath, target) .Returns(Task.FromResult(validBuildId)); await action.RecordAsync(checker.CheckRemoteBinaryOnAttachAsync(remoteTargetPid, target, action)); metrics.Received().RecordEvent( DeveloperEventType.Types.Type.VsiDebugPreflightBinaryCheck, Arg.Is <DeveloperLogEvent>(m => m.StatusCode == DeveloperEventStatus.Types.Code.Success && m.DebugPreflightCheckData.CheckType == DebugPreflightCheckData.Types.CheckType.AttachOnly && m.DebugPreflightCheckData.RemoteBuildIdCheckResult == DebugPreflightCheckData.Types.RemoteBuildIdCheckResult .ValidRemoteBuildId)); }
public virtual async Task <bool> LoadSymbolsAsync( SbModule lldbModule, TextWriter searchLog, bool useSymbolStores) { if (lldbModule == null) { throw new ArgumentNullException(nameof(lldbModule)); } searchLog = searchLog ?? TextWriter.Null; // Return early if symbols are already loaded if (moduleUtil.HasSymbolsLoaded(lldbModule)) { return(true); } var(symbolFileDir, symbolFileName) = await GetSymbolFileDirAndNameAsync(lldbModule, searchLog); if (string.IsNullOrEmpty(symbolFileName)) { await searchLog.WriteLineAsync(ErrorStrings.SymbolFileNameUnknown); Trace.WriteLine(ErrorStrings.SymbolFileNameUnknown); return(false); } BuildId uuid = new BuildId(lldbModule.GetUUIDString()); // If we have a search directory, let us look up the symbol file in there. if (!string.IsNullOrEmpty(symbolFileDir)) { string symbolFilePath = string.Empty; try { symbolFilePath = Path.Combine(symbolFileDir, symbolFileName); BuildId fileUUID = await binaryFileUtil.ReadBuildIdAsync(symbolFilePath); if (fileUUID == uuid) { return(AddSymbolFile(symbolFilePath, lldbModule, searchLog)); } } catch (Exception e) when(e is InvalidBuildIdException || e is BinaryFileUtilException || e is ArgumentException) { // Just ignore the symbol file path if we could not read the build Id. Trace.WriteLine($"Could not read build Id from {symbolFilePath} " + $"for module {lldbModule.GetFileSpec().GetFilename()} " + $"(Message: {e.Message})."); } } var filepath = useSymbolStores ? await moduleFileFinder.FindFileAsync( symbolFileName, uuid, true, searchLog) : null; if (filepath == null) { return(false); } return(AddSymbolFile(filepath, lldbModule, searchLog)); }