Skip to content

Commit 0264878

Browse files
namhyungacmel
authored andcommitted
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 <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c8b9358 commit 0264878

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tools/perf/util/annotate-data.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,26 @@ static void pr_debug_location(Dwarf_Die *die, u64 pc, int reg)
131131
}
132132
}
133133

134+
static void pr_debug_scope(Dwarf_Die *scope_die)
135+
{
136+
int tag;
137+
138+
if (!debug_type_profile && verbose < 3)
139+
return;
140+
141+
pr_info("(die:%lx) ", (long)dwarf_dieoffset(scope_die));
142+
143+
tag = dwarf_tag(scope_die);
144+
if (tag == DW_TAG_subprogram)
145+
pr_info("[function] %s\n", dwarf_diename(scope_die));
146+
else if (tag == DW_TAG_inlined_subroutine)
147+
pr_info("[inlined] %s\n", dwarf_diename(scope_die));
148+
else if (tag == DW_TAG_lexical_block)
149+
pr_info("[block]\n");
150+
else
151+
pr_info("[unknown] tag=%x\n", tag);
152+
}
153+
134154
bool has_reg_type(struct type_state *state, int reg)
135155
{
136156
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,
13051325
if (dwarf_ranges(&scopes[i], 0, &base, &start, &end) < 0)
13061326
break;
13071327

1308-
pr_debug_dtp("scope: [%d/%d] (die:%lx)\n",
1309-
i + 1, nr_scopes, (long)dwarf_dieoffset(&scopes[i]));
1328+
pr_debug_dtp("scope: [%d/%d] ", i + 1, nr_scopes);
1329+
pr_debug_scope(&scopes[i]);
1330+
13101331
src_ip = map__objdump_2rip(dloc->ms->map, start);
13111332

13121333
again:

0 commit comments

Comments
 (0)