Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1711199imu; Thu, 17 Jan 2019 01:54:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN7eleOMe3196mkSC6CW5908gBTgmNqXOCsKps4rWOw5yWoLTAKuo4RWSzTS9yH5PAGvmYJN X-Received: by 2002:a63:ef04:: with SMTP id u4mr12940174pgh.197.1547718890416; Thu, 17 Jan 2019 01:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547718890; cv=none; d=google.com; s=arc-20160816; b=V2UV1XUoExOnnmWNc9ELZYa7EkpzwGb3IIkuVoLvKbL5/Yq9xGSOYYelorIU2ku8xU NX14QKLC72uOaR9wm9CqTvmlDv0YZQirsi1crCGLhCBnnXJy8mC7Ij/caHvFDtdKFYjQ tHmAEwLjzvwD7+nDl1WUFbjkHyZyooiQauMMNnGRo5JCkiEPWXj+gjX0n2GOjbcQtKpg q3uysy8Gr7LUj1HCHaZ2vg3OvpVGq4tUMGWJt2hLZRN5jQ1bPcLH0zOpR6fGtaA6r4Yf eE1Q0ziMUNQjfX0tfHe46ftMlH+ZOjr6aRO4gZBzGgzUICe7O73AYba0o4HnhJCetxN+ MlSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=uUhZIYNZCICFNoTNA1B4MHeDPvwcefHDToK9NkUYs8E=; b=qN9QfKEcbuam9OpjCK2WoUFEm5oaS+wnrA9zfxUQQherQKX9IBrX2EOJGaCFsD/f68 ea2QTkDz4myrrLsWh59Vlk6E5ZVPnZmtnSpOSfEBwAbnwxRWfoqu6Giu8YcFTWsH4Iks IsX4H7tXy+7Nd3zc/8MpWmccBpbQOAyRl9oqevLjW3VceyI52Tucz0Lv6Q24KVCdAMpJ nczLP08Biw8iodip5406loscxEuis31GwxYgz29i6jFd0/J6UatcQt/sfQhz5cnif9dU nXe+nyjjlgju+/5x5Q3Rt9tznAQEuLeDEhe4NenhPcH3Y1MmVdQ829b9nnT+FOniZkaY xVKA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a11si1229057pln.78.2019.01.17.01.54.34; Thu, 17 Jan 2019 01:54:50 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbfAQJqO (ORCPT + 99 others); Thu, 17 Jan 2019 04:46:14 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37896 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728578AbfAQJqL (ORCPT ); Thu, 17 Jan 2019 04:46:11 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0H9iFKJ121985 for ; Thu, 17 Jan 2019 04:46:11 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2q2qb0831e-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 17 Jan 2019 04:46:11 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 Jan 2019 09:46:08 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 17 Jan 2019 09:46:04 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0H9k3ZN54919368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 17 Jan 2019 09:46:03 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B772F11C06C; Thu, 17 Jan 2019 09:46:03 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 58BB111C04C; Thu, 17 Jan 2019 09:46:02 +0000 (GMT) Received: from oc1548405160.ibm.com (unknown [9.124.35.202]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Thu, 17 Jan 2019 09:46:02 +0000 (GMT) From: Seeteena Thoufeek To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, linux-kernel@vger.kernel.org Cc: s1seetee@linux.vnet.ibm.com Subject: [PATCH v2] perf scripts python: Add Python 3 support to intel-pt-events.py Date: Thu, 17 Jan 2019 15:15:34 +0530 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547718344-27382-1-git-send-email-s1seetee@linux.vnet.ibm.com> References: <1547718344-27382-1-git-send-email-s1seetee@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011709-0028-0000-0000-0000033A5AED X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011709-0029-0000-0000-000023F78508 Message-Id: <1547718344-27382-7-git-send-email-s1seetee@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-17_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901170072 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support both Python 2 and Python 3 in intel-pt-events.py.``print`` is now a function rather than a statement. This should have no functional change. Fixes indentation issue, replace spaces with tab. Signed-off-by: Seeteena Thoufeek Reviewed-by: Ravi Bangoria --- tools/perf/scripts/python/intel-pt-events.py | 57 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py index b19172d..de153f7 100644 --- a/tools/perf/scripts/python/intel-pt-events.py +++ b/tools/perf/scripts/python/intel-pt-events.py @@ -9,6 +9,7 @@ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. +from __future__ import print_function import os import sys @@ -22,34 +23,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)), 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)), 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)), 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)), 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"] - sample = param_dict["sample"] - raw_buf = param_dict["raw_buf"] - comm = param_dict["comm"] - name = param_dict["ev_name"] - - # Symbol and dso info are not always resolved - if (param_dict.has_key("dso")): - dso = param_dict["dso"] - else: - dso = "[unknown]" - - if (param_dict.has_key("symbol")): - symbol = param_dict["symbol"] - else: - symbol = "[unknown]" - + event_attr = param_dict["attr"] + sample = param_dict["sample"] + raw_buf = param_dict["raw_buf"] + comm = param_dict["comm"] + name = param_dict["ev_name"] + + # Symbol and dso info are not always resolved + if ('dso' in param_dict): + dso = param_dict["dso"] + else: + dso = "[unknown]" + + if ('symbol' in param_dict): + symbol = param_dict["symbol"] + else: + symbol = "[unknown]" + if name == "ptwrite": print_common_start(comm, sample, name) print_ptwrite(raw_buf) -- 1.8.3.1