Message ID | 20231214123304.34087-2-tianruidong@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8507506dys; Thu, 14 Dec 2023 04:33:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1fCUi+8oAcLdLYpcP3GSy61ydb7FR5gI0y3AiSpyh2stYIVhLTViFARk6JWO+4y/nKHV5 X-Received: by 2002:aa7:8684:0:b0:6ce:725f:7da9 with SMTP id d4-20020aa78684000000b006ce725f7da9mr9513731pfo.59.1702557211457; Thu, 14 Dec 2023 04:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702557211; cv=none; d=google.com; s=arc-20160816; b=E+gF7nOlsqNmcMEd3nsKIrksKeKcuZqIf+wmEkl38JvxoGxDnWzcHyD9yK0uxJIiPv y9jKjs3z6rGpAwz/tyIfwPUPUNVZOYPfjnb/AqAhf2ZgBy+Q/nr3ky8ZtVi01F0y+YJN 592l8aqxjva7HTBktMnqmQR9zFrWSeu4nJuOMH6XSkJnm72dGucZOlkL5Hd4shMkZ3P+ GnpfB+RPexj0BGGE23+nxVbE4aVXwAVQdUcRo119pb2VbzOlwS+NcTky/2tILe09SA1m h+P5zE3JyBwqfenBBAZrU3uHyBpGUziSIK4Tz9SSOi3Y/tU8Z6/uQz5jn6sZ8CyuT+gS NMsg== 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; bh=u+93OwqEg2VyTZwXAen7lyK9wHD7pXSvR+PaxcLd/n8=; fh=2C1f0j/nzSygmX2ABc+8OQYD53hkUy28AVWbjAwc8E0=; b=uJMKk4VIlrBE/3l8mHUmSzgjsZKsPTZPTbd+pL4uGKBWbB2UQa/Z1opqnrRFuvwZ/0 esaIbNQyQC7Q6XF6mJ+CThEUfl72+SsJWCx5WrN9+J/goQh8xLm9TDv6pRIM9iDC6HsH 4LVDCndpPxwQ4n8AYlgq4NbVj+/C+74whYhNzGIc8GMF5PzpUHSWCdEWzCUpWIEff4hd ic+3lylczD6E1Y+ax20F1OevcxfNJyC6iwy5O6/utZJW/eJJG//n7ZgK1TmOEYE2x2Zv GZMogrB4+IfuY54f5oykgy1JUNDSV4mWO8ersjSVhyuNkKc81eo2Lv/1tp3i5Hejhd1r ZPTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id c15-20020a634e0f000000b005c6075f8a31si10961186pgb.153.2023.12.14.04.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 04:33:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id B6C5C822B2E9; Thu, 14 Dec 2023 04:33:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573068AbjLNMdP (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Thu, 14 Dec 2023 07:33:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573052AbjLNMdN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 14 Dec 2023 07:33:13 -0500 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D860120; Thu, 14 Dec 2023 04:33:19 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R441e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=tianruidong@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0VyUMJ.p_1702557194; Received: from localhost(mailfrom:tianruidong@linux.alibaba.com fp:SMTPD_---0VyUMJ.p_1702557194) by smtp.aliyun-inc.com; Thu, 14 Dec 2023 20:33:16 +0800 From: Ruidong Tian <tianruidong@linux.alibaba.com> To: linux-kernel@vger.kernel.org Cc: james.clark@arm.com, coresight@lists.linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, alexander.shishkin@linux.intel.com, linux-arm-kernel@lists.infradead.org, adrian.hunter@intel.com, linux-perf-users@vger.kernel.org, leo.yan@linaro.org, al.grant@arm.com, mathieu.poirier@linaro.org, tor@ti.com, acme@redhat.com, Ruidong Tian <tianruidong@linux.alibaba.com> Subject: [PATCH 1/3] perf scripts python: arm-cs-trace-disasm.py: print dso base address Date: Thu, 14 Dec 2023 20:33:02 +0800 Message-Id: <20231214123304.34087-2-tianruidong@linux.alibaba.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20231214123304.34087-1-tianruidong@linux.alibaba.com> References: <20231214123304.34087-1-tianruidong@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 14 Dec 2023 04:33:28 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785260630550490100 X-GMAIL-MSGID: 1785260630550490100 |
Series |
perf scripts python: arm-cs-trace-disasm.py:
|
|
Commit Message
Ruidong Tian
Dec. 14, 2023, 12:33 p.m. UTC
arm-cs-trace-disasm just print offset for library dso:
0000000000002200 <memcpy>:
2200: d503201f nop
2204: 8b020024 add x4, x1, x2
2208: 8b020005 add x5, x0, x2
This print DSO base address to get complete virtual address for
userspace application:
0000000000002200 <memcpy>: (base address is 0x0000ffffb4c21000)
2200: d503201f nop
2204: 8b020024 add x4, x1, x2
2208: 8b020005 add x5, x0, x2
Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com>
---
tools/perf/scripts/python/arm-cs-trace-disasm.py | 2 ++
1 file changed, 2 insertions(+)
Comments
On 14/12/2023 12:33, Ruidong Tian wrote: > arm-cs-trace-disasm just print offset for library dso: > > 0000000000002200 <memcpy>: > 2200: d503201f nop > 2204: 8b020024 add x4, x1, x2 > 2208: 8b020005 add x5, x0, x2 > > This print DSO base address to get complete virtual address for > userspace application: > > 0000000000002200 <memcpy>: (base address is 0x0000ffffb4c21000) > 2200: d503201f nop > 2204: 8b020024 add x4, x1, x2 > 2208: 8b020005 add x5, x0, x2 > I believe the output format without the base address is consistent with objdump. For compatibility I would say that it's better to keep it that way. We could add this as an option, but have it disabled by default. I suppose it depends how likely that someone is using this output in a tool and processing it further whether an option is needed or not. Although it's also not that clear what this is useful for, given that all the other output is relative too? Maybe you could add an example to the commit message, even if it's just for debugging. Would an option that turned _all_ the output into virtual addresses not be more useful? Thanks James > Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com> > --- > tools/perf/scripts/python/arm-cs-trace-disasm.py | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py > index d59ff53f1d94..46bf6b02eea1 100755 > --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py > +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py > @@ -108,6 +108,8 @@ def print_disam(dso_fname, dso_start, start_addr, stop_addr): > m = disasm_re.search(line) > if m is None: > continue > + else: > + line += " (base address is 0x%016x)" % dso_start > print("\t" + line) > > def print_sample(sample):
Hi James 在 2023/12/20 18:44, James Clark 写道: > > On 14/12/2023 12:33, Ruidong Tian wrote: >> arm-cs-trace-disasm just print offset for library dso: >> >> 0000000000002200 <memcpy>: >> 2200: d503201f nop >> 2204: 8b020024 add x4, x1, x2 >> 2208: 8b020005 add x5, x0, x2 >> >> This print DSO base address to get complete virtual address for >> userspace application: >> >> 0000000000002200 <memcpy>: (base address is 0x0000ffffb4c21000) >> 2200: d503201f nop >> 2204: 8b020024 add x4, x1, x2 >> 2208: 8b020005 add x5, x0, x2 >> > I believe the output format without the base address is consistent with > objdump. For compatibility I would say that it's better to keep it that way. Sure, the output is totally corrected, i just print the base address rather than modify the output address, i don't think this change is incompatible. > > We could add this as an option, but have it disabled by default. I > suppose it depends how likely that someone is using this output in a > tool and processing it further whether an option is needed or not. I want to get the runtime trace flow with virtual address, i can get the trace information with virtual address in `perf report` and `perf script` by default, so i think it is more reasonable to print virtual address in arm-cs-trace-disasm script by default. > > Although it's also not that clear what this is useful for, given that > all the other output is relative too? Maybe you could add an example to > the commit message, even if it's just for debugging. Would an option > that turned _all_ the output into virtual addresses not be more useful? I want to use arm-cs-trace-disasm.py output associate with PMU and SPE data to explore more CPU performance info, all the PMU/SPE/Coresight informations generated by `perf report` and `perf script` include virtual address, so i want this script do the same thing. > > Thanks > James > >> Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com> >> --- >> tools/perf/scripts/python/arm-cs-trace-disasm.py | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py >> index d59ff53f1d94..46bf6b02eea1 100755 >> --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py >> +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py >> @@ -108,6 +108,8 @@ def print_disam(dso_fname, dso_start, start_addr, stop_addr): >> m = disasm_re.search(line) >> if m is None: >> continue >> + else: >> + line += " (base address is 0x%016x)" % dso_start >> print("\t" + line) >> >> def print_sample(sample):
Hi Ruidong, On Fri, Dec 22, 2023 at 03:29:18PM +0800, Ruidong Tian wrote: [...] > > Although it's also not that clear what this is useful for, given that > > all the other output is relative too? Maybe you could add an example to > > the commit message, even if it's just for debugging. Would an option > > that turned _all_ the output into virtual addresses not be more useful? > > I want to use arm-cs-trace-disasm.py output associate with PMU and SPE data > to explore more CPU performance info, all the PMU/SPE/Coresight informations > generated by `perf report` and `perf script` include virtual address, so i > want this script do the same thing. I think James' suggestion is valid for replacing all offsets with virtual addresses, in addition to introducing a new option. Below change works well at my side. Hope this is helpful. diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py index de58991c78bb..6c94ff2287cd 100755 --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py @@ -36,7 +36,10 @@ option_list = [ help="Set path to objdump executable file"), make_option("-v", "--verbose", dest="verbose", action="store_true", default=False, - help="Enable debugging log") + help="Enable debugging log"), + make_option("-a", "--vaddr", dest="vaddr", + action="store_true", default=False, + help="Enable virtual address") ] parser = OptionParser(option_list=option_list) @@ -108,6 +111,14 @@ def print_disam(dso_fname, dso_start, start_addr, stop_addr): m = disasm_re.search(line) if m is None: continue + + # Replace offset with virtual address + if (options.vaddr == True): + offset = re.search(r"^\s*([0-9a-fA-F]+)", line).group() + if offset: + virt_addr = dso_start + int(offset, 16) + line = line.replace(offset.lstrip(), "0x%016x" % virt_addr) + print("\t" + line) def print_sample(sample): Thanks, Leo
diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py index d59ff53f1d94..46bf6b02eea1 100755 --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py @@ -108,6 +108,8 @@ def print_disam(dso_fname, dso_start, start_addr, stop_addr): m = disasm_re.search(line) if m is None: continue + else: + line += " (base address is 0x%016x)" % dso_start print("\t" + line) def print_sample(sample):