Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751646AbdFGQCF (ORCPT ); Wed, 7 Jun 2017 12:02:05 -0400 Received: from terminus.zytor.com ([65.50.211.136]:38561 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbdFGQCE (ORCPT ); Wed, 7 Jun 2017 12:02:04 -0400 Date: Wed, 7 Jun 2017 08:57:08 -0700 From: tip-bot for Kim Phillips Message-ID: Cc: alexander.shishkin@linux.intel.com, ravi.bangoria@linux.vnet.ibm.com, hpa@zytor.com, acme@redhat.com, mingo@kernel.org, anton@samba.org, treeze.taeung@gmail.com, peterz@infradead.org, borntraeger@de.ibm.com, kim.phillips@arm.com, mark.rutland@arm.com, robin.murphy@arm.com, linux-kernel@vger.kernel.org, tglx@linutronix.de Reply-To: acme@redhat.com, mingo@kernel.org, anton@samba.org, hpa@zytor.com, peterz@infradead.org, treeze.taeung@gmail.com, alexander.shishkin@linux.intel.com, ravi.bangoria@linux.vnet.ibm.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, robin.murphy@arm.com, borntraeger@de.ibm.com, mark.rutland@arm.com, kim.phillips@arm.com In-Reply-To: <20170601092959.f60d98912e8a1b66fd1e4c0e@arm.com> References: <20170601092959.f60d98912e8a1b66fd1e4c0e@arm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf annotate: Fix branch instruction with multiple operands Git-Commit-ID: b13bbeee5ee606cfb57ddcf47e66802f9aa7273e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5223 Lines: 155 Commit-ID: b13bbeee5ee606cfb57ddcf47e66802f9aa7273e Gitweb: http://git.kernel.org/tip/b13bbeee5ee606cfb57ddcf47e66802f9aa7273e Author: Kim Phillips AuthorDate: Thu, 1 Jun 2017 09:29:59 -0500 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 1 Jun 2017 14:48:36 -0300 perf annotate: Fix branch instruction with multiple operands 'perf annotate' is dropping the cr* fields from branch instructions. Fix it by adding support to display branch instructions having multiple operands. Power Arch objdump of int_sqrt: 20.36 | c0000000004d2694: subf r10,r10,r3 | c0000000004d2698: v bgt cr6,c0000000004d26a0 1.82 | c0000000004d269c: mr r3,r10 29.18 | c0000000004d26a0: mr r10,r8 | c0000000004d26a4: v bgt cr7,c0000000004d26ac | c0000000004d26a8: mr r10,r7 Power Arch Before Patch: 20.36 | subf r10,r10,r3 | v bgt 40 1.82 | mr r3,r10 29.18 | 40: mr r10,r8 | v bgt 4c | mr r10,r7 Power Arch After patch: 20.36 | subf r10,r10,r3 | v bgt cr6,40 1.82 | mr r3,r10 29.18 | 40: mr r10,r8 | v bgt cr7,4c | mr r10,r7 Also support AArch64 conditional branch instructions, which can have up to three operands: Aarch64 Non-simplified (raw objdump) view: │ffff0000083cd11c: ↑ cbz w0, ffff0000083cd100 Tested-by: Ravi Bangoria Reported-by: Anton Blanchard Reported-by: Robin Murphy Signed-off-by: Kim Phillips Cc: Alexander Shishkin Cc: Christian Borntraeger Cc: Mark Rutland Cc: Peter Zijlstra Cc: Taeung Song Link: http://lkml.kernel.org/r/20170601092959.f60d98912e8a1b66fd1e4c0e@arm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 07d5608..1367d7e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -239,10 +239,20 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op const char *s = strchr(ops->raw, '+'); const char *c = strchr(ops->raw, ','); - if (c++ != NULL) + /* + * skip over possible up to 2 operands to get to address, e.g.: + * tbnz w0, #26, ffff0000083cd190 + */ + if (c++ != NULL) { ops->target.addr = strtoull(c, NULL, 16); - else + if (!ops->target.addr) { + c = strchr(c, ','); + if (c++ != NULL) + ops->target.addr = strtoull(c, NULL, 16); + } + } else { ops->target.addr = strtoull(ops->raw, NULL, 16); + } if (s++ != NULL) { ops->target.offset = strtoull(s, NULL, 16); @@ -257,10 +267,27 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op static int jump__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops) { + const char *c = strchr(ops->raw, ','); + if (!ops->target.addr || ops->target.offset < 0) return ins__raw_scnprintf(ins, bf, size, ops); - return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset); + if (c != NULL) { + const char *c2 = strchr(c + 1, ','); + + /* check for 3-op insn */ + if (c2 != NULL) + c = c2; + c++; + + /* mirror arch objdump's space-after-comma style */ + if (*c == ' ') + c++; + } + + return scnprintf(bf, size, "%-6.6s %.*s%" PRIx64, + ins->name, c ? c - ops->raw : 0, ops->raw, + ops->target.offset); } static struct ins_ops jump_ops = {