From mboxrd@z Thu Jan 1 00:00:00 1970 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 26668EEE26C for ; Fri, 13 Sep 2024 12:46:02 +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: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0w1a9PBLAU6+gVAaHv8BVzKNUMW/qNR1GAJhDgJLols=; b=uhGjxUp5JeZc84SwCWKZJ+8TKp leOdUbz/OmCcex9KHHNsMTxGno8NLO0HC+Fs/pvDqGSQxTswOeNCz/5aYoqHt0CXz/yEwpTYhfHOu pu/tX/gQXpSD28AzeNFVZYdW7MmfUce/NiKyNnN4O+58Ebk9W3h62D9JH7iTb9q9FCZYbpk/+ZsNL 8jyP8Rs3Z1C/9Fu0RLkw9LjWMtHEjkgXoJPl+1uqEj3Tqfiea7DOopED7Yn0oO6lLJdl39DPuxxXq DRVEKIidPk+LOIBJbFIPPooD5v5qvC5wgmbVEX3RCvtO8LNUnjLS7Umd40qsWAnGg95AjIRkmwTeN 4Md1hM0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sp5gM-0000000FwkQ-1yDp; Fri, 13 Sep 2024 12:45:50 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sp5fH-0000000Fwe1-3d3G for linux-arm-kernel@lists.infradead.org; Fri, 13 Sep 2024 12:44:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6B54913D5; Fri, 13 Sep 2024 05:45:11 -0700 (PDT) Received: from [10.2.76.71] (e132581.arm.com [10.2.76.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 739873F64C; Fri, 13 Sep 2024 05:44:38 -0700 (PDT) Message-ID: <7ddea4df-9fe7-4cb8-998d-88e8c46ffcf8@arm.com> Date: Fri, 13 Sep 2024 13:44:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 4/7] perf scripts python cs-etm: Update to use argparse To: James Clark , linux-perf-users@vger.kernel.org, gankulkarni@os.amperecomputing.com, coresight@lists.linaro.org, scclevenger@os.amperecomputing.com Cc: 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 References: <20240912151143.1264483-1-james.clark@linaro.org> <20240912151143.1264483-5-james.clark@linaro.org> Content-Language: en-US From: Leo Yan In-Reply-To: <20240912151143.1264483-5-james.clark@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240913_054444_091160_AB30226E X-CRM114-Status: GOOD ( 18.02 ) 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 On 9/12/24 16:11, James Clark wrote:> > 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. > -- > 2.34.1 >