From: Mark W. <ma...@so...> - 2025-06-21 23:41:15
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=116a1c8242891b5ddcd1ce9704b0ab90143cc968 commit 116a1c8242891b5ddcd1ce9704b0ab90143cc968 Author: Mark Wielaard <ma...@kl...> Date: Sat Jun 21 23:04:04 2025 +0200 Update DW_TAG_subprogram parsing for clang 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. Diff: --- coregrind/m_debuginfo/readdwarf3.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c index 745f2c43a6..49c5abb68d 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 "<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; } } |