From: Mark Wielaard Date: Sat, 21 Jun 2025 21:04:04 +0000 (+0200) Subject: Update DW_TAG_subprogram parsing for clang X-Git-Tag: VALGRIND_3_26_0~341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=116a1c8242891b5ddcd1ce9704b0ab90143cc968;p=thirdparty%2Fvalgrind.git Update DW_TAG_subprogram parsing for clang Clang doesn't give a name for some artificial subprograms. In that case just use "" 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. --- diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index 745f2c43a..49c5abb68 100644 --- a/coregrind/m_debuginfo/readdwarf3.c +++ b/coregrind/m_debuginfo/readdwarf3.c @@ -3617,18 +3617,27 @@ static Bool parse_inl_DIE ( sub.isSubprogRef = False; } } + /* Clang doesn't give a name for some artificial subprograms. + Just use "" as the name. */ + if (!name_or_spec && sub.isArtificial) { + name_or_spec = True; + fn = ML_(addStr)(cc->di, "", -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; } }