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

Commit 657bcaf5 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf annotate browser: Use the disasm_line instruction name and operand fields

No need to reparse it everytime.

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-90ncot487p4h5rzkn8h2whou@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5145418b
Loading
Loading
Loading
Loading
+10 −19
Original line number Original line Diff line number Diff line
@@ -260,22 +260,16 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
				    void *arg, int delay_secs)
				    void *arg, int delay_secs)
{
{
	struct map_symbol *ms = browser->b.priv;
	struct map_symbol *ms = browser->b.priv;
	struct disasm_line *dl = browser->selection;
	struct symbol *sym = ms->sym;
	struct symbol *sym = ms->sym;
	struct annotation *notes;
	struct annotation *notes;
	struct symbol *target;
	struct symbol *target;
	char *s = strstr(browser->selection->line, "callq ");
	u64 ip;
	u64 ip;


	if (s == NULL)
	if (strcmp(dl->name, "callq"))
		return false;
		return false;


	s = strchr(s, ' ');
	ip = strtoull(dl->operands, NULL, 16);
	if (s++ == NULL) {
		ui_helpline__puts("Invallid callq instruction.");
		return true;
	}

	ip = strtoull(s, NULL, 16);
	ip = ms->map->map_ip(ms->map, ip);
	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) {
@@ -322,21 +316,18 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *brows
static bool annotate_browser__jump(struct annotate_browser *browser)
static bool annotate_browser__jump(struct annotate_browser *browser)
{
{
	const char *jumps[] = { "je", "jne", "ja", "jmpq", "js", "jmp", NULL };
	const char *jumps[] = { "je", "jne", "ja", "jmpq", "js", "jmp", NULL };
	struct disasm_line *dl;
	struct disasm_line *dl = browser->selection;
	s64 idx, offset;
	s64 idx, offset;
	char *s = NULL;
	char *s;
	int i = 0;
	int i = 0;


	while (jumps[i]) {
	while (jumps[i] && strcmp(dl->name, jumps[i]))
		s = strstr(browser->selection->line, jumps[i++]);
		++i;
		if (s)
			break;
	}


	if (s == NULL)
	if (jumps[i] == NULL)
		return false;
		return false;


	s = strchr(s, '+');
	s = strchr(dl->operands, '+');
	if (s++ == NULL) {
	if (s++ == NULL) {
		ui_helpline__puts("Invallid jump instruction.");
		ui_helpline__puts("Invallid jump instruction.");
		return true;
		return true;