From 6482db9f8b397b9f16742aa52410f5b70edcaea1 Mon Sep 17 00:00:00 2001
From: Walter Lozano <walter.lozano@collabora.com>
Date: Tue, 26 Jul 2022 22:35:39 -0300
Subject: [PATCH] Process files with missing DW_AT_name

With current behavior while scanning compile units the utility exits with
error if a unit does not contains an entry with name. However, some
packages, like arm-trusted-firmware, has entries without names. Since these
entries do not provide useful information for the mapping between binaries
to sources just skip them.

https://gitlab.apertis.org/infrastructure/apertis-issues/-/issues/81

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 src/main.rs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 7935413..b370e4e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -82,9 +82,12 @@ fn list_entries<R: Reader>(
                 .transpose()?
                 .ok_or_else(|| anyhow!("Missing DW_AT_comp_dir"))?;
 
-            let at_name = entry
-                .attr(gimli::DW_AT_name)?
-                .ok_or_else(|| anyhow!("Missing DW_AT_name"))?;
+            let at_name = if let Some(it) = entry.attr(gimli::DW_AT_name)? {
+                it
+            } else {
+                eprintln!("Warning: unit without name, skipping it");
+                continue;
+            };
 
             if let Some(r) = at_name.string_value(debug_str) {
                 let comp_name = r.to_string()?;
-- 
GitLab