1

perf annotate-data: Add pr_debug_scope()

The pr_debug_scope() is to print more information about the scope DIE
during the instruction tracking so that it can help finding relevant
debug info and the source code like inlined functions more easily.

  $ perf --debug type-profile annotate --data-type
  ...
  -----------------------------------------------------------
  find data type for 0(reg0, reg12) at set_task_cpu+0xdd
  CU for kernel/sched/core.c (die:0x1268dae)
  frame base: cfa=1 fbreg=7
  scope: [3/3] (die:12b6d28) [inlined] set_task_rq       <<<--- (here)
  bb: [9f - dd]
  var [9f] reg3 type='struct task_struct*' size=0x8 (die:0x126aff0)
  var [9f] reg6 type='unsigned int' size=0x4 (die:0x1268e0d)

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.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/20240909214251.3033827-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Namhyung Kim 2024-09-09 14:42:51 -07:00 committed by Arnaldo Carvalho de Melo
parent c8b9358778
commit 02648783c2

View File

@ -131,6 +131,26 @@ static void pr_debug_location(Dwarf_Die *die, u64 pc, int reg)
} }
} }
static void pr_debug_scope(Dwarf_Die *scope_die)
{
int tag;
if (!debug_type_profile && verbose < 3)
return;
pr_info("(die:%lx) ", (long)dwarf_dieoffset(scope_die));
tag = dwarf_tag(scope_die);
if (tag == DW_TAG_subprogram)
pr_info("[function] %s\n", dwarf_diename(scope_die));
else if (tag == DW_TAG_inlined_subroutine)
pr_info("[inlined] %s\n", dwarf_diename(scope_die));
else if (tag == DW_TAG_lexical_block)
pr_info("[block]\n");
else
pr_info("[unknown] tag=%x\n", tag);
}
bool has_reg_type(struct type_state *state, int reg) bool has_reg_type(struct type_state *state, int reg)
{ {
return (unsigned)reg < ARRAY_SIZE(state->regs); return (unsigned)reg < ARRAY_SIZE(state->regs);
@ -1305,8 +1325,9 @@ static enum type_match_result find_data_type_block(struct data_loc_info *dloc,
if (dwarf_ranges(&scopes[i], 0, &base, &start, &end) < 0) if (dwarf_ranges(&scopes[i], 0, &base, &start, &end) < 0)
break; break;
pr_debug_dtp("scope: [%d/%d] (die:%lx)\n", pr_debug_dtp("scope: [%d/%d] ", i + 1, nr_scopes);
i + 1, nr_scopes, (long)dwarf_dieoffset(&scopes[i])); pr_debug_scope(&scopes[i]);
src_ip = map__objdump_2rip(dloc->ms->map, start); src_ip = map__objdump_2rip(dloc->ms->map, start);
again: again: