[Bug libdw/34666] srcfiles missing main source in some cases

mark at klomp dot org sourceware-bugzilla@sourceware.org
Mon Sep 21 16:57:34 GMT 2026


https://sourceware.org/bugzilla/show_bug.cgi?id=34666

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at sourceware dot org   |mark at klomp dot org

--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
This looks like a reasonable fix. It pretends to always have a zero entry,
which is the cu name/file (plus comp_dir) whether or not we use --cu-only:

diff --git a/src/srcfiles.cxx b/src/srcfiles.cxx
index 9bbb6ef10473..e2fc0f128d71 100644
--- a/src/srcfiles.cxx
+++ b/src/srcfiles.cxx
@@ -273,10 +273,14 @@ collect_sourcefiles (Dwfl_Module *dwflmod,
             clog << "skipping cu=" << cuname << " due to empty comp_dir" <<
endl;
           continue;
         }
-      for (size_t f = 1; f < nfiles; ++f)
+      for (size_t f = 0; f < nfiles; ++f)
         {
+         /* For --cu-only we are only interested in the "zero" entry.  */
+         if (CU_only && f != 0)
+           break;
+
           const char *hat;
-          if (CU_only)
+          if (f == 0)
           {
             if (strcmp(cuname, "<unknown>") == 0 || strcmp(cuname,
"<artificial>") == 0 )
               continue;

It also fixes an inefficiency with -c. It would go through the whole list, but
always record the CU name. Now it just skips reading the whole list except for
the "fake" zero entry.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Elfutils-devel mailing list