Skip to content

Commit 6ef9492

Browse files
rnavacmel
authored andcommitted
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>
1 parent 9f776ba commit 6ef9492

3 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎tools/perf/ui/browsers/annotate.c‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,14 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
223223
} else if (ins__is_call(dl->ins)) {
224224
ui_browser__write_graph(browser, SLSMG_RARROW_CHAR);
225225
SLsmg_write_char(' ');
226+
} else if (ins__is_ret(dl->ins)) {
227+
ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
228+
SLsmg_write_char(' ');
226229
} else {
227230
ui_browser__write_nstring(browser, " ", 2);
228231
}
229232
} else {
230-
if (strcmp(dl->name, "retq")) {
231-
ui_browser__write_nstring(browser, " ", 2);
232-
} else {
233-
ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
234-
SLsmg_write_char(' ');
235-
}
233+
ui_browser__write_nstring(browser, " ", 2);
236234
}
237235

238236
disasm_line__scnprintf(dl, bf, sizeof(bf), !annotate_browser__opts.use_offset);
@@ -843,14 +841,14 @@ static int annotate_browser__run(struct annotate_browser *browser,
843841
ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
844842
else if (browser->selection->offset == -1)
845843
ui_helpline__puts("Actions are only available for assembly lines.");
846-
else if (!browser->selection->ins) {
847-
if (strcmp(browser->selection->name, "retq"))
848-
goto show_sup_ins;
844+
else if (!browser->selection->ins)
845+
goto show_sup_ins;
846+
else if (ins__is_ret(browser->selection->ins))
849847
goto out;
850-
} else if (!(annotate_browser__jump(browser) ||
848+
else if (!(annotate_browser__jump(browser) ||
851849
annotate_browser__callq(browser, evsel, hbt))) {
852850
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.");
854852
}
855853
continue;
856854
case 't':

‎tools/perf/util/annotate.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,15 @@ static struct ins_ops nop_ops = {
354354
.scnprintf = nop__scnprintf,
355355
};
356356

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+
357366
static struct ins instructions[] = {
358367
{ .name = "add", .ops = &mov_ops, },
359368
{ .name = "addl", .ops = &mov_ops, },
@@ -444,6 +453,7 @@ static struct ins instructions[] = {
444453
{ .name = "xadd", .ops = &mov_ops, },
445454
{ .name = "xbeginl", .ops = &jump_ops, },
446455
{ .name = "xbeginq", .ops = &jump_ops, },
456+
{ .name = "retq", .ops = &ret_ops, },
447457
};
448458

449459
static int ins__key_cmp(const void *name, const void *insp)

‎tools/perf/util/annotate.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct ins {
4848

4949
bool ins__is_jump(const struct ins *ins);
5050
bool ins__is_call(const struct ins *ins);
51+
bool ins__is_ret(const struct ins *ins);
5152
int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops);
5253

5354
struct annotation;

0 commit comments

Comments
 (0)