* [PATCH] perf annotate: Handle s390 pc relative load and store instruction.
@ 2018-03-08 12:09 Thomas Richter
2018-03-08 12:52 ` Arnaldo Carvalho de Melo
2018-03-09 8:58 ` [tip:perf/core] perf annotate: Handle s390 PC " tip-bot for Thomas Richter
0 siblings, 2 replies; 3+ messages in thread
From: Thomas Richter @ 2018-03-08 12:09 UTC (permalink / raw)
To: linux-kernel, linux-perf-users, acme
Cc: brueckner, schwidefsky, heiko.carstens, Thomas Richter
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>
---
tools/perf/arch/s390/annotate/instructions.c | 63 ++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c
index 0a3e39b5143d..0c54f1b33ac0 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 = {
.scnprintf = call__scnprintf,
};
+static int s390_mov__parse(struct arch *arch __maybe_unused,
+ struct ins_operands *ops,
+ struct map *map __maybe_unused)
+{
+ char *s = strchr(ops->raw, ','), *target, *endptr;
+
+ if (s == NULL)
+ return -1;
+
+ *s = '\0';
+ ops->source.raw = strdup(ops->raw);
+ *s = ',';
+
+ if (ops->source.raw == NULL)
+ return -1;
+
+ target = ++s;
+ ops->target.raw = strdup(target);
+ if (ops->target.raw == NULL)
+ goto out_free_source;
+
+ ops->target.addr = strtoull(target, &endptr, 16);
+ if (endptr == target)
+ goto out_free_target;
+
+ s = strchr(endptr, '<');
+ if (s == NULL)
+ goto out_free_target;
+ endptr = strchr(s + 1, '>');
+ if (endptr == NULL)
+ goto out_free_target;
+
+ *endptr = '\0';
+ ops->target.name = strdup(s + 1);
+ *endptr = '>';
+ if (ops->target.name == NULL)
+ goto out_free_target;
+
+ return 0;
+
+out_free_target:
+ zfree(&ops->target.raw);
+out_free_source:
+ zfree(&ops->source.raw);
+ return -1;
+}
+
+static int mov__scnprintf(struct ins *ins, char *bf, size_t size,
+ struct ins_operands *ops);
+
+static struct ins_ops s390_mov_ops = {
+ .parse = s390_mov__parse,
+ .scnprintf = mov__scnprintf,
+};
+
static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name)
{
struct ins_ops *ops = NULL;
@@ -68,6 +123,14 @@ static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *na
ops = &s390_call_ops;
if (!strcmp(name, "br"))
ops = &ret_ops;
+ /* override load/store relative to PC */
+ if (!strcmp(name, "lrl") ||
+ !strcmp(name, "lgrl") ||
+ !strcmp(name, "lgfrl") ||
+ !strcmp(name, "llgfrl") ||
+ !strcmp(name, "strl") ||
+ !strcmp(name, "stgrl"))
+ ops = &s390_mov_ops;
if (ops)
arch__associate_ins_ops(arch, name, ops);
--
2.14.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf annotate: Handle s390 pc relative load and store instruction.
2018-03-08 12:09 [PATCH] perf annotate: Handle s390 pc relative load and store instruction Thomas Richter
@ 2018-03-08 12:52 ` Arnaldo Carvalho de Melo
2018-03-09 8:58 ` [tip:perf/core] perf annotate: Handle s390 PC " tip-bot for Thomas Richter
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-03-08 12:52 UTC (permalink / raw)
To: Thomas Richter
Cc: linux-kernel, linux-perf-users, brueckner, schwidefsky,
heiko.carstens
Em Thu, Mar 08, 2018 at 01:09:13PM +0100, Thomas Richter escreveu:
> S390 has several load and store instructions with target operand
> addressing relative to the program counter, for example lrl, lgrl,
> strl, stgrl.
Thanks, applied.
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:perf/core] perf annotate: Handle s390 PC relative load and store instruction.
2018-03-08 12:09 [PATCH] perf annotate: Handle s390 pc relative load and store instruction Thomas Richter
2018-03-08 12:52 ` Arnaldo Carvalho de Melo
@ 2018-03-09 8:58 ` tip-bot for Thomas Richter
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Thomas Richter @ 2018-03-09 8:58 UTC (permalink / raw)
To: linux-tip-commits
Cc: hpa, heiko.carstens, brueckner, tmricht, linux-kernel, mingo,
schwidefsky, tglx, acme
Commit-ID: 0b4b6b78a3ce07023052e44b967f5d42fa3d802c
Gitweb: https://git.kernel.org/tip/0b4b6b78a3ce07023052e44b967f5d42fa3d802c
Author: Thomas Richter <tmricht@linux.vnet.ibm.com>
AuthorDate: Thu, 8 Mar 2018 13:09:13 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 8 Mar 2018 11:30:53 -0300
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>
---
tools/perf/arch/s390/annotate/instructions.c | 63 ++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
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 = {
.scnprintf = call__scnprintf,
};
+static int s390_mov__parse(struct arch *arch __maybe_unused,
+ struct ins_operands *ops,
+ struct map *map __maybe_unused)
+{
+ char *s = strchr(ops->raw, ','), *target, *endptr;
+
+ if (s == NULL)
+ return -1;
+
+ *s = '\0';
+ ops->source.raw = strdup(ops->raw);
+ *s = ',';
+
+ if (ops->source.raw == NULL)
+ return -1;
+
+ target = ++s;
+ ops->target.raw = strdup(target);
+ if (ops->target.raw == NULL)
+ goto out_free_source;
+
+ ops->target.addr = strtoull(target, &endptr, 16);
+ if (endptr == target)
+ goto out_free_target;
+
+ s = strchr(endptr, '<');
+ if (s == NULL)
+ goto out_free_target;
+ endptr = strchr(s + 1, '>');
+ if (endptr == NULL)
+ goto out_free_target;
+
+ *endptr = '\0';
+ ops->target.name = strdup(s + 1);
+ *endptr = '>';
+ if (ops->target.name == NULL)
+ goto out_free_target;
+
+ return 0;
+
+out_free_target:
+ zfree(&ops->target.raw);
+out_free_source:
+ zfree(&ops->source.raw);
+ return -1;
+}
+
+static int mov__scnprintf(struct ins *ins, char *bf, size_t size,
+ struct ins_operands *ops);
+
+static struct ins_ops s390_mov_ops = {
+ .parse = s390_mov__parse,
+ .scnprintf = mov__scnprintf,
+};
+
static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *name)
{
struct ins_ops *ops = NULL;
@@ -68,6 +123,14 @@ static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char *na
ops = &s390_call_ops;
if (!strcmp(name, "br"))
ops = &ret_ops;
+ /* override load/store relative to PC */
+ if (!strcmp(name, "lrl") ||
+ !strcmp(name, "lgrl") ||
+ !strcmp(name, "lgfrl") ||
+ !strcmp(name, "llgfrl") ||
+ !strcmp(name, "strl") ||
+ !strcmp(name, "stgrl"))
+ ops = &s390_mov_ops;
if (ops)
arch__associate_ins_ops(arch, name, ops);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-09 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-08 12:09 [PATCH] perf annotate: Handle s390 pc relative load and store instruction Thomas Richter
2018-03-08 12:52 ` Arnaldo Carvalho de Melo
2018-03-09 8:58 ` [tip:perf/core] perf annotate: Handle s390 PC " tip-bot for Thomas Richter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).