summaryrefslogtreecommitdiff
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2023-12-12 16:13:22 -0800
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-12-23 22:40:13 -0300
commit61a9741e9f78c64c5178e4ae9d405eeceff04c8f (patch)
tree1ea825718de2b77cf6cf36c386615f778f46b559 /tools/perf/util/annotate.c
parent227ad323854ab48d45966461d7a0a94e03f19368 (diff)
perf annotate: Add --type-stat option for debugging
The --type-stat option is to be used with --data-type and to print detailed failure reasons for the data type annotation. $ perf annotate --data-type --type-stat Annotate data type stats: total 294, ok 116 (39.5%), bad 178 (60.5%) ----------------------------------------------------------- 30 : no_sym 40 : no_insn_ops 33 : no_mem_ops 63 : no_var 4 : no_typeinfo 8 : bad_offset Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> 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: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: linux-toolchains@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Link: https://lore.kernel.org/r/20231213001323.718046-17-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 68424ee0215e..9870257ce21e 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -103,6 +103,9 @@ static struct ins_ops nop_ops;
static struct ins_ops lock_ops;
static struct ins_ops ret_ops;
+/* Data type collection debug statistics */
+struct annotated_data_stat ann_data_stat;
+
static int arch__grow_instructions(struct arch *arch)
{
struct ins *new_instructions;
@@ -3683,14 +3686,22 @@ struct annotated_data_type *hist_entry__get_data_type(struct hist_entry *he)
u64 ip = he->ip;
int i;
- if (ms->map == NULL || ms->sym == NULL)
+ ann_data_stat.total++;
+
+ if (ms->map == NULL || ms->sym == NULL) {
+ ann_data_stat.no_sym++;
return NULL;
+ }
- if (!symbol_conf.init_annotation)
+ if (!symbol_conf.init_annotation) {
+ ann_data_stat.no_sym++;
return NULL;
+ }
- if (evsel__get_arch(evsel, &arch) < 0)
+ if (evsel__get_arch(evsel, &arch) < 0) {
+ ann_data_stat.no_insn++;
return NULL;
+ }
/* Make sure it runs objdump to get disasm of the function */
symbol__ensure_annotate(ms, evsel);
@@ -3700,11 +3711,15 @@ struct annotated_data_type *hist_entry__get_data_type(struct hist_entry *he)
* This is too slow...
*/
dl = find_disasm_line(ms->sym, ip);
- if (dl == NULL)
+ if (dl == NULL) {
+ ann_data_stat.no_insn++;
return NULL;
+ }
- if (annotate_get_insn_location(arch, dl, &loc) < 0)
+ if (annotate_get_insn_location(arch, dl, &loc) < 0) {
+ ann_data_stat.no_insn_ops++;
return NULL;
+ }
for_each_insn_op_loc(&loc, i, op_loc) {
if (!op_loc->mem_ref)
@@ -3721,5 +3736,7 @@ struct annotated_data_type *hist_entry__get_data_type(struct hist_entry *he)
he->mem_type_off = op_loc->offset;
return mem_type;
}
+
+ ann_data_stat.no_mem_ops++;
return NULL;
}