Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2236102imm; Thu, 23 Aug 2018 17:12:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzkAMt5DWHZ24WODhPcY2zMdFu9pPpgPGgmR/N/+A0h0K/Sxob+c7QXoLv+tDrffFRzHdB1 X-Received: by 2002:a62:63c2:: with SMTP id x185-v6mr64269839pfb.13.1535069552940; Thu, 23 Aug 2018 17:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535069552; cv=none; d=google.com; s=arc-20160816; b=o0D7UbsuhmXAxuH4CWNeY3Rmbuirer1QjOKK1zKL2BgkKv7tyfcdMZ+eOJYZmO1O0/ wuUolSA8oAg9U3c+uNU2O+QVrieT1GfyX+R1oSDRrfmWxAhP4Zr5YdxkSmyMOKMpvkhu wwiDxs6LHEFzNRSvW6tpxFof/jYBXQ0k+5YqP+2j4JP1mWgeyDQKxd7T26hrgO9kWun6 81v6ftoS3dLzwPolQ+zIco5Wg2Xu3ea8lqepiMPstwH2FVRYCexdB7JPQ5x2n523g/+X gBa9Hx04XV8wVgHu8KMBtAeEGHhAlXmeWbMKt2Iw6nrXXe65H0MIY/jyjON5YTdNNShk zATQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:message-id:subject:cc:to:from:date :arc-authentication-results; bh=ObYvS6BFZ1l0UmJllPfo9wy0M4ZJX3S0G24D+TzyR/s=; b=oh77PIagB8o8yh+kdmbuxq2AQeaKQ+20lS4iV+rKLOvwbywZao0NUOgHjcFPZ3eBWq xFPNwRd53VrGIJ4ys1b0jb/Wznpn4ySOtdXlQYBG1ybliqeVl/OwrKoKUBHGH4F3P398 GeV+iqt9YsKprPK6qTTAg34qdzAAjqcLoaEGhJRbbCDIMVrbIHcz7BTWn6JVwSFlBlYX CBilHHMUyqyat076aKuil6Yd9++BCwwbGPTwLntJ2+HogtE/B62aV/YdTlp6d6bTT9Ar P5jKsHXiu7txdIksuPJG9y7QAR01DqnJrENlMPIAjb75f4u6I6xOW/yxquDXZPIg9vOm ZyXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b28-v6si5700505pfe.265.2018.08.23.17.12.17; Thu, 23 Aug 2018 17:12:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727223AbeHXDmx (ORCPT + 99 others); Thu, 23 Aug 2018 23:42:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:52202 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbeHXDmw (ORCPT ); Thu, 23 Aug 2018 23:42:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7715C7A9; Thu, 23 Aug 2018 17:10:48 -0700 (PDT) Received: from dupont (dupont.austin.arm.com [10.118.16.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C331C3F2EA; Thu, 23 Aug 2018 17:10:47 -0700 (PDT) Date: Thu, 23 Aug 2018 19:10:47 -0500 From: Kim Phillips To: Arnaldo Carvalho de Melo Cc: Ravi Bangoria , Anton Blanchard , Robin Murphy , Alexander Shishkin , Christian Borntraeger , Mark Rutland , Peter Zijlstra , Taeung Song , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, perf group Subject: [PATCH] perf annotate: fix parsing aarch64 branch instructions after objdump update Message-Id: <20180823191047.9260992844205984b75e6721@arm.com> Organization: Arm X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Starting with binutils 2.28, aarch64 objdump adds comments to the disassembly output to show the alternative names of a condition code [1]. It is assumed that commas in objdump comments could occur in other arches now or in the future, so this fix is arch-independent. The fix could have been done with arm64 specific jump__parse and jump__scnprintf functions, but the jump__scnprintf instruction would have to have its comment character be a literal, since the scnprintf functions cannot receive a struct arch easily. This inconvenience also applies to the generic jump__scnprintf, which is why we add a raw_comment pointer to struct ins_operands, so the __parse function assigns it to be re-used by its corresponding __scnprintf function. Example differences in 'perf annotate --stdio2' output on an aarch64 perf.data file: BEFORE: → b.cs ffff200008133d1c // b.hs, dffff7ecc47b AFTER : ↓ b.cs 18c BEFORE: → b.cc ffff200008d8d9cc // b.lo, b.ul, dffff727295b AFTER : ↓ b.cc 31c The branch target labels 18c and 31c also now appear in the output: BEFORE: add x26, x29, #0x80 AFTER : 18c: add x26, x29, #0x80 BEFORE: add x21, x21, #0x8 AFTER : 31c: add x21, x21, #0x8 The Fixes: tag below is added so stable branches will get the update; it doesn't necessarily mean that commit was broken at the time, rather it didn't withstand the aarch64 objdump update. Tested no difference in output for sample x86_64, power arch perf.data files. [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=bb7eff5206e4795ac79c177a80fe9f4630aaf730 Cc: Ravi Bangoria Cc: Anton Blanchard Cc: Robin Murphy Cc: Alexander Shishkin Cc: Christian Borntraeger Cc: Mark Rutland Cc: Peter Zijlstra Cc: Taeung Song Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Fixes: b13bbeee5ee6 ("perf annotate: Fix branch instruction with multiple operands") Signed-off-by: Kim Phillips --- tools/perf/util/annotate.c | 17 ++++++++++++++++- tools/perf/util/annotate.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e32ead4744bd..b83897dafbb0 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -282,7 +282,8 @@ bool ins__is_call(const struct ins *ins) 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_symbol *ms) +static int jump__parse(struct arch *arch, struct ins_operands *ops, + struct map_symbol *ms) { struct map *map = ms->map; struct symbol *sym = ms->sym; @@ -291,6 +292,15 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op }; const char *c = strchr(ops->raw, ','); u64 start, end; + + /* + * Prevent from matching commas in the comment section, e.g.: + * ffff200008446e70: b.cs ffff2000084470f4 // b.hs, b.nlast + */ + ops->raw_comment = strchr(ops->raw, arch->objdump.comment_char); + if (c && ops->raw_comment && c > ops->raw_comment) + c = NULL; + /* * Examples of lines to parse for the _cpp_lex_token@@Base * function: @@ -367,6 +377,11 @@ static int jump__scnprintf(struct ins *ins, char *bf, size_t size, return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.sym->name); c = strchr(ops->raw, ','); + + /* Prevent from matching commas in the comment section */ + if (ops->raw_comment && c && c > ops->raw_comment) + c = NULL; + if (c != NULL) { const char *c2 = strchr(c + 1, ','); diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 005a5fe8a8c6..5399ba2321bb 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -22,6 +22,7 @@ struct ins { struct ins_operands { char *raw; + char *raw_comment; struct { char *raw; char *name; -- 2.17.1