Commit 0b58a77c authored by Thomas Richter's avatar Thomas Richter Committed by Arnaldo Carvalho de Melo

perf annotate: Fix s390 target function disassembly

'perf annotate' displays function call assembler instructions with a
right arrow. Hitting enter on this line/instruction causes the browser
to disassemble this target function and show it on the screen.  On s390
this results in an error message 'The called function was not found.'

The function call assembly line parsing does not handle the s390 bras
and brasl instructions. Function call__parse expects the target as first
operand:

	callq	e9140 <__fxstat>

S390 has a register number as first operand:

	brasl	%r14,41d60 <abort>

Therefore the target addresses on s390 are always zero which is an
invalid address.

Introduce a s390 specific call parsing function which skips the first
operand on s390.
Signed-off-by: default avatarThomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Link: http://lkml.kernel.org/r/20180307134325.96106-1-tmricht@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 599a5beb
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include <linux/compiler.h> #include <linux/compiler.h>
static int s390_call__parse(struct arch *arch, struct ins_operands *ops,
struct map *map)
{
char *endptr, *tok, *name;
struct addr_map_symbol target = {
.map = map,
};
tok = strchr(ops->raw, ',');
if (!tok)
return -1;
ops->target.addr = strtoull(tok + 1, &endptr, 16);
name = strchr(endptr, '<');
if (name == NULL)
return -1;
name++;
if (arch->objdump.skip_functions_char &&
strchr(name, arch->objdump.skip_functions_char))
return -1;
tok = strchr(name, '>');
if (tok == NULL)
return -1;
*tok = '\0';
ops->target.name = strdup(name);
*tok = '>';
if (ops->target.name == NULL)
return -1;
target.addr = map__objdump_2mem(map, ops->target.addr);
if (map_groups__find_ams(&target) == 0 &&
map__rip_2objdump(target.map, map->map_ip(target.map, target.addr)) == ops->target.addr)
ops->target.sym = target.sym;
return 0;
}
static int call__scnprintf(struct ins *ins, char *bf, size_t size,
struct ins_operands *ops);
static struct ins_ops s390_call_ops = {
.parse = s390_call__parse,
.scnprintf = call__scnprintf,
};
static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name) static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name)
{ {
struct ins_ops *ops = NULL; struct ins_ops *ops = NULL;
...@@ -14,7 +65,7 @@ static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *na ...@@ -14,7 +65,7 @@ static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *na
if (!strcmp(name, "bras") || if (!strcmp(name, "bras") ||
!strcmp(name, "brasl") || !strcmp(name, "brasl") ||
!strcmp(name, "basr")) !strcmp(name, "basr"))
ops = &call_ops; ops = &s390_call_ops;
if (!strcmp(name, "br")) if (!strcmp(name, "br"))
ops = &ret_ops; ops = &ret_ops;
......
...@@ -248,7 +248,7 @@ static struct ins_ops call_ops = { ...@@ -248,7 +248,7 @@ static struct ins_ops call_ops = {
bool ins__is_call(const struct ins *ins) bool ins__is_call(const struct ins *ins)
{ {
return ins->ops == &call_ops; return ins->ops == &call_ops || ins->ops == &s390_call_ops;
} }
static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map *map __maybe_unused) static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map *map __maybe_unused)
......
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