Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ef94929 authored by Naveen N. Rao's avatar Naveen N. Rao Committed by Arnaldo Carvalho de Melo
Browse files

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: default avatarNaveen 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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9f776ba1
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -223,16 +223,14 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
			} else if (ins__is_call(dl->ins)) {
				ui_browser__write_graph(browser, SLSMG_RARROW_CHAR);
				SLsmg_write_char(' ');
			} else if (ins__is_ret(dl->ins)) {
				ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
				SLsmg_write_char(' ');
			} else {
				ui_browser__write_nstring(browser, " ", 2);
			}
		} else {
			if (strcmp(dl->name, "retq")) {
			ui_browser__write_nstring(browser, " ", 2);
			} else {
				ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
				SLsmg_write_char(' ');
			}
		}

		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,
				ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
			else if (browser->selection->offset == -1)
				ui_helpline__puts("Actions are only available for assembly lines.");
			else if (!browser->selection->ins) {
				if (strcmp(browser->selection->name, "retq"))
			else if (!browser->selection->ins)
				goto show_sup_ins;
			else if (ins__is_ret(browser->selection->ins))
				goto out;
			} else if (!(annotate_browser__jump(browser) ||
			else if (!(annotate_browser__jump(browser) ||
				     annotate_browser__callq(browser, evsel, hbt))) {
show_sup_ins:
				ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions.");
				ui_helpline__puts("Actions are only available for function call/return & jump/branch instructions.");
			}
			continue;
		case 't':
+10 −0
Original line number Diff line number Diff line
@@ -354,6 +354,15 @@ static struct ins_ops nop_ops = {
	.scnprintf = nop__scnprintf,
};

static struct ins_ops ret_ops = {
	.scnprintf = ins__raw_scnprintf,
};

bool ins__is_ret(const struct ins *ins)
{
	return ins->ops == &ret_ops;
}

static struct ins instructions[] = {
	{ .name = "add",   .ops  = &mov_ops, },
	{ .name = "addl",  .ops  = &mov_ops, },
@@ -444,6 +453,7 @@ static struct ins instructions[] = {
	{ .name = "xadd",  .ops  = &mov_ops, },
	{ .name = "xbeginl", .ops  = &jump_ops, },
	{ .name = "xbeginq", .ops  = &jump_ops, },
	{ .name = "retq",  .ops  = &ret_ops, },
};

static int ins__key_cmp(const void *name, const void *insp)
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ struct ins {

bool ins__is_jump(const struct ins *ins);
bool ins__is_call(const struct ins *ins);
bool ins__is_ret(const struct ins *ins);
int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops);

struct annotation;