]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Update DW_TAG_subprogram parsing for clang
authorMark Wielaard <mark@klomp.org>
Sat, 21 Jun 2025 21:04:04 +0000 (23:04 +0200)
committerMark Wielaard <mark@klomp.org>
Sat, 21 Jun 2025 21:18:29 +0000 (23:18 +0200)
Clang doesn't give a name for some artificial subprograms. In that
case just use "<artificial>" as the name of the DW_TAG_subprogram.

Clang also sometimes generates a DW_TAG_subprogram without any
attributes. These aren't really useful for us. So just silently skip
them.

If we warn about subprograms without a name, specification or abstract
origin, also emit the index in the .debug_info section to make it
easier to look them up.

coregrind/m_debuginfo/readdwarf3.c

index 745f2c43a64f2acf01c2de488b9e23760ad61376..49c5abb68d07ec6a18e7d0294fa8cbf7042fad91 100644 (file)
@@ -3617,18 +3617,27 @@ static Bool parse_inl_DIE (
             sub.isSubprogRef = False;
          }
       }
+      /* Clang doesn't give a name for some artificial subprograms.
+         Just use "<artificial>" as the name.  */
+      if (!name_or_spec && sub.isArtificial) {
+         name_or_spec = True;
+         fn = ML_(addStr)(cc->di, "<artificial>", -1);
+         sub.ref.fn = fn;
+         sub.isSubprogRef = False;
+      }
       if (name_or_spec)
          ML_(addSubprogram) (cc->di, &sub);
-      else {
+      else if (nf_i > 1 /* Clang produces empty subprograms, no attrs.  */
+               && VG_(clo_verbosity) >= 1) {
          /* Only warn once per debug file.  */
          static HChar *last_dbgname;
          HChar *dbgname = cc->di->fsm.dbgname
             ? cc->di->fsm.dbgname : cc->di->fsm.filename;
          if (last_dbgname != dbgname) {
-            if (VG_(clo_verbosity) >= 1)
-               VG_(message)(Vg_DebugMsg, "Warning: DW_TAG_subprogram with"
-                            " no DW_AT_name and no DW_AT_specification or"
-                            " DW_AT_abstract_origin in %s\n", dbgname);
+            VG_(message)(Vg_DebugMsg,
+                         "Warning: <%lx> DW_TAG_subprogram with no"
+                         " DW_AT_name and no DW_AT_specification or"
+                         " DW_AT_abstract_origin in %s\n", posn, dbgname);
             last_dbgname = dbgname;
          }
       }