private async Task Collect(string path) { var files = Directory.GetFiles(path); _logger.LogInformation("Path {path} has {length} files to process", path, files.Length); foreach (var file in files) { _logger.LogInformation("Processing file: {file}.", file); IELF elf = null; try { if (!ELFReader.TryLoad(file, out elf)) { _logger.LogWarning("Couldn't load': {file} with ELF reader.", file); continue; } var hasBuildId = elf.TryGetSection(".note.gnu.build-id", out var buildId); if (!hasBuildId) { _logger.LogWarning("No Debug Id in {file}", file); continue; } var hasUnwindingInfo = elf.TryGetSection(".eh_frame", out _); var hasDwarfDebugInfo = elf.TryGetSection(".debug_frame", out _); if (!hasUnwindingInfo && !hasDwarfDebugInfo) { _logger.LogWarning("No unwind nor DWARF debug info in {file}", file); continue; } await ProcessFile(file, hasUnwindingInfo, hasDwarfDebugInfo, buildId, elf); } catch (Exception e) { // You would expect TryLoad doesn't throw but that's not the case _logger.LogError(e, "Failed processing file {file}.", file); } finally { elf?.Dispose(); } } }
protected static ISection?GetSection(IELF elf, string sectionName) { if (!elf.TryGetSection(sectionName, out ISection section)) { return(null); } return(section); }
public bool TryGetSection(string name, out ISection section) { return(_inner.TryGetSection(name, out section)); }
public bool TryGetSection(int index, out ISection section) { return(_inner.TryGetSection(index, out section)); }