diff options
author | Namhyung Kim <namhyung@kernel.org> | 2024-08-16 16:58:36 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-08-19 11:40:57 -0300 |
commit | 98d1f1dc72fd6e0e85db4acc0b2dd591f4488216 (patch) | |
tree | b76705a9fe412227d17c28ba72676f8d86e42bd3 /tools/perf/util/annotate-data.c | |
parent | 69e2c78425c92361f0ab01cbbb8f3a44fc94341f (diff) |
perf annotate-data: Add is_pointer_type() helper
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>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240816235840.2754937-7-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate-data.c')
-rw-r--r-- | tools/perf/util/annotate-data.c | 23 |
1 files 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; |