From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org, Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 2/3] perf annotate: Parse x86 SIB addressing properly
Date: Wed, 10 May 2023 23:27:24 -0700 [thread overview]
Message-ID: <20230511062725.514752-2-namhyung@kernel.org> (raw)
In-Reply-To: <20230511062725.514752-1-namhyung@kernel.org>
When the source argument of mov instruction is look like below, it didn't
parse the whole operand and just stopped at the first comma.
mov (%rbx,%rax,1),%rcx
Fix it by checking the parentheses and move it to the closing one.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/util/annotate.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index ca9f0add68f4..6053ddf9c32d 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -550,6 +550,19 @@ static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_sy
return -1;
*s = '\0';
+
+ /*
+ * x86 SIB addressing has something like 0x8(%rax, %rcx, 1)
+ * then it needs to have the closing parenthesis.
+ */
+ if (strchr(ops->raw, '(')) {
+ *s = ',';
+ s = strchr(ops->raw, ')');
+ if (s == NULL || s[1] != ',')
+ return -1;
+ *++s = '\0';
+ }
+
ops->source.raw = strdup(ops->raw);
*s = ',';
--
2.40.1.521.gf1e218fcd8-goog
next prev parent reply other threads:[~2023-05-11 6:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-11 6:27 [PATCH 1/3] perf annotate: Handle more instructions on x86 Namhyung Kim
2023-05-11 6:27 ` Namhyung Kim [this message]
2023-05-15 17:08 ` [PATCH 2/3] perf annotate: Parse x86 SIB addressing properly Ian Rogers
2023-05-11 6:27 ` [PATCH 3/3] perf annotate browser: Add '<' and '>' keys for navigation Namhyung Kim
2023-05-15 17:09 ` Ian Rogers
2023-05-15 20:54 ` Arnaldo Carvalho de Melo
2023-05-15 20:55 ` Arnaldo Carvalho de Melo
2023-05-15 17:08 ` [PATCH 1/3] perf annotate: Handle more instructions on x86 Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230511062725.514752-2-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox