From patchwork Thu Sep 5 10:50:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13792155 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 14409CD5BA9 for ; Thu, 5 Sep 2024 10:58:24 +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=CSznTAkiUYs+zo3z9diQDvfmUN IGJGfuVFq2DTPDd5RCZSSR5Xryw+XgSWi885lz26kgHPYEnQaUuDKPkiYCLBFkxTA8H98jbZHvM1p vZ/Bd218RBX0xmF7grBXjo7DKxsXFxN2Uye93yDxPyY8Hy4s8I6es5lpxIET47zXLuxInNQkWWRxD YKrB/Zsecnl3g7YeYb9FWTOLal82BwA5GFQHNmEGaFNuACK+nNwcOzkw+RxW7mHH48m2cRhztz6G3 PaieWPpOeaMT2qy1wbxBs/b6i3Wqghs/HpeI17Cm/ab+3hZyVZAWx2tNgoRTPVArir5lKzHmMNUwA 1N++46dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smABp-00000008337-1S6A; Thu, 05 Sep 2024 10:58:13 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smA5L-000000081Ty-1neq for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 10:51:35 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-428e0d184b4so4662265e9.2 for ; Thu, 05 Sep 2024 03:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725533490; x=1726138290; 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=q6z+nkoDfmIat0QJuPJKwRUW9Pt5alELuOCh1Fu0SKYpd4zeJu751vsBhxEE64Klyu 0Tns4KAlCc7xCsHXEmxiMGBNfjJo4wuhBpeJGcLdtao1GNuIRaaOWYzzQZb09VrjYnA7 qsh8TUKrIkp/KbYc+NFYuykQKBUaeudlUiiNjnTqjECj3GER1jPoYUnUbNRuaYh51ix0 NmRDWH7ZIh9P1VxOsofbE3DQaDaYPKjPJth+V8pdlQwihHqzHq+VO9KXAJBNBWksgZix EouGu9f8Ys1RqPjCHc6StO/pWerhc6p1c6J06UoKjKJ2BOYytp1EoNPcFQ110nwY4urt MmwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725533490; x=1726138290; 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=toWV3BMpDVaOtV+X7i5tgBU12R1mm3yoPVN+c5j7LIYhfX1tYU7T5QAFT2r52P45eE 380/VhiqUWaSqipDs1UmTHUX++i/l6xaldANrc37Y77xw5Uq4atys0EjVBvDw2DmUjV6 gh9rPVHLnC+Xc2I6D0w5mHRXDrZx9gEN+A27/i8wvw4I2JNficTiSd5p/w68EwrtnYo8 gmKL0xEcPF3piGtWu7HneGJCZPp0SY8vAhQnnbNRxMUraQXgZpI2JNjYtCUWE1lGVFO4 l2FI6yskd2+xKh2z2dr3V7RKjcUFyq7RCcOixjxA3Y/A3bIqUQ82iV0WEZOTJWc/2chD Upxw== X-Forwarded-Encrypted: i=1; AJvYcCXzXkSjQFZIj1FAGPE22LZzZursQL85SXwWGDDboLMuNK6BY49elvprd7NjJu8bG+JnrTWthPkusNelssTmuW88@lists.infradead.org X-Gm-Message-State: AOJu0Yy6xxH4L1obkghZoZBnkRLGsRr74NCapALJ9qqS+SykE4rQ1f2l faR+CgIkS+g+yCfp+ZZt34arNR4rjqEtKvAaiF1qKC247agLo+oKV7uBGSNu0HE= X-Google-Smtp-Source: AGHT+IH/+XS62yXBkrtQXdlyQqjo3Bxww5IdiYqj0rBOSr4rHkxQrx9C9Aypty2rFMzvzq+ymudjxA== X-Received: by 2002:a05:600c:4f4f:b0:426:6000:565a with SMTP id 5b1f17b1804b1-42c7b5a8ee2mr111733575e9.16.1725533489532; Thu, 05 Sep 2024 03:51:29 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6df0dbcsm231089965e9.17.2024.09.05.03.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 03:51:29 -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 5/8] perf scripts python cs-etm: Update to use argparse Date: Thu, 5 Sep 2024 11:50:36 +0100 Message-Id: <20240905105043.160225-6-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905105043.160225-1-james.clark@linaro.org> References: <20240905105043.160225-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-20240905_035131_568676_A0166C23 X-CRM114-Status: GOOD ( 15.01 ) 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 --- .../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.