aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/arch/s390/annotate/instructions.c
diff options
context:
space:
mode:
authorThomas Richter <tmricht@linux.vnet.ibm.com>2018-03-08 07:09:13 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-03-08 09:30:53 -0500
commit0b4b6b78a3ce07023052e44b967f5d42fa3d802c (patch)
treebf0374ab8d41f17e23fa3189c8d87c4fa428a1de /tools/perf/arch/s390/annotate/instructions.c
parentbb848c14f80d93059cb10b1e1446cc6823d77142 (diff)
perf annotate: Handle s390 PC relative load and store instruction.
S390 has several load and store instructions with target operand addressing relative to the program counter, for example lrl, lgrl, strl, stgrl. These instructions are handled similar to x86. Objdump output displays those instructions as: 9595c: c4 2d 00 09 9c 54 lgrl %r7,1c8540 <mp_+0x60> This output is parsed (like on x86) and perf annotate shows those lines as: lgrl %r7,mp_+0x60 This patch handles the s390 specific instruction parsing for PC relative load and store instructions. Signed-off-by: Thomas 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/20180308120913.14802-1-tmricht@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/arch/s390/annotate/instructions.c')
-rw-r--r--tools/perf/arch/s390/annotate/instructions.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c
index e80589fc5b58..46c21831f2ac 100644
--- a/tools/perf/arch/s390/annotate/instructions.c
+++ b/tools/perf/arch/s390/annotate/instructions.c
@@ -52,6 +52,61 @@ static struct ins_ops s390_call_ops = {
52 .scnprintf = call__scnprintf, 52 .scnprintf = call__scnprintf,
53}; 53};
54 54
55static int s390_mov__parse(struct arch *arch __maybe_unused,
56 struct ins_operands *ops,
57 struct map *map __maybe_unused)
58{
59 char *s = strchr(ops->raw, ','), *target, *endptr;
60
61 if (s == NULL)
62 return -1;
63
64 *s = '\0';
65 ops->source.raw = strdup(ops->raw);
66 *s = ',';
67
68 if (ops->source.raw == NULL)
69 return -1;
70
71 target = ++s;
72 ops->target.raw = strdup(target);
73 if (ops->target.raw == NULL)
74 goto out_free_source;
75
76 ops->target.addr = strtoull(target, &endptr, 16);
77 if (endptr == target)
78 goto out_free_target;
79
80 s = strchr(endptr, '<');
81 if (s == NULL)
82 goto out_free_target;
83 endptr = strchr(s + 1, '>');
84 if (endptr == NULL)
85 goto out_free_target;
86
87 *endptr = '\0';
88 ops->target.name = strdup(s + 1);
89 *endptr = '>';
90 if (ops->target.name == NULL)
91 goto out_free_target;
92
93 return 0;
94
95out_free_target:
96 zfree(&ops->target.raw);
97out_free_source:
98 zfree(&ops->source.raw);
99 return -1;
100}
101
102static int mov__scnprintf(struct ins *ins, char *bf, size_t size,
103 struct ins_operands *ops);
104
105static struct ins_ops s390_mov_ops = {
106 .parse = s390_mov__parse,
107 .scnprintf = mov__scnprintf,
108};
109
55static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name) 110static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name)
56{ 111{
57 struct ins_ops *ops = NULL; 112 struct ins_ops *ops = NULL;
@@ -68,6 +123,14 @@ static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *na
68 ops = &s390_call_ops; 123 ops = &s390_call_ops;
69 if (!strcmp(name, "br")) 124 if (!strcmp(name, "br"))
70 ops = &ret_ops; 125 ops = &ret_ops;
126 /* override load/store relative to PC */
127 if (!strcmp(name, "lrl") ||
128 !strcmp(name, "lgrl") ||
129 !strcmp(name, "lgfrl") ||
130 !strcmp(name, "llgfrl") ||
131 !strcmp(name, "strl") ||
132 !strcmp(name, "stgrl"))
133 ops = &s390_mov_ops;
71 134
72 if (ops) 135 if (ops)
73 arch__associate_ins_ops(arch, name, ops); 136 arch__associate_ins_ops(arch, name, ops);