diff options
author | Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> | 2016-06-24 07:53:58 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-06-27 13:25:05 -0400 |
commit | 6ef9492915b09816c75bb41e7e37b2e507d2f70f (patch) | |
tree | 7dc66188a6168c9bcd799febdbe6ea9d7f923ba5 /tools/perf | |
parent | 9f776ba11c8be311a5c23777bc9f3b96498cc6cc (diff) |
perf annotate: Generalize handling of 'ret' instructions
Introduce helper to detect 'ret' instructions and use the same in the TUI.
A helper is needed since some architectures such as powerpc have more
than one return instruction.
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anton Blanchard <anton@ozlabs.org>
Cc: Daniel Axtens <dja@axtens.net>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Link: http://lkml.kernel.org/r/1466769240-12376-5-git-send-email-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 20 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 10 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 1 |
3 files changed, 20 insertions, 11 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 0e106bb97525..29dc6d20364e 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -223,16 +223,14 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
223 | } else if (ins__is_call(dl->ins)) { | 223 | } else if (ins__is_call(dl->ins)) { |
224 | ui_browser__write_graph(browser, SLSMG_RARROW_CHAR); | 224 | ui_browser__write_graph(browser, SLSMG_RARROW_CHAR); |
225 | SLsmg_write_char(' '); | 225 | SLsmg_write_char(' '); |
226 | } else if (ins__is_ret(dl->ins)) { | ||
227 | ui_browser__write_graph(browser, SLSMG_LARROW_CHAR); | ||
228 | SLsmg_write_char(' '); | ||
226 | } else { | 229 | } else { |
227 | ui_browser__write_nstring(browser, " ", 2); | 230 | ui_browser__write_nstring(browser, " ", 2); |
228 | } | 231 | } |
229 | } else { | 232 | } else { |
230 | if (strcmp(dl->name, "retq")) { | 233 | ui_browser__write_nstring(browser, " ", 2); |
231 | ui_browser__write_nstring(browser, " ", 2); | ||
232 | } else { | ||
233 | ui_browser__write_graph(browser, SLSMG_LARROW_CHAR); | ||
234 | SLsmg_write_char(' '); | ||
235 | } | ||
236 | } | 234 | } |
237 | 235 | ||
238 | disasm_line__scnprintf(dl, bf, sizeof(bf), !annotate_browser__opts.use_offset); | 236 | disasm_line__scnprintf(dl, bf, sizeof(bf), !annotate_browser__opts.use_offset); |
@@ -843,14 +841,14 @@ show_help: | |||
843 | ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); | 841 | ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org"); |
844 | else if (browser->selection->offset == -1) | 842 | else if (browser->selection->offset == -1) |
845 | ui_helpline__puts("Actions are only available for assembly lines."); | 843 | ui_helpline__puts("Actions are only available for assembly lines."); |
846 | else if (!browser->selection->ins) { | 844 | else if (!browser->selection->ins) |
847 | if (strcmp(browser->selection->name, "retq")) | 845 | goto show_sup_ins; |
848 | goto show_sup_ins; | 846 | else if (ins__is_ret(browser->selection->ins)) |
849 | goto out; | 847 | goto out; |
850 | } else if (!(annotate_browser__jump(browser) || | 848 | else if (!(annotate_browser__jump(browser) || |
851 | annotate_browser__callq(browser, evsel, hbt))) { | 849 | annotate_browser__callq(browser, evsel, hbt))) { |
852 | show_sup_ins: | 850 | show_sup_ins: |
853 | ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); | 851 | ui_helpline__puts("Actions are only available for function call/return & jump/branch instructions."); |
854 | } | 852 | } |
855 | continue; | 853 | continue; |
856 | case 't': | 854 | case 't': |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index b2c7ae465465..c385fecb9d32 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -354,6 +354,15 @@ static struct ins_ops nop_ops = { | |||
354 | .scnprintf = nop__scnprintf, | 354 | .scnprintf = nop__scnprintf, |
355 | }; | 355 | }; |
356 | 356 | ||
357 | static struct ins_ops ret_ops = { | ||
358 | .scnprintf = ins__raw_scnprintf, | ||
359 | }; | ||
360 | |||
361 | bool ins__is_ret(const struct ins *ins) | ||
362 | { | ||
363 | return ins->ops == &ret_ops; | ||
364 | } | ||
365 | |||
357 | static struct ins instructions[] = { | 366 | static struct ins instructions[] = { |
358 | { .name = "add", .ops = &mov_ops, }, | 367 | { .name = "add", .ops = &mov_ops, }, |
359 | { .name = "addl", .ops = &mov_ops, }, | 368 | { .name = "addl", .ops = &mov_ops, }, |
@@ -444,6 +453,7 @@ static struct ins instructions[] = { | |||
444 | { .name = "xadd", .ops = &mov_ops, }, | 453 | { .name = "xadd", .ops = &mov_ops, }, |
445 | { .name = "xbeginl", .ops = &jump_ops, }, | 454 | { .name = "xbeginl", .ops = &jump_ops, }, |
446 | { .name = "xbeginq", .ops = &jump_ops, }, | 455 | { .name = "xbeginq", .ops = &jump_ops, }, |
456 | { .name = "retq", .ops = &ret_ops, }, | ||
447 | }; | 457 | }; |
448 | 458 | ||
449 | static int ins__key_cmp(const void *name, const void *insp) | 459 | static int ins__key_cmp(const void *name, const void *insp) |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 82f3781138f9..a23084f54128 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -48,6 +48,7 @@ struct ins { | |||
48 | 48 | ||
49 | bool ins__is_jump(const struct ins *ins); | 49 | bool ins__is_jump(const struct ins *ins); |
50 | bool ins__is_call(const struct ins *ins); | 50 | bool ins__is_call(const struct ins *ins); |
51 | bool ins__is_ret(const struct ins *ins); | ||
51 | int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops); | 52 | int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops); |
52 | 53 | ||
53 | struct annotation; | 54 | struct annotation; |