Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6985279imb; Sat, 9 Mar 2019 12:05:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyUL9O/H6D3A0nQ2ahYRATd5jKkSV4odFbKj1hP+X2Jk6m5C8uaDMOQRG5BzB1+vdddhC3v X-Received: by 2002:a63:d4f:: with SMTP id 15mr22923495pgn.162.1552161944515; Sat, 09 Mar 2019 12:05:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552161944; cv=none; d=google.com; s=arc-20160816; b=qHMC4bJAXOsQ+NnSdl1SlNQ4XkLJJhejZymALtT1F3b093qeYrxYjtu69l9539qDX3 dafhi8eB5LdLR01qoP/FPa/l7F5Dcc0mxw+ROf43yzHnd6Nlg6ZFbL/+kwyvAIEnckLy HFr+/CwAFdoCSZ0j7nx8KijxO5jtvwFaW0pqYNxetLpZv/qgSCIuqAXIjLIUCYxq2XZj M23+oFdkCUxWaQiGDfOBF3KuNv9RZ2pj/b8sPFMp5pYz8u65YoRB7daP3VDJJSAkqKed VOIuyrYNlyqV8PRhzecfqI3YEjiAdODVqKqGZ7iXUolYy8LeY9kT7lpz6pNzvaO8WOVI s0FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=DtGouN1WFfbxYtDUpK465UbcbAcAUlnLSUHhm/P2aok=; b=L5g+W7lawevMIIwqgEkB776V8EtKSPEQ1AUtRF+wg5H60BlFz1ar2pXj3lSZxJOMlE mPher2w3+VFkOMvxrXNTn6W1/klrsxl8vm6IAzZKT5Tf/gasnR4YX9iD7AMyu3EO8OYj NAE5vv2KEZziOXnodVBRYDVtUwm6rWmemwRUh/XBFME1Mq8Z/DG9DFNtpffq9nBSr6lY pnzdIT/yYoaV7l4uj9zMs/wcSLBS5UYrMKI4e3cneiQjin6REulNR0Mm6aH0Hk/BU7xq u/m1JRBoaxeZ+puRo3kwu3ujTRpd5C26ZkQidFxZ7OmuHuJ9Iay7UjrAM3z/JGh3xHQS N0uA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m22si1122846pgv.562.2019.03.09.12.05.29; Sat, 09 Mar 2019 12:05:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbfCIUFG (ORCPT + 99 others); Sat, 9 Mar 2019 15:05:06 -0500 Received: from terminus.zytor.com ([198.137.202.136]:35187 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726298AbfCIUFF (ORCPT ); Sat, 9 Mar 2019 15:05:05 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x29K4t6h3205615 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 9 Mar 2019 12:04:55 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x29K4t473205612; Sat, 9 Mar 2019 12:04:55 -0800 Date: Sat, 9 Mar 2019 12:04:55 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Tony Jones Message-ID: Cc: acme@redhat.com, adrian.hunter@intel.com, mingo@kernel.org, tonyj@suse.de, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, s1seetee@linux.vnet.ibm.com Reply-To: tonyj@suse.de, mingo@kernel.org, adrian.hunter@intel.com, acme@redhat.com, s1seetee@linux.vnet.ibm.com, hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf script python: Add Python3 support to intel-pt-events.py Git-Commit-ID: fdf2460c297f1bb2f3bd20b3b52903b267af9050 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_48_96 autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: fdf2460c297f1bb2f3bd20b3b52903b267af9050 Gitweb: https://git.kernel.org/tip/fdf2460c297f1bb2f3bd20b3b52903b267af9050 Author: Tony Jones AuthorDate: Tue, 5 Mar 2019 08:19:02 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:12:33 -0300 perf script python: Add Python3 support to intel-pt-events.py Support both Python2 and Python3 in the intel-pt-events.py script There may be differences in the ordering of output lines due to differences in dictionary ordering etc. However the format within lines should be unchanged. The use of 'from __future__' implies the minimum supported Python2 version is now v2.6 Signed-off-by: Tony Jones Acked-by: Adrian Hunter Link: http://lkml.kernel.org/r/fd26acf9-0c0f-717f-9664-a3c33043ce19@suse.de Signed-off-by: Seeteena Thoufeek Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/intel-pt-events.py | 32 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py index 2177722f509e..a73847c8f548 100644 --- a/tools/perf/scripts/python/intel-pt-events.py +++ b/tools/perf/scripts/python/intel-pt-events.py @@ -10,6 +10,8 @@ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. +from __future__ import print_function + import os import sys import struct @@ -22,34 +24,34 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \ #from Core import * def trace_begin(): - print "Intel PT Power Events and PTWRITE" + print("Intel PT Power Events and PTWRITE") def trace_end(): - print "End" + print("End") def trace_unhandled(event_name, context, event_fields_dict): - print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) + print(' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])) def print_ptwrite(raw_buf): data = struct.unpack_from("> 32) & 0x3 - print "hints: %#x extensions: %#x" % (hints, extensions), + print("hints: %#x extensions: %#x" % (hints, extensions), end=' ') def print_pwre(raw_buf): data = struct.unpack_from("> 7) & 1 cstate = (payload >> 12) & 0xf subcstate = (payload >> 8) & 0xf - print "hw: %u cstate: %u sub-cstate: %u" % (hw, cstate, subcstate), + print("hw: %u cstate: %u sub-cstate: %u" % (hw, cstate, subcstate), + end=' ') def print_exstop(raw_buf): data = struct.unpack_from("> 4) & 0xf wake_reason = (payload >> 8) & 0xf - print "deepest cstate: %u last cstate: %u wake reason: %#x" % (deepest_cstate, last_cstate, wake_reason), + print("deepest cstate: %u last cstate: %u wake reason: %#x" % + (deepest_cstate, last_cstate, wake_reason), end=' ') def print_common_start(comm, sample, name): ts = sample["time"] cpu = sample["cpu"] pid = sample["pid"] tid = sample["tid"] - print "%16s %5u/%-5u [%03u] %9u.%09u %7s:" % (comm, pid, tid, cpu, ts / 1000000000, ts %1000000000, name), + print("%16s %5u/%-5u [%03u] %9u.%09u %7s:" % + (comm, pid, tid, cpu, ts / 1000000000, ts %1000000000, name), + end=' ') def print_common_ip(sample, symbol, dso): ip = sample["ip"] - print "%16x %s (%s)" % (ip, symbol, dso) + print("%16x %s (%s)" % (ip, symbol, dso)) def process_event(param_dict): event_attr = param_dict["attr"] @@ -92,12 +98,12 @@ def process_event(param_dict): name = param_dict["ev_name"] # Symbol and dso info are not always resolved - if (param_dict.has_key("dso")): + if "dso" in param_dict: dso = param_dict["dso"] else: dso = "[unknown]" - if (param_dict.has_key("symbol")): + if "symbol" in param_dict: symbol = param_dict["symbol"] else: symbol = "[unknown]"