From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Subject: [PATCH 6/9] perf annotate-data: Add is_pointer_type() helper
Date: Fri, 16 Aug 2024 16:58:36 -0700 [thread overview]
Message-ID: <20240816235840.2754937-7-namhyung@kernel.org> (raw)
In-Reply-To: <20240816235840.2754937-1-namhyung@kernel.org>
It treats pointers and arrays in the same way. Let's add the helper and
use it when it checks if it needs a pointer.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/annotate-data.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
index 5548cd8e84ba..b2414747cdeb 100644
--- a/tools/perf/util/annotate-data.c
+++ b/tools/perf/util/annotate-data.c
@@ -375,6 +375,13 @@ static const char *match_result_str(enum type_match_result tmr)
}
}
+static bool is_pointer_type(Dwarf_Die *type_die)
+{
+ int tag = dwarf_tag(type_die);
+
+ return tag == DW_TAG_pointer_type || tag == DW_TAG_array_type;
+}
+
/* The type info will be saved in @type_die */
static enum type_match_result check_variable(struct data_loc_info *dloc,
Dwarf_Die *var_die,
@@ -382,15 +389,15 @@ static enum type_match_result check_variable(struct data_loc_info *dloc,
int offset, bool is_fbreg)
{
Dwarf_Word size;
- bool is_pointer = true;
+ bool needs_pointer = true;
Dwarf_Die sized_type;
if (reg == DWARF_REG_PC)
- is_pointer = false;
+ needs_pointer = false;
else if (reg == dloc->fbreg || is_fbreg)
- is_pointer = false;
+ needs_pointer = false;
else if (arch__is(dloc->arch, "x86") && reg == X86_REG_SP)
- is_pointer = false;
+ needs_pointer = false;
/* Get the type of the variable */
if (__die_get_real_type(var_die, type_die) == NULL) {
@@ -403,9 +410,8 @@ static enum type_match_result check_variable(struct data_loc_info *dloc,
* Convert to a real type it points to. But global variables
* and local variables are accessed directly without a pointer.
*/
- if (is_pointer) {
- if ((dwarf_tag(type_die) != DW_TAG_pointer_type &&
- dwarf_tag(type_die) != DW_TAG_array_type) ||
+ if (needs_pointer) {
+ if (!is_pointer_type(type_die) ||
__die_get_real_type(type_die, type_die) == NULL) {
ann_data_stat.no_typeinfo++;
return PERF_TMR_NO_POINTER;
@@ -887,14 +893,13 @@ static enum type_match_result check_matching_type(struct type_state *state,
state->regs[reg].ok, state->regs[reg].kind);
if (state->regs[reg].ok && state->regs[reg].kind == TSR_KIND_TYPE) {
- int tag = dwarf_tag(&state->regs[reg].type);
Dwarf_Die sized_type;
/*
* Normal registers should hold a pointer (or array) to
* dereference a memory location.
*/
- if (tag != DW_TAG_pointer_type && tag != DW_TAG_array_type) {
+ if (!is_pointer_type(&state->regs[reg].type)) {
if (dloc->op->offset < 0 && reg != state->stack_reg)
goto check_kernel;
--
2.46.0.184.g6999bdac58-goog
next prev parent reply other threads:[~2024-08-16 23:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 23:58 [PATCHSET 0/9] perf annotate-data: Update data-type profiling quality (v1) Namhyung Kim
2024-08-16 23:58 ` [PATCH 1/9] perf dwarf-aux: Check allowed location expressions when collecting variables Namhyung Kim
2024-08-17 16:24 ` Masami Hiramatsu
2024-08-16 23:58 ` [PATCH 2/9] perf annotate-data: Fix off-by-one in location range check Namhyung Kim
2024-08-18 13:22 ` Masami Hiramatsu
2024-08-16 23:58 ` [PATCH 3/9] perf annotate-data: Add enum type_match_result Namhyung Kim
2024-08-16 23:58 ` [PATCH 4/9] perf annotate-data: Add variable_state_str() Namhyung Kim
2024-08-16 23:58 ` [PATCH 5/9] perf annotate-data: Change return type of find_data_type_block() Namhyung Kim
2024-08-16 23:58 ` Namhyung Kim [this message]
2024-08-16 23:58 ` [PATCH 7/9] perf annotate-data: Add is_better_type() helper Namhyung Kim
2024-08-16 23:58 ` [PATCH 8/9] perf annotate-data: Check variables in every scope Namhyung Kim
2024-08-16 23:58 ` [PATCH 9/9] perf annotate-data: Update type stat at the end of find_data_type_die() Namhyung Kim
2024-08-19 19:35 ` [PATCHSET 0/9] perf annotate-data: Update data-type profiling quality (v1) Arnaldo Carvalho de Melo
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=20240816235840.2754937-7-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/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®