From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD17940DB55 for ; Wed, 29 Jul 2026 10:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785320467; cv=none; b=P4D30dMRzSEpd/4DO2dxLLqxlLexHGWWRSdZFqDe2L4/TAuwmRY7utR1vrnZxRk3BSv4RdFa9El3QwyYaRG6lNqZvX7f3c5JTL3tzxX1ZeMHeA3+lUvkiD0BRRK8FAMw8/gczzS5Fjx11u7Yqd/qs+RxGOxguDdxlUaKjD1XUBw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785320467; c=relaxed/simple; bh=lm7HkwRtfaKPxRJmndAb593LB5pEPAaiQkeDKCHyS2Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oxHN4uBLHQ+LhtNLfAJMj3cqVG0yM05ITVnrGRT/rrCJSNtBHclBj2fXlYNtKngyA6xGluwcafITEhYQ6Cgt+KUGJG8T4ytV4vTld48zK1q71W9AynW8TK8X2+M/1k+5Z5G9ShEEeWpRtmt4nx71rYlvEsGPgSpmYvs8caEw12Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=aid9Lx7K; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aid9Lx7K" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-69fc2261f2bso1120537a12.3 for ; Wed, 29 Jul 2026 03:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1785320464; x=1785925264; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=woyG06gmH+8jnzwxUeoujoEkRkTWjBa9EBmmYnPEOuc=; b=aid9Lx7Kqmr5giGIjdIKz0fxaEFNlfzJ2jbFSoRAzLLCh0enHmWSs5vBhDLURRd+O9 UFhwcZ1Z2TFq6wG6yYOQz4XETfhdX3465CNi3vSh6JTKcwcoLH7vAByl9k7HbexC1ea1 /5D0+50Xbji5+UsprF29HGOtedczS9207s0enUhugcSMTZ8BJtLURStT9ZJkKnBER1tn JStHvzIYZSFouMyAND19d9SUkI9MOGurgVjw6TYh/1T+U4m25XtRTLzBQVcDjTqDfumV UFdSi8IGU9DbNaCHpP6v4dC+Ib1fkzAcZaUevX7w919gyuXPBDKRsak1sIiFu/CNfSV9 LOXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785320464; x=1785925264; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=woyG06gmH+8jnzwxUeoujoEkRkTWjBa9EBmmYnPEOuc=; b=R0qZ7LqLjSFS/f1fGT7vMmIueC17gHYg4+CIill40J1kA+5zMn8LpV8Jtk74oxLbWn Tt2tyioo6LScqZthd2ezjgigcg/ToxaAeoVaw/0lJypyCLl1oMP524yNqgMJtleKc5hk D1HGp9x6DKxtMHfQBMQE3uzsFuoaJ2wiO5X4TJb6wcitUzfABfDSKJyGWb+4dCwL5qD1 8WhCO6F0snrSHfmE0un9qoS5r6xEZSb4cn2FiWXr3FTdWaqrmWbExkOKe0j0w5vMkLnP oztD6LbhO0k+64Lni4999sa1DcvUnM8vdMoZikwU4fECPUzPU7XbOW6mF+14lfVNEFBO F3Uw== X-Forwarded-Encrypted: i=1; AHgh+RpQbITnua79VFDU0JppQu27r+U/6/jJad/IuJpB8eV8Qx7q6Dw4sJFhEI+4VaZP/m2Yh6B++yCBAL+Z2fE=@vger.kernel.org X-Gm-Message-State: AOJu0YwieX52L0Gtp4jLBo26Jt+8sc1f4nsPmLJigIa3R8OXm9O+ceWk hbgOlrYc80V1OFUYV/CTqguTrKM6ENQ4l/FQr86IL/lL6O/1wECvAW3Tr8/BTO5rCJM= X-Gm-Gg: AR+sD10T12At+EasAfKDj+aAro4pHJmpGamAn5cFiTlIBffA3J8TwxgBBw1817yOpoH T7jcx9pKNUL3pyDyXIZwQ4zRaDWDWIEUGiaRnb2qO+iCYorQmQInG5h1L7oScppkfxQF4d+eXNx ORkVsiNT/27RJ/vXRVjAWEp5SPo1CXf4QNpCQftk87cllPXVlG0Hi70seHv9d1LdmGLmLWGLQn1 FNV2A81OtEFV3rw862/dikOdlOWMP0NZGo74edfTfwtGG2Ix3YIyfa2gE41B0Gn9nGtiHNJ35CV b0Tt8Kinqt2guI9zKY3szbmMjScQnmF+HeSauyzVwZfYh/7UYuaKrA92MVllzpXlA3gTjICVQ7i TkeWlH9HrZ+g6pajhSFGnSbge+uMTUyfInmeVkH1ZBkkMhKsmhWVzhDHmOFI3qCo46naBwjHgDE 9AqANPhAnEBZ+X3LwIAbPYd1QXkJLop1YKXrKoLEtnB7cJaGrhI+MzkMcnwNivkcZyRw== X-Received: by 2002:a05:6402:430b:b0:69f:4b71:41e7 with SMTP id 4fb4d7f45d1cf-6a0349eab87mr3375108a12.8.1785320464133; Wed, 29 Jul 2026 03:21:04 -0700 (PDT) Received: from [192.168.1.3] ([37.18.141.193]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a050c5cf21sm651510a12.21.2026.07.29.03.21.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jul 2026 03:21:03 -0700 (PDT) Message-ID: <7d980402-84d0-4cef-9bc2-af8fd5e13224@linaro.org> Date: Wed, 29 Jul 2026 11:21:02 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] perf libdw: Fix outer-frame name resolution and spurious "(inlined)" tag To: Michael Liang Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Namhyung Kim , Peter Zijlstra , Ingo Molnar References: <20260728204215.327318-1-mliang@purestorage.com> <20260728204215.327318-2-mliang@purestorage.com> Content-Language: en-US From: James Clark In-Reply-To: <20260728204215.327318-2-mliang@purestorage.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 28/07/2026 9:42 pm, Michael Liang wrote: > cu_walk_functions_at() calls libdw_a2l_cb() with the containing > DW_TAG_subprogram DIE first, then each DW_TAG_inlined_subroutine > nested inside. The callback treated both the same way, causing two > bugs: > > 1) die_name() returns the unqualified DW_AT_name, so every C++ > frame lost its namespace/class prefix (ns::Class::method > collapsed to method). > > 2) new_inline_sym() re-uses base_sym only when funcname matches > base_sym->name exactly; otherwise it fabricates a fake symbol > tagged "(inlined)". Any mismatch between the DWARF name and > the ELF symbol name mis-tags an outer, non-inline frame as > inlined. This hits C++ (die_name()'s unqualified output never > matches the demangled ELF symbol) and it also hits C functions > that GCC IPA-cloned (foo vs foo.isra.0 / .constprop / .part / > .cold), since DW_AT_linkage_name doesn't reflect those renames. > > Fix both: > > * Prefer die_get_linkage_name() (mangled, fully qualified), > falling back to die_name() when absent (C, extern "C"). > new_inline_sym() already demangles via dso__demangle_sym(). > > * For DW_TAG_subprogram DIEs, use base_sym directly -- the DIE > tag already tells us it is the outer function, sidestepping > the name comparison entirely for both C++ qualification and > GCC IPA-clone renames. > > Fixes: 88c51002d06f9a68 ("perf addr2line: Add a libdw implementation") > Signed-off-by: Michael Liang Reviewed-by: James Clark > --- > tools/perf/util/libdw.c | 34 ++++++++++++++++++++++++++++++---- > 1 file changed, 30 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/libdw.c b/tools/perf/util/libdw.c > index d5d2958902c0..4ca7e7e4fbe9 100644 > --- a/tools/perf/util/libdw.c > +++ b/tools/perf/util/libdw.c > @@ -82,13 +82,39 @@ struct libdw_a2l_cb_args { > static int libdw_a2l_cb(Dwarf_Die *die, void *_args) > { > struct libdw_a2l_cb_args *args = _args; > - struct symbol *inline_sym = new_inline_sym(args->dso, args->sym, die_name(die)); > const char *call_fname = die_get_call_file(die); > int call_lineno = die_get_call_lineno(die); > char *call_srcline = srcline__unknown; > - > - if (!inline_sym) > - goto abort_enomem; > + struct symbol *inline_sym; > + > + if (dwarf_tag(die) == DW_TAG_subprogram && args->sym) { > + /* > + * cu_walk_functions_at() opens the walk with the > + * containing DW_TAG_subprogram DIE (the non-inlined outer > + * function). That's just the base symbol -- use it > + * directly. Avoids a fragile name-vs-name compare in > + * new_inline_sym() that misfires when GCC IPA passes > + * (.isra/.constprop/.part/.cold) rename the ELF symbol > + * while DWARF keeps the pre-clone linkage name, which > + * left the outer frame spuriously tagged "(inlined)". > + */ > + inline_sym = args->sym; > + } else { > + /* > + * Prefer DW_AT_linkage_name so C++ inline frames keep > + * their namespace/class qualification. new_inline_sym() > + * runs the name through dso__demangle_sym(), so the > + * mangled linkage name is turned back into > + * "Namespace::Class::method". Fall back to DW_AT_name > + * (unqualified) when no linkage name is present, e.g. > + * for C code or extern "C" functions. > + */ > + const char *funcname = die_get_linkage_name(die) ?: die_name(die); > + > + inline_sym = new_inline_sym(args->dso, args->sym, funcname); > + if (!inline_sym) > + goto abort_enomem; > + } > > /* Assign caller information to the parent. */ > if (call_fname)