mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>, Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	James Clark <james.clark@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org, Zecheng Li <zli94@ncsu.edu>,
	Yanbo Zhao <yzhao62@ncsu.edu>,
	Tengda Wu <wutengda@huaweicloud.com>,
	Shuai Xue <xueshuai@linux.alibaba.com>
Subject: Re: [PATCH v2 2/4] perf dwarf-aux: Add die_has_flex_array() helper
Date: Wed, 16 Sep 2026 22:56:13 +0900	[thread overview]
Message-ID: <20260916225613.f70bbbf7f627c593cb0beb2d@kernel.org> (raw)
In-Reply-To: <aqjdixZz4RYQZgCJ@google.com>

On Mon, 14 Sep 2026 22:54:19 -0700
Namhyung Kim <namhyung@kernel.org> wrote:

> > > +
> > > +	do {
> > > +		if (dwarf_tag(&die_mem) != DW_TAG_member)
> > > +			continue;
> > 
> > If the member is a "const" member, you may have to use
> > die_get_real_type() to get the actual type.
> > (in this case, you need a cursor DIE for dwarf_siblingof()) 
> 
> Doesn't it belong to a type of the member?  In my simple test program,
> it shows the struct type only has children of members and their types
> including const are referenced from the member DIEs.
> 
> Also I don't think flexible arrays will be const as they cannot be
> initialized.

Ah, indeed. flex array needs to be initialized. :)

> 
> > 
> > > +
> > > +		if (tag == DW_TAG_union_type) {
> > > +			if (is_flex_array_member(&die_mem))
> > > +				return true;
> > > +
> > > +			if (die_get_real_type(&die_mem, &last_mb) &&
> > > +			    die_has_flex_array_recurse(&last_mb, depth + 1))
> > > +				return true;
> > > +		}
> > > +
> > > +		if (tag == DW_TAG_structure_type)
> > > +			memcpy(&last_mb, &die_mem, sizeof(last_mb));
> > 
> > To find the last member, I think you'd better check the
> > DW_AT_data_member_location and DW_AT_decl_line to ensure the
> > DIE is the last member.
> 
> Good point.  I can add the member location check.  I'm afraid decl line
> may be incorrect if compiler randomized the layout.
> 
> So far I haven't seen DWARF data having unsorted members (by location),
> but it'd be better to make sure it's sorted.

OK, that maybe enough.

Thanks!


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

  reply	other threads:[~2026-09-16 13:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  6:45 [PATCH v2 0/4] perf annotate-data: Support flexible array types Namhyung Kim
2026-09-14  6:45 ` [PATCH v2 1/4] perf annotate-data: Convert type histogram to hashmap Namhyung Kim
2026-09-14 12:22   ` Tengda Wu
2026-09-14 18:56     ` Arnaldo Carvalho de Melo
2026-09-14 19:22       ` Arnaldo Carvalho de Melo
2026-09-14 20:42         ` Namhyung Kim
2026-09-14  6:45 ` [PATCH v2 2/4] perf dwarf-aux: Add die_has_flex_array() helper Namhyung Kim
2026-09-14 12:14   ` Tengda Wu
2026-09-14 20:28     ` Namhyung Kim
2026-09-14 23:40   ` Masami Hiramatsu
2026-09-15  5:54     ` Namhyung Kim
2026-09-16 13:56       ` Masami Hiramatsu [this message]
2026-09-14  6:45 ` [PATCH v2 3/4] perf annotate-date: Allow out-of-size access for flex-array types Namhyung Kim
2026-09-14 12:19   ` Tengda Wu
2026-09-14 20:39     ` Namhyung Kim
2026-09-14  6:45 ` [PATCH v2 4/4] perf annotate-data: Adjust type offset for flex-array Namhyung Kim

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=20260916225613.f70bbbf7f627c593cb0beb2d@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=wutengda@huaweicloud.com \
    --cc=xueshuai@linux.alibaba.com \
    --cc=yzhao62@ncsu.edu \
    --cc=zli94@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

all inboxes | Powered by JetHome®