Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp194481rdb; Mon, 15 Jan 2024 18:09:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZMLwAiWPLbYPNf+7bn4mvVtFjIzNZSqEAQbvl1Wcxu5GVGGZzkmroGIaS7GDi+w+0dtbT X-Received: by 2002:ae9:ea01:0:b0:783:54bb:a66a with SMTP id f1-20020ae9ea01000000b0078354bba66amr3964200qkg.23.1705370959223; Mon, 15 Jan 2024 18:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705370959; cv=none; d=google.com; s=arc-20160816; b=imwJ/TLXSoO6rdUFJ8YxhdlpNR2BMiKPuF9Aeg5A87l2sbXJgcDQS/lq2EL6kIqNYM 7NhA8hMxG0w5wy91fyx8cPASIHoyVf5VG41XNvWaR8iUT2BWvZXdRH5DCLDbEQLgtIoY /0fzUJga9FZ5KnrPXgBwTX7QPVH3KnNnkC/LQbti46BUQhXyEeEs+vSaNG5FpVJWa7NM YSDz0rkXJPzortEQJ1gbMxuOd1Jt2YQMxs3MW2IgSm+NRXb1kEP4WmnC82T624rzEdcs ku5IyDC7tg0GP3ZjsckWjK5ewvhhL4aLpcGVj8BGZRnqHXJhnbfzmiePQ+G4eqKTnfOd Gh1Q== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26918-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f16-20020a37ad10000000b0078335c34bf0si8957317qkm.46.2024.01.15.18.09.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 18:09:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26918-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26918-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 006A11C22D2B for ; Tue, 16 Jan 2024 02:09:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3AE35611F; Tue, 16 Jan 2024 02:09:10 +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 Content-Transfer-Encoding: 8bit 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): -- 2.33.1