Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp70458imm; Wed, 5 Sep 2018 15:10:14 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdau9nH3dX5q7gjKYWUxIV+OdSk+RQSnehJx5erOd1/CZAZnmUeqYuI5WzBZvsZjU8jAi+H2 X-Received: by 2002:a62:9f4c:: with SMTP id g73-v6mr42771619pfe.142.1536185414280; Wed, 05 Sep 2018 15:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536185414; cv=none; d=google.com; s=arc-20160816; b=UUbSg1hH2GeMb4uhBgmNR9agQ2k+ZEyDb2fUPIY7eOsAV3dqAEZjkkCaIwWmov5S7S UngoUttRgsf2J7j2AMDJ1IFzn8u+CGcVU6WrvRcDGZHq6SfGMAO8UyDZd2FHjxMxt5+W MT2J+oeg94TYlNn1dNzJg5aafKxM20Kr7Hi98FRqdQkg8uIbxH8KOTfto51req6L31NN fX3wE1UrKPqAfH+haYqupvpxE8bgXwUtpRWI9RlqIb4cGnLYYKBRcwT+LeLSIi6Cve9g 8uw8quG0VS/OZDbCEjXJMme7Ggqye2z45Wak223+J40IBC5+FK2tBnVBFV86+7/m5ooH NnlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=d5GcgLX2ti+se+xvb77rev5jHNljy6qjgaY9TYfkHTA=; b=PHRycl+BEbnE1rhd6rZPQcNyN7gKqjVupDgR1b7oMsqJRMlOYmqvp6IixQeDU1+jsj +UAVCroBpmFZ4iRNGOLNBYFuDAfmW1vZBTl6nluQkSa8ZsFNAQgtejAtr7zBJEA22koE m0+KHNi17gVo2/kLJS3O2DpC59gjZ6gJeDqu8+lZQJPAdwAUwHtu2cOqTd6qETZ6Mw/Z cJTaHyQ8L73Gi/zXe20gfWHlVBQb0nqE/31lHc4qCgRJ4BGH1P57q1VQLZp5EKfBcysd 2rJ1VP9cOhC8s89a/gso2S0Nm/nFQJfub+Qjeg3AHORMXTFyWNJD7iOInTM2g8S7XIJW FcXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hsRyokz+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o66-v6si3388116pfb.125.2018.09.05.15.09.58; Wed, 05 Sep 2018 15:10:14 -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; dkim=pass header.i=@kernel.org header.s=default header.b=hsRyokz+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729055AbeIFCkW (ORCPT + 99 others); Wed, 5 Sep 2018 22:40:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:55390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727518AbeIFCkV (ORCPT ); Wed, 5 Sep 2018 22:40:21 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6633820861; Wed, 5 Sep 2018 22:08:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536185288; bh=C9N1K5i24gMuvKBqPj/mVPJrM7e29i2OZjXeajHcOQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hsRyokz+zC0lTV0UG/FNokyuv50q80afBSIJQ8GOg0Pmlf2vEw+b22r/htCP/PPo2 tPYpVXAXUKM/GgogPOpWnp5bnoqMI9o/6Pa62NVtIzuDhxTevKOk4D2oV4L3XaAgi9 246N9KmbxFmKkjIc03BksBnRWKhz63q6g4i6woSs= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Kim Phillips , Alexander Shishkin , Greg Kroah-Hartman , Hendrik Brueckner , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 70/77] perf annotate: Handle arm64 move instructions Date: Wed, 5 Sep 2018 19:04:33 -0300 Message-Id: <20180905220440.20256-71-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180905220440.20256-1-acme@kernel.org> References: <20180905220440.20256-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kim Phillips Add default handler for non-jump instructions. This really only has an effect on instructions that compute a PC-relative address, such as 'adrp,' as seen in these couple of examples: BEFORE: adrp x0, ffff20000aa11000 AFTER: adrp x0, kallsyms_token_index+0xce000 BEFORE: adrp x23, ffff20000ae94000 <__per_cpu_load> AFTER: adrp x23, __per_cpu_load The implementation is identical to that of s390, but with a slight adjustment for objdump whitespace propagation (arm64 objdump puts spaces after commas, whereas s390's presumably doesn't). The mov__scnprintf() declaration is moved from s390's to arm64's instructions.c because arm64's gets included before s390's. Committer testing: Ran 'perf annotate --stdio2 > /tmp/{before,after}' no diff. Signed-off-by: Kim Phillips Tested-by: Arnaldo Carvalho de Melo Tested-by: Thomas Richter Cc: Alexander Shishkin Cc: Greg Kroah-Hartman Cc: Hendrik Brueckner Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20180827150807.304110d2e9919a17c832ca48@arm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm64/annotate/instructions.c | 59 ++++++++++++++++++++++++++- tools/perf/arch/s390/annotate/instructions.c | 2 - 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arch/arm64/annotate/instructions.c index 6688977e4ac7..76c6345a57d5 100644 --- a/tools/perf/arch/arm64/annotate/instructions.c +++ b/tools/perf/arch/arm64/annotate/instructions.c @@ -8,6 +8,63 @@ struct arm64_annotate { jump_insn; }; +static int arm64_mov__parse(struct arch *arch __maybe_unused, + struct ins_operands *ops, + struct map_symbol *ms __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'; + *s = ' '; + ops->target.name = strdup(s); + *s = '<'; + *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 arm64_mov_ops = { + .parse = arm64_mov__parse, + .scnprintf = mov__scnprintf, +}; + static struct ins_ops *arm64__associate_instruction_ops(struct arch *arch, const char *name) { struct arm64_annotate *arm = arch->priv; @@ -21,7 +78,7 @@ static struct ins_ops *arm64__associate_instruction_ops(struct arch *arch, const else if (!strcmp(name, "ret")) ops = &ret_ops; else - return NULL; + ops = &arm64_mov_ops; arch__associate_ins_ops(arch, name, ops); return ops; diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c index cee4e2f7c057..de0dd66dbb48 100644 --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c @@ -100,8 +100,6 @@ static int s390_mov__parse(struct arch *arch __maybe_unused, 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, -- 2.14.4