From patchwork Thu Sep 12 15:11:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13802302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 73D7EEED615 for ; Thu, 12 Sep 2024 15:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tvd47gfary40B5CZwKU25bQw1FRFKdvBGhXDTC0MpmU=; b=h0WZ/aTLtgw4aAQUWtwQpp4fC3 CmbD21P8r123YP7BVLJmMibVzERXG9I2n+CnCLhC9AQYbsjMHbnqZXqUmMEUiGX90kuQbD2wYIG31 aNR+5Lq/hb0bUQz43XqQI8p2nIdXgenVprYTaL41As0B0xqcXr4+/LyiGlwCkIXXyRSEhH6oHdJib QEMpDStQz+VDQxakhn0ZTCxpORTCfWUr37gFQBfWzdET9f/kJeJh0pXuW8nJ5ZybIt4jsdNVLI3wd bL4b96rd9o0uW2/2NC7X5QyVb+c1kK+i+N7lWiSDw1xID5jmyrVjfdWnEol//Yg1c+p8SFCYE/QS3 cDI7jwmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1solg2-0000000DXpR-3gAH; Thu, 12 Sep 2024 15:24:10 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1solV4-0000000DVBe-3FeT for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2024 15:12:53 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42cba8340beso13713185e9.1 for ; Thu, 12 Sep 2024 08:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726153969; x=1726758769; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tvd47gfary40B5CZwKU25bQw1FRFKdvBGhXDTC0MpmU=; b=cCjiLlcU1lUh7QYOavgGhblH5fQPteQK6BQbu+075KweHFtmHjcEsjZfnEDESDbR9D q7idBskb7/BbLfiU+39Wz8fA+iEi1rQr/x0Lsq1eXQ/h9JPGtyluz4SQ1Om2p0jOYrph r/6EP3JWx6krgP49wCxA0EZcgWpgdjONeScAJoelBCRTxh1Lycb3uU2m8jANJoip3rMf /wodfNjOPgYHkI0UMgwuyYS9pmgWoip8HwADrxd+jH81ogSGT9T3+QgUGVx5A8K7jpgz VjJRkR+oud8LvcCl/fqck31j2Qc3dskdlfeZMvZMfpHyVfigU3Swq4429D9Sd+M+zcah cRjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726153969; x=1726758769; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tvd47gfary40B5CZwKU25bQw1FRFKdvBGhXDTC0MpmU=; b=Fg3+lRt7n4d9mwvY8G43vYgZnLVqMuDWlZ2TEvbv0ue72Fmn4ywgZzQ1melJMu34Q4 t8WxUKLLddqjNP6vF0lOep2VuHOVIL0iAC8kYoz4rmjnMwn8XFs3rcmdPrHkLG+aT+qu gZvod51BXT0OZ4Oh065qCn2HzlJy6x67/DHPt/j9kOUPq+Dx/s0iH050CeCWdnEYyEwR t9+nedrSf/Q9gATBXaPZMj+QPGPklex1lWAN8YOd2d80HP4p1grikv+lEHAxMZbwzLZp 463DKHEVEiTFAjZJ2wVFUw6u3jMyLIndtaGF9vkc0qupK0qvcl5ajPiGcmADVD5S+kGp mruw== X-Forwarded-Encrypted: i=1; AJvYcCWT34lIwsKeLAAr+8NTzkk01aUTm2sz5MTt5znXNUmp81qFZmvgIn2BDWm0r7rV7Z4MRtEguANdLQ4IuVk8tN/5@lists.infradead.org X-Gm-Message-State: AOJu0YwfrmkG63AmWR7WhxHEmEED/NDNjkeOAGr1dcr/Rh+Ht9lB7Ykt QM5dNK9g2VWLjZt6FEkwdWz+txCIN3eR/TFHA2DPxjVMYCyWw68dcpo5nvxF12s= X-Google-Smtp-Source: AGHT+IGXc5ywzLhmjTHKXlNIwnMTOMLrdQHiAdNlmIcNXtaF4leLAP0V2tpbvYPIKGpqX0pwKDC7nw== X-Received: by 2002:a05:600c:3516:b0:42c:b7ae:4c97 with SMTP id 5b1f17b1804b1-42cbde1a867mr66142135e9.11.1726153968510; Thu, 12 Sep 2024 08:12:48 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cb0dbcb6bsm171928845e9.30.2024.09.12.08.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 08:12:48 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, gankulkarni@os.amperecomputing.com, coresight@lists.linaro.org, leo.yan@arm.com, scclevenger@os.amperecomputing.com Cc: James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , Suzuki K Poulose , Mike Leach , John Garry , Will Deacon , Leo Yan , Ben Gainey , Ruidong Tian , Benjamin Gray , Mathieu Poirier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 4/7] perf scripts python cs-etm: Update to use argparse Date: Thu, 12 Sep 2024 16:11:35 +0100 Message-Id: <20240912151143.1264483-5-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240912151143.1264483-1-james.clark@linaro.org> References: <20240912151143.1264483-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240912_081250_925638_37D01CA9 X-CRM114-Status: GOOD ( 15.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org optparse is deprecated and less flexible than argparse so update it. Signed-off-by: James Clark Reviewed-by: Leo Yan --- .../scripts/python/arm-cs-trace-disasm.py | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py index 7aff02d84ffb..45f682a8b34d 100755 --- a/tools/perf/scripts/python/arm-cs-trace-disasm.py +++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py @@ -11,7 +11,7 @@ import os from os import path import re from subprocess import * -from optparse import OptionParser, make_option +import argparse from perf_trace_context import perf_set_itrace_options, \ perf_sample_insn, perf_sample_srccode @@ -28,19 +28,11 @@ from perf_trace_context import perf_set_itrace_options, \ # perf script -s scripts/python/arm-cs-trace-disasm.py # Command line parsing. -option_list = [ - # formatting options for the bottom entry of the stack - make_option("-k", "--vmlinux", dest="vmlinux_name", - help="Set path to vmlinux file"), - make_option("-d", "--objdump", dest="objdump_name", - help="Set path to objdump executable file"), - make_option("-v", "--verbose", dest="verbose", - action="store_true", default=False, - help="Enable debugging log") -] - -parser = OptionParser(option_list=option_list) -(options, args) = parser.parse_args() +args = argparse.ArgumentParser() +args.add_argument("-k", "--vmlinux", help="Set path to vmlinux file") +args.add_argument("-d", "--objdump", help="Set path to objdump executable file"), +args.add_argument("-v", "--verbose", action="store_true", help="Enable debugging log") +options = args.parse_args() # Initialize global dicts and regular expression disasm_cache = dict() @@ -65,8 +57,8 @@ def get_offset(perf_dict, field): def get_dso_file_path(dso_name, dso_build_id): if (dso_name == "[kernel.kallsyms]" or dso_name == "vmlinux"): - if (options.vmlinux_name): - return options.vmlinux_name; + if (options.vmlinux): + return options.vmlinux; else: return dso_name @@ -92,7 +84,7 @@ def read_disam(dso_fname, dso_start, start_addr, stop_addr): else: start_addr = start_addr - dso_start; stop_addr = stop_addr - dso_start; - disasm = [ options.objdump_name, "-d", "-z", + disasm = [ options.objdump, "-d", "-z", "--start-address="+format(start_addr,"#x"), "--stop-address="+format(stop_addr,"#x") ] disasm += [ dso_fname ] @@ -256,7 +248,7 @@ def process_event(param_dict): print("Stop address 0x%x is out of range [ 0x%x .. 0x%x ] for dso %s" % (stop_addr, int(dso_start), int(dso_end), dso)) return - if (options.objdump_name != None): + if (options.objdump != None): # It doesn't need to decrease virtual memory offset for disassembly # for kernel dso and executable file dso, so in this case we set # vm_start to zero.