From patchwork Mon Sep 16 13:57: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: 13805530 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 4DE8BC3ABA2 for ; Mon, 16 Sep 2024 14:04:10 +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=lWq/62mWpUAFEk/gBjzNeVY0NoKYK+5WXUTV/6v1tA0=; b=wVGCJAbwHTcrxkkAlSuX2G1Uxk 96lHiSw2gRWbUI3v4mD7x31vIPeXrUgWHyMVN1F92E9rT4EDyy/4x2bdiPbhfmJksxFl1sjfV2I1M nINrSUtHVTNDaA/AApZ9H9CMYPV0d7J1SaUyOWtMwUDem1a/7kGbIqUy/WgedYIu+0rugN/zFHot7 LAA0arZGB6iwP8xskOq5+13a2rO5zqEpdFuH0D7K5ZZ7SDbJFEOBGaiSy8YqUPEOUlxmgClVJhrNm khDNwAxtx34Vt6WDSxmHHpq3CVnQAJC20xVkUjF7ymK6i+jFH+qT1xp5LORnjlvjAOT3lQswIOKqD qp5BBbKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sqCKZ-000000048yL-1ao1; Mon, 16 Sep 2024 14:03:55 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sqCFX-000000047cr-1mnl for linux-arm-kernel@lists.infradead.org; Mon, 16 Sep 2024 13:58:44 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-374c5bab490so3712703f8f.1 for ; Mon, 16 Sep 2024 06:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726495122; x=1727099922; 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=lWq/62mWpUAFEk/gBjzNeVY0NoKYK+5WXUTV/6v1tA0=; b=N9rsL51MegDDi073VPWj3l6ARjx4zo5cTeJdv3B/FRJtqz8Xbj2057HhttyeSgQQ/f DWg8on1bUAo1j3m0YDOaRUlxW2PurMlsByNN3JKDMTXjK16wAsDdobtHp3INchYRtdKq +Ur2TlD4WxDzfvDK9/2V53SZn8nIzp1WGyMEYr4guJf93yLYXJcJMgranP7n4so+nzdt RzkImUwDK9R1H8kfNj2CuRaE0dsffJc/h1MKocWTpaXA6zjWVQOjMxJOrx67l1UnDgXa /WzEuTQAfWHH9GWb7qFExWPFrnpirNCEJob8eSpjxllIg2/lQXkrkzKRjpc77Wefval4 nNMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726495122; x=1727099922; 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=lWq/62mWpUAFEk/gBjzNeVY0NoKYK+5WXUTV/6v1tA0=; b=MI8xoub/FEC5xgU4z3IV00MN01kOiZZ0iDUpPXR/cvCClYAqBK8DesRadrImBp8TME MqD5/J0IPKHY/4X+Bc4VEAJ1r82G32Yg0NOhrvuxRkf4tb7cIwrV00z2X+5gwG24M33Q f/xXjpJ+nU2r3PJYWgQ65wn5T4vHcK7Cl9WNiU4+qAE/uAtM3EDzYCd+V8t89Zld2fMs kR3PDHYxuRPMeb6zC0KWmsbBdR4lwYyV4xjlXZvU94WS+0YaH7KMqRGAF5gaUoK4Z5eI fUg5NEFmBXLBzRHIi0KVtcTcxuIFBi8XDxcUM1uwJIVqPPrMqv1Ce+M60fChrAuuD1lY aOfg== X-Forwarded-Encrypted: i=1; AJvYcCVMCJFjsh7i5BiozXp7kJrLD70O54fnMuejxkwxbHU3KTXWANXug+vdbtE/JpyavjO0a83JG8sh2Qr64WY4jqD3@lists.infradead.org X-Gm-Message-State: AOJu0Yzv0oj6eYV+sPfFavJJXTfBPqowCTz7a3Yb2QfRTPKmRa//+jdh mTx1dMRuDuSx2JDEYhfiCEEpIVdPw13EcQKjcn7f3R4ZwikqdSZzEFMI9rnZX+A= X-Google-Smtp-Source: AGHT+IGbvS6CYBCK4iQeg7G3Wj+J1fYZmYFe88jcm4ZQhuvkb+pN16rQGuWduTfP0xBqRl59dJ+Uyg== X-Received: by 2002:adf:b50a:0:b0:374:d130:a43b with SMTP id ffacd0b85a97d-378c27a12cdmr9347404f8f.4.1726495121954; Mon, 16 Sep 2024 06:58:41 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378e73f62dasm7285098f8f.49.2024.09.16.06.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2024 06:58:41 -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 v3 4/7] perf scripts python cs-etm: Update to use argparse Date: Mon, 16 Sep 2024 14:57:35 +0100 Message-Id: <20240916135743.1490403-5-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240916135743.1490403-1-james.clark@linaro.org> References: <20240916135743.1490403-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-20240916_065843_492589_FE4C04C4 X-CRM114-Status: GOOD ( 15.15 ) 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. Reviewed-by: Leo Yan 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.