Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1215363imu; Wed, 16 Jan 2019 15:00:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN50X/1gpSjExJC6AVw0crEqpxWuwUt7EGcQ/M49NGP8vMGuRBuGLhxKGbDTkYVJK25LknzT X-Received: by 2002:a63:3703:: with SMTP id e3mr10967180pga.348.1547679628913; Wed, 16 Jan 2019 15:00:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547679628; cv=none; d=google.com; s=arc-20160816; b=zYkZCjPwHNv8jh9bLO/MaybLGOLo38Pj4FmhtG4/tXZZ3LfurUShnsPwUe1WHjVg69 Sot6Q+xQp1sqW97QLLEhmCenraLcYYrl2QF4T7sqYw9iFY4oee6cqhCsfVh8dU86uTkz xMW0QSwNBOb1UHt+LkM6Fmeyrq1UbkLNFDlYrk3z6LktwTKr//JBqPxCOH+/0geazc5D Ta8yKbzZMyxqblmk08VPO3A1V+T2Furh9DvgrOTNJt4nOTeI6EEXWZBBYGcpKX+QCpKH nr5YTqF41quLKQYNe1MH1cQ3xO2qQ7t8nnWo9NXeUk4527dShH42JYNMkEpYuQ0NxjnQ Vk6g== 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=/s1kGuSsMQvlJGBUsvYMx9ieA9tokESDzrwebFbRTQg=; b=xyIZedSr11J/E0OO5RxH+gpsL1s8wMfHXrvFYLUGPR+5+D0USOz9k53s38jf29kZF7 vWv1/3aknUQQ/xC6rcrhb6T4+JnEYjPEyOFOVcMhYpbVInBIiD8tW69hd03wFNFrdz32 EN92N9+nw70sUyPCU7+QO0GYqhP4kz/flpecsTTngnOwtYpfbb0ZWKJTefPmBO4Q9BsT TQYDoiMuYP04669GA7/OI5ShtaZzD5JF5j8I4Ive3Av0Hr3/2XQKmcpKPcEAyHhe+VCt CoaB7nrf/SFiDl7IK66VRjl571BNSaXoNfoBoYtcRPbKHGT97BiMxK0asI7heL0Akqwf TknQ== 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 p10si2290307pgi.549.2019.01.16.15.00.13; Wed, 16 Jan 2019 15:00:28 -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 S2405507AbfAPQYW (ORCPT + 99 others); Wed, 16 Jan 2019 11:24:22 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48294 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731504AbfAPQYV (ORCPT ); Wed, 16 Jan 2019 11:24:21 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id x0GGMnCF180000 for ; Wed, 16 Jan 2019 11:24:19 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2q2832g2kt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 16 Jan 2019 11:24:19 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 16 Jan 2019 16:24:17 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) 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) Wed, 16 Jan 2019 16:24:15 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x0GGOEdS65732618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 16 Jan 2019 16:24:14 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 40EDA42045; Wed, 16 Jan 2019 16:24:14 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 241E842049; Wed, 16 Jan 2019 16:24:12 +0000 (GMT) Received: from oc1548405160.ibm.com (unknown [9.85.72.239]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 16 Jan 2019 16:24:11 +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, ravi.bangoria@linux.ibm.com Subject: [PATCH] perf scripts python: Add Python 3 support to intel-pt-events.py Date: Wed, 16 Jan 2019 21:53:35 +0530 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1547655825-28754-1-git-send-email-s1seetee@linux.vnet.ibm.com> References: <1547655825-28754-1-git-send-email-s1seetee@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19011616-0028-0000-0000-0000033A0BEE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19011616-0029-0000-0000-000023F733BA Message-Id: <1547655825-28754-7-git-send-email-s1seetee@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-01-16_06:,, 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-1901160132 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 | 56 ++++++++++++++-------------- 1 file changed, 28 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..a02a810 100644 --- a/tools/perf/scripts/python/intel-pt-events.py +++ b/tools/perf/scripts/python/intel-pt-events.py @@ -22,34 +22,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