[tip:perf/core] perf annotate: Use ops->target.name when available for unresolved call targets

From: tip-bot for Arnaldo Carvalho de Melo
Date: Tue Mar 20 2018 - 02:38:15 EST


Commit-ID: 4c9cb2c2b4b5530717f74b2252f8cc4c45b2a918
Gitweb: https://git.kernel.org/tip/4c9cb2c2b4b5530717f74b2252f8cc4c45b2a918
Author: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
AuthorDate: Fri, 16 Mar 2018 13:28:09 -0300
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Mon, 19 Mar 2018 13:51:52 -0300

perf annotate: Use ops->target.name when available for unresolved call targets

There is a bug where when using 'perf annotate timerqueue_add' the
target for its only routine called with the 'callq' instruction,
'rb_insert_color', doesn't get resolved from its address when parsing
that 'callq' instruction.

That symbol resolution works when using 'perf report --tui' and then
doing annotation for 'timerqueue_add' from there, the vmlinux
dso->symbols rb_tree somehow gets in a state that we can't find that
address, that is a bug that has to be further investigated.

But since the objdump output has the function name, i.e. the raw objdump
disassembled line looks like:

So, before:

# perf annotate timerqueue_add

â mov %rbx,%rdi
â mov %rbx,(%rdx)
â â callq *ffffffff8184dc80
â mov 0x8(%rbp),%rdx
â test %rdx,%rdx
â â je 67

# perf report

â mov %rbx,%rdi
â mov %rbx,(%rdx)
â â callq rb_insert_color
â mov 0x8(%rbp),%rdx
â test %rdx,%rdx
â â je 67

And after both look the same:

# perf annotate timerqueue_add

â mov %rbx,%rdi
â mov %rbx,(%rdx)
â â callq rb_insert_color
â mov 0x8(%rbp),%rdx
â test %rdx,%rdx
â â je 67

>From 'perf report' one can annotate and navigate to that 'rb_insert_color'
function, but not directly from 'perf annotate timerqueue_add', that
remains to be investigated and fixed.

Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Jin Yao <yao.jin@xxxxxxxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Wang Nan <wangnan0@xxxxxxxxxx>
Link: https://lkml.kernel.org/n/tip-nkktz6355rhqtq7o8atr8f8r@xxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/annotate.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ddad87f34a68..535357c6ce02 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -238,6 +238,9 @@ static int call__scnprintf(struct ins *ins, char *bf, size_t size,
if (ops->target.addr == 0)
return ins__raw_scnprintf(ins, bf, size, ops);

+ if (ops->target.name)
+ return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.name);
+
return scnprintf(bf, size, "%-6s *%" PRIx64, ins->name, ops->target.addr);
}