Message ID | 20230511062725.514752-2-namhyung@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4161291vqo; Wed, 10 May 2023 23:54:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4arNFm52s9V9GBaaKBcfXH2VfLInfYA+wsEtY+1E3S/mF0p0TcV4cjAu3zgPVvAvRUkQm+ X-Received: by 2002:a05:6a21:789c:b0:100:607:b986 with SMTP id bf28-20020a056a21789c00b001000607b986mr18314408pzc.56.1683788059993; Wed, 10 May 2023 23:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683788059; cv=none; d=google.com; s=arc-20160816; b=kH7tg5eGrGHsm6vGl/uJXPWyeIbIE996ydCiutDvweVPu19pEYqHBHQhYHbZnw39Mf QCJcLSTJ9RDCOzf0bWGo6x60CeotDdpiC1hwW54EXSJfnaRs7ZulDIDLNS7pvdLBHDyH yYo4KPHr8wjJAEiNtRerz2ygz09qo3cuYkjFxhfuS2Zw9JjcEhcIcjvFR0YZRxtW79OV wQtAds5dG4ZNSW3U4hhx9O/DdXc3IK3ixP+jgnSq8ScI1Re0yX5QDTYwrSRCQhfXoJZ4 Xl7AokUob7SYHuB/ZonkN8gMdJCXTd8kQmpGMBU/C1eCbCqjU13bF4GUFITxfPkQk7UU 821A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=BUM/womBq8zG0iIiWwWTRkqn2H+jvaSWOmmttRj5uZA=; b=UxLW7r2UR88kA0P5+JPEFxSyvD8ws8ZKm510R1hDBffgXkdt18STuhpRoVcHplGw7m wZnmJK1j8/Jd9SR9Yl74v4i8/KErkWNmNmXnZUwJNrhPzrmEnl3q6VvWNoQcyvlehSyr gTG2GLa9fvTfmPIcdwS1NH3O9+8kTxIl5UZVKZGIQE1pDaJLjwX0N/t3Z20Lvd9HMzx+ mbm3IFBMcXTbWzwadSiIBWrDfXDwHsq1CkXi5i7RzXQigPr+mxGn7orRVQHR/nQI6jKb DVtqlJHeS+5KSyRuQjlyjE713Lkkjqco7AmESo5UXEmmxJyCfEpfaAD0jJEsfTHJXQGU cDCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="QVkS6/mf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x186-20020a6386c3000000b00528c6c2ea96si6312173pgd.306.2023.05.10.23.54.07; Wed, 10 May 2023 23:54:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="QVkS6/mf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232984AbjEKG1f (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Thu, 11 May 2023 02:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236751AbjEKG1a (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 11 May 2023 02:27:30 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFDF9103; Wed, 10 May 2023 23:27:29 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-51b0f9d7d70so7437391a12.1; Wed, 10 May 2023 23:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683786449; x=1686378449; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=BUM/womBq8zG0iIiWwWTRkqn2H+jvaSWOmmttRj5uZA=; b=QVkS6/mfk8fj+fZi8lFlKmIk8nPgYKzj4H1gYEY24Nc0TMmQJ0SNvHM5yPrbqOQfez S509jegR0jRiPSkb5q6EpjrQlc8BZmq7/uzRWMURB2sUOb1B8W4qCx+YeGhIG1+tyZ+Y JZ7MVI2Qr8dpfFvczODEDR2pZIDgJt/L3nZjlWihYI6ZgCxTgYVPgoMMohmAHoJm0YHJ csf6IDnjecRXuoahJO/J6TXkhlBSpNbw9Eyoa0eg4f2eWrvwbzODuMFxbOJssWCkY2pB 6IRD/wZz56p9HWtMibiYOzR75HJk+YcZqX0lj6dghNkh4YUkCOo796cgbFz7HhsEA3lV T+eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683786449; x=1686378449; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BUM/womBq8zG0iIiWwWTRkqn2H+jvaSWOmmttRj5uZA=; b=SZUYzB1Va2cyi6Or0mPerN1HICTU28wF4KDSHnkx+Z+J+GalLfEWwzGXbGTYa7GqNj aQTbMEfZAfH0+S3U6Z4fFeF497l70SNN4rQJNRc7eHkXW5RngQH8ZWHSws15YwjTPLk5 eNSf1Yh/mQy8+xPpnpD51bgxToiyySdLes7kv4h+gy29KLzdGHkB3FmhvwZ7rA7IOoYp XzyOeBSwskGc9DBvTjKMX4Q122jk2kQ9dAEZTm84NsnjIdiWWFJWTwHn0MPjHa4jKXbr yZ4FPlEh8PAkG3Y+WUFgvbpjOmS9uNeX6Vpa59brbOHDhT/MV2guovSDi2kFJY4HgW3j NUOA== X-Gm-Message-State: AC+VfDwoV5bvfp34JGbu1EgpSdyjynNcCM65pfSBWTOdf/7DwQed+824 B3YsMY/mG5CH2kmq8AonsX0= X-Received: by 2002:a17:902:b68d:b0:1ac:7405:d3ba with SMTP id c13-20020a170902b68d00b001ac7405d3bamr13535688pls.40.1683786449496; Wed, 10 May 2023 23:27:29 -0700 (PDT) Received: from bangji.hsd1.ca.comcast.net ([2601:647:6700:7f00:c18c:3210:36c3:c88c]) by smtp.gmail.com with ESMTPSA id jj17-20020a170903049100b001ac2be2639asm4925683plb.223.2023.05.10.23.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 23:27:29 -0700 (PDT) Sender: Namhyung Kim <namhyung@gmail.com> 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 Message-ID: <20230511062725.514752-2-namhyung@kernel.org> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog In-Reply-To: <20230511062725.514752-1-namhyung@kernel.org> References: <20230511062725.514752-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765579748919658429?= X-GMAIL-MSGID: =?utf-8?q?1765579748919658429?= |
Series |
[1/3] perf annotate: Handle more instructions on x86
|
|
Commit Message
Namhyung Kim
May 11, 2023, 6:27 a.m. UTC
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(+)
Comments
On Wed, May 10, 2023 at 11:27 PM Namhyung Kim <namhyung@kernel.org> wrote: > > 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> Acked-by: Ian Rogers <irogers@google.com> Thanks, Ian > --- > 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 >
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 = ',';