From: sashiko-bot@kernel.org
To: "Yanbo Zhao" <yzhao62@ncsu.edu>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/3] perf dwarf-aux: Add die_is_compound_type() to handle C++ class types
Date: Fri, 21 Aug 2026 05:13:55 +0000 [thread overview]
Message-ID: <20260821051356.2BF9D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821050207.4517-2-yzhao62@ncsu.edu>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Empty Base Optimization (EBO) causes zero-sized base classes to shadow data members at the same offset.
- [Medium] Virtual inheritance uses complex location expressions that are unsupported, silently defaulting to offset 0.
--
--- Patch [1]: [PATCH 1/3] perf dwarf-aux: Add die_is_compound_type() to handle C++ class types ---
commit 9d64a45d6e2e13c946726cd0182607e969f8dd87
Author: Yanbo Zhao <yzhao62@ncsu.edu>
perf dwarf-aux: Add die_is_compound_type() to handle C++ class types
Introduce the die_is_compound_type() helper which checks for
DW_TAG_structure_type, DW_TAG_union_type, and DW_TAG_class_type, and
convert all the existing open-coded struct/union tag checks to use it.
Also accept DW_TAG_inheritance so member lookup descends into C++ base
classes.
> diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
> --- a/tools/perf/util/annotate-data.c
> +++ b/tools/perf/util/annotate-data.c
> @@ -230,9 +230,9 @@ static int __add_member_cb(Dwarf_Die *die, void *arg)
> Dwarf_Word size, loc, bit_size = 0;
> Dwarf_Attribute attr;
> struct strbuf sb;
> - int tag;
> + int tag = dwarf_tag(die);
>
> - if (dwarf_tag(die) != DW_TAG_member)
> + if (tag != DW_TAG_member && tag != DW_TAG_inheritance)
> return DIE_FIND_CB_SIBLING;
[Severity: Medium]
Since DW_TAG_inheritance is now processed here, how does this handle virtual
inheritance? Virtual base classes often use complex DWARF location
expressions (like DW_OP_deref).
Looking at the location parsing slightly further down in __add_member_cb():
if (dwarf_attr_integrate(die, DW_AT_data_member_location, &attr)) {
if (dwarf_formudata(&attr, &loc) != 0) {
if (die_get_data_member_location(die, &loc) != 0)
loc = 0;
}
}
If die_get_data_member_location() fails due to an unsupported complex
expression, it silently defaults to offset 0. Will this incorrectly assign
virtual base classes an offset of 0, potentially masking actual fields at
offset 0 like the vtable pointer?
[ ... ]
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
[ ... ]
> @@ -2053,7 +2061,7 @@ static int __die_find_member_offset_cb(Dwarf_Die *die_mem, void *arg)
> Dwarf_Word offset = (long)arg;
> int tag = dwarf_tag(die_mem);
>
> - if (tag != DW_TAG_member)
> + if (tag != DW_TAG_member && tag != DW_TAG_inheritance)
> return DIE_FIND_CB_SIBLING;
[Severity: Medium]
With DW_TAG_inheritance now included, does this code correctly handle the
Empty Base Optimization (EBO)?
Zero-sized base classes share the same offset as the first data member.
Further down in __die_find_member_offset_cb(), there is an exact offset
match check:
if (offset == loc)
return DIE_FIND_CB_END;
Since an empty base class often appears first in DWARF before the data
member, will this unconditionally return DIE_FIND_CB_END when matching the
empty base class? This appears to stop the search and cause data type
resolution to fail for the actual data member at the same offset.
Additionally, __die_find_member_offset_cb() contains similar location parsing
to __add_member_cb() which falls back to 0 if die_get_data_member_location()
fails. Could this also cause virtual base classes to incorrectly resolve to
offset 0 here?
> /* Unions might not have location */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260821050207.4517-1-yzhao62@ncsu.edu?part=1
next prev parent reply other threads:[~2026-08-21 5:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 5:02 [PATCH 0/3] perf annotate: Data type profiling support for C++ classes and virtual calls Yanbo Zhao
2026-08-21 5:02 ` [PATCH 1/3] perf dwarf-aux: Add die_is_compound_type() to handle C++ class types Yanbo Zhao
2026-08-21 5:13 ` sashiko-bot [this message]
2026-08-21 5:02 ` [PATCH 2/3] perf dwarf-aux: Add C++ class, inheritance and vtable helpers Yanbo Zhao
2026-08-21 5:12 ` sashiko-bot
2026-08-21 5:02 ` [PATCH 3/3] perf disasm & annotate x86: Track C++ vptr and resolve virtual function calls Yanbo Zhao
2026-08-21 5:26 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260821051356.2BF9D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yzhao62@ncsu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox