perf annotate: Parse call targets earlier

No need to do it everytime the user presses enter/-> on a call
instruction.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-ybgss44m5ycry8mk7b1qdbre@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 4f9d0325
...@@ -266,11 +266,10 @@ static bool annotate_browser__callq(struct annotate_browser *browser, ...@@ -266,11 +266,10 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
struct symbol *target; struct symbol *target;
u64 ip; u64 ip;
if (strcmp(dl->name, "callq")) if (!ins__is_call(dl->ins))
return false; return false;
ip = strtoull(dl->operands, NULL, 16); ip = ms->map->map_ip(ms->map, dl->target);
ip = ms->map->map_ip(ms->map, ip);
target = map__find_symbol(ms->map, ip, NULL); target = map__find_symbol(ms->map, ip, NULL);
if (target == NULL) { if (target == NULL) {
ui_helpline__puts("The called function was not found."); ui_helpline__puts("The called function was not found.");
...@@ -318,7 +317,7 @@ static bool annotate_browser__jump(struct annotate_browser *browser) ...@@ -318,7 +317,7 @@ static bool annotate_browser__jump(struct annotate_browser *browser)
struct disasm_line *dl = browser->selection; struct disasm_line *dl = browser->selection;
s64 idx; s64 idx;
if (!dl->ins || !ins__is_jump(dl->ins)) if (!ins__is_jump(dl->ins))
return false; return false;
dl = annotate_browser__find_offset(browser, dl->target, &idx); dl = annotate_browser__find_offset(browser, dl->target, &idx);
...@@ -556,7 +555,8 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, ...@@ -556,7 +555,8 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx,
ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
else if (self->selection->offset == -1) else if (self->selection->offset == -1)
ui_helpline__puts("Actions are only available for assembly lines."); ui_helpline__puts("Actions are only available for assembly lines.");
else if (!(annotate_browser__jump(self) || else if (!self->selection->ins ||
!(annotate_browser__jump(self) ||
annotate_browser__callq(self, evidx, timer, arg, delay_secs))) annotate_browser__callq(self, evidx, timer, arg, delay_secs)))
ui_helpline__puts("Actions are only available for the 'callq' and jump instructions."); ui_helpline__puts("Actions are only available for the 'callq' and jump instructions.");
continue; continue;
......
...@@ -18,6 +18,21 @@ ...@@ -18,6 +18,21 @@
const char *disassembler_style; const char *disassembler_style;
static int call_ops__parse_target(const char *operands, u64 *target)
{
*target = strtoull(operands, NULL, 16);
return 0;
}
static struct ins_ops call_ops = {
.parse_target = call_ops__parse_target,
};
bool ins__is_call(const struct ins *ins)
{
return ins->ops == &call_ops;
}
static int jump_ops__parse_target(const char *operands, u64 *target) static int jump_ops__parse_target(const char *operands, u64 *target)
{ {
const char *s = strchr(operands, '+'); const char *s = strchr(operands, '+');
...@@ -38,11 +53,12 @@ bool ins__is_jump(const struct ins *ins) ...@@ -38,11 +53,12 @@ bool ins__is_jump(const struct ins *ins)
return ins->ops == &jump_ops; return ins->ops == &jump_ops;
} }
/* /*
* Must be sorted by name! * Must be sorted by name!
*/ */
static struct ins instructions[] = { static struct ins instructions[] = {
{ .name = "call", .ops = &call_ops, },
{ .name = "callq", .ops = &call_ops, },
{ .name = "ja", .ops = &jump_ops, }, { .name = "ja", .ops = &jump_ops, },
{ .name = "je", .ops = &jump_ops, }, { .name = "je", .ops = &jump_ops, },
{ .name = "jmp", .ops = &jump_ops, }, { .name = "jmp", .ops = &jump_ops, },
......
...@@ -17,6 +17,7 @@ struct ins { ...@@ -17,6 +17,7 @@ struct ins {
}; };
bool ins__is_jump(const struct ins *ins); bool ins__is_jump(const struct ins *ins);
bool ins__is_call(const struct ins *ins);
struct disasm_line { struct disasm_line {
struct list_head node; struct list_head node;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment