Пример #1
0
        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();
                }
            }
        }
Пример #2
0
        protected static ISection?GetSection(IELF elf, string sectionName)
        {
            if (!elf.TryGetSection(sectionName, out ISection section))
            {
                return(null);
            }

            return(section);
        }
Пример #3
0
 public bool TryGetSection(string name, out ISection section)
 {
     return(_inner.TryGetSection(name, out section));
 }
Пример #4
0
 public bool TryGetSection(int index, out ISection section)
 {
     return(_inner.TryGetSection(index, out section));
 }