From patchwork Tue Jan 16 02:08:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruidong Tian X-Patchwork-Id: 188359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp3344dye; Mon, 15 Jan 2024 18:10:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHI0ziIkyjzqx3YXw3lIB7dxiu0/to+23sgWRIhP0emZ89yu6QPw75v8v4Q34tC8ILt1J6O X-Received: by 2002:a05:6871:d30c:b0:204:c0:5db3 with SMTP id pn12-20020a056871d30c00b0020400c05db3mr8748720oac.13.1705371004403; Mon, 15 Jan 2024 18:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705371004; cv=none; d=google.com; s=arc-20160816; b=a80uH3Lez6Sa9FkP8MDxzjWOx+7SHhB9T+KofrRwLkPa8WJuNvH1SL2/TQ+lJKPKg+ NWX4K1eOoq/TuaNQEGyXVnzvUym9jRu3nk2jj0Q7wN4dSGoLrJyGb5mCURWGbgoFktNa VJXwAiMDSn16KhSQp2UZWRcp76ywhTZnxM7o11QFo/Jcwlfcxwt4CgqW13+dZWTjEiG3 I2dEur5ulzuIpyPYJ/4NuuZk0D05gy6roLqQHnMGWhlGoAm/wJqNPv1qGkCcvv7cdbEv 0YVZA1dIc1UggKuEZE5SdxRzgP1MzUv1QJAZEouHpgv9EiSWpcPcvFJpOQswpWjC548i qG5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=xao0+mPIwaNfpi+yhBiPFNZ9goo+q0XhQTtfl6hiPEI=; fh=2C1f0j/nzSygmX2ABc+8OQYD53hkUy28AVWbjAwc8E0=; b=lfAIBd4DCKYqvoB60lz/ZeKz2IBeZIhxVO4VmbWSDiXJU9VZAGMxYmwKuVYXe/C238 Am1YpQdWs3hFHmKk9HEcYmv3P8O+3Hf/a1ALa65Y/n4YFXA3tFxldyHqC7Pid2HMB69e nL/fBCgkIViEX4kpqw7cNevPq6QEPKyCi2IkOhbUP/psH61IoypXW44OcD0BhWMqv7kD VFw9DJzW2LkkTZIRGn1AZ4iQePx03lqSlwmXbLD0GcguuZwCgZDqYGEzND7DBwhMPYA3 X05pB/eo7MA6hDd73McKDFqAaVdmRAKMqIIjSnAKzsIcQUAyU5nl/8NqeLUIBKH4MQge Q8KA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26918-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26918-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a22-20020a656416000000b005cdfa102332si9866677pgv.601.2024.01.15.18.10.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 18:10:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26918-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26918-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26918-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7C0A1B227C4 for ; Tue, 16 Jan 2024 02:09:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 498DB79C7; Tue, 16 Jan 2024 02:09:11 +0000 (UTC) Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8C4228F6; Tue, 16 Jan 2024 02:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=tianruidong@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0W-kJsPU_1705370940; Received: from localhost(mailfrom:tianruidong@linux.alibaba.com fp:SMTPD_---0W-kJsPU_1705370940) by smtp.aliyun-inc.com; Tue, 16 Jan 2024 10:09:02 +0800 From: Ruidong Tian 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 Subject: [PATCH v3 1/1] perf scripts python: arm-cs-trace-disasm.py: add option to print virtual address Date: Tue, 16 Jan 2024 10:08:52 +0800 Message-Id: <20240116020854.56030-2-tianruidong@linux.alibaba.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20240116020854.56030-1-tianruidong@linux.alibaba.com> References: <20231214123304.34087-1-tianruidong@linux.alibaba.com> <20240116020854.56030-1-tianruidong@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787670497978946028 X-GMAIL-MSGID: 1788211106320534327 arm-cs-trace-disasm just print offset for library dso now: 0000000000002200 : 2200: d503201f nop 2204: 8b020024 add x4, x1, x2 2208: 8b020005 add x5, x0, x2 Add a option `-a` to print virtual offset other than offset: # perf script -s scripts/python/arm-cs-trace-disasm.py -- -d llvm-objdump -a ... ffffb4c23200 : ffffb4c23200: d503201f nop ffffb4c23204: 8b020024 add x4, x1, x2 ffffb4c23208: 8b020005 add x5, x0, x2 ... Signed-off-by: Ruidong Tian Reviewed-by: Leo Yan --- tools/perf/scripts/python/arm-cs-trace-disasm.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py index d973c2baed1c..78419498237e 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(), "%x" % virt_addr) + print("\t" + line) def print_sample(sample): From patchwork Tue Jan 16 02:08:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruidong Tian X-Patchwork-Id: 188360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp3361dye; Mon, 15 Jan 2024 18:10:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3ydrfi7aiugAYYHpFnet4rv/CT0yEA7jngswF0NOl5nxOFZsTrVwiF7BmuBpqyVT1DfdJ X-Received: by 2002:a17:902:cec2:b0:1d5:4c65:6f67 with SMTP id d2-20020a170902cec200b001d54c656f67mr8691511plg.111.1705371006517; Mon, 15 Jan 2024 18:10:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705371006; cv=none; d=google.com; s=arc-20160816; b=jaZcJpjCsXmAvoUmoAI1y2kawn64YOWYb7EEtf0IV0GrpAH80zPhJwAFzg9zeka6pX /37rEzqP4VRVJafq892ku82tj/b17VkfohZXvCsU+8NYkA3vUSTTXW1dU22WGZ4XTIQa EuAsaIt0ODTZoRO7apU3yqzMXBpTbmW4NCnv7vISmDIpFIly7Em3Nk7XGtB104/KEsY+ nas3tkZUxQvF86P1JwagownnQNDbC5ii6n+62was4Z9mLo/PzPel7lRlE20o3UUbYTuq H+Dst4iU9CGRfjOe4qVIvTL4Gu+OSBcIsCAFIADSZjOcN7BQsAj72ExT8AolRVItUbGW irrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=m3mUXWMvE1CbiBSf6/fyaZFBnvN1JIgT1dnBWraAosw=; fh=2C1f0j/nzSygmX2ABc+8OQYD53hkUy28AVWbjAwc8E0=; b=J0k8I+dF/+y+WQBnlxpA1g8+KOIKMv0aLiwdfyNB/+mEaG8p10B3OLp0vpizf4Pfub 72eL7xPzPKS8s7zR5OnwsfXpvSjT/Q6KHVlllZwBtrMLobrsPLoZJbbzakolhRQaUTMp /0PHOR359lzwCUfFI58S5Mepvzp6ZJl1tZ4yX9x3u3Zl2k5UViS0l8SUDo/gCg61ANza Cdms8tsXC41KBxoeTc++c2m4U5OoCpm0dMjpUBWBYjP/hRIk6ip/dFIcjVD1DuPTLUvE QzYJxisB9nIgnEdWDkJApU1kODkfQA2aky5lHtsZYvTXlmUNiZnDsOVaI1HjPwg9LfKQ W0oQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26920-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26920-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id kq11-20020a170903284b00b001d48a73f1fdsi9546441plb.163.2024.01.15.18.10.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 18:10:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26920-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26920-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26920-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 540B628413D for ; Tue, 16 Jan 2024 02:10:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01526CA7C; Tue, 16 Jan 2024 02:09:14 +0000 (UTC) Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B1F7613C; Tue, 16 Jan 2024 02:09:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R401e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=tianruidong@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0W-kLked_1705370944; Received: from localhost(mailfrom:tianruidong@linux.alibaba.com fp:SMTPD_---0W-kLked_1705370944) by smtp.aliyun-inc.com; Tue, 16 Jan 2024 10:09:06 +0800 From: Ruidong Tian 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 Subject: [PATCH v3 2/3] perf scripts python: arm-cs-trace-disasm.py: set start vm addr of exectable file to 0 Date: Tue, 16 Jan 2024 10:08:53 +0800 Message-Id: <20240116020854.56030-3-tianruidong@linux.alibaba.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20240116020854.56030-1-tianruidong@linux.alibaba.com> References: <20231214123304.34087-1-tianruidong@linux.alibaba.com> <20240116020854.56030-1-tianruidong@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785260635545762572 X-GMAIL-MSGID: 1788211108639205451 For exectable ELF file, which e_type is ET_EXEC, dso start address is a absolute address other than offset. Just set vm_start to zero when dso start is 0x400000, which means it is a exectable file. Signed-off-by: Ruidong Tian --- tools/perf/scripts/python/arm-cs-trace-disasm.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py index 46bf6b02eea1..c9e14af5b58c 100755 --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py @@ -260,8 +260,9 @@ def process_event(param_dict): if (options.objdump_name != None): # It doesn't need to decrease virtual memory offset for disassembly - # for kernel dso, so in this case we set vm_start to zero. - if (dso == "[kernel.kallsyms]"): + # for kernel dso and executable file dso, so in this case we set + # vm_start to zero. + if (dso == "[kernel.kallsyms]" or dso_start == 0x400000): dso_vm_start = 0 else: dso_vm_start = int(dso_start)