Skip to content

Commit 9b2700e

Browse files
tonyj-suseacmel
authored andcommitted
perf script python: Add Python3 support to failed-syscalls-by-pid.py
Support both Python2 and Python3 in the failed-syscalls-by-pid.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 <tonyj@suse.de> Cc: Tom Zanussi <tzanussi@gmail.com> Link: http://lkml.kernel.org/r/20190222230619.17887-5-tonyj@suse.de Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 02b03ec commit 9b2700e

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

‎tools/perf/scripts/python/failed-syscalls-by-pid.py‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# Displays system-wide failed system call totals, broken down by pid.
66
# If a [comm] arg is specified, only syscalls called by [comm] are displayed.
77

8+
from __future__ import print_function
9+
810
import os
911
import sys
1012

@@ -32,7 +34,7 @@
3234
syscalls = autodict()
3335

3436
def trace_begin():
35-
print "Press control+C to stop and show the summary"
37+
print("Press control+C to stop and show the summary")
3638

3739
def trace_end():
3840
print_error_totals()
@@ -57,22 +59,21 @@ def syscalls__sys_exit(event_name, context, common_cpu,
5759

5860
def print_error_totals():
5961
if for_comm is not None:
60-
print "\nsyscall errors for %s:\n\n" % (for_comm),
62+
print("\nsyscall errors for %s:\n" % (for_comm))
6163
else:
62-
print "\nsyscall errors:\n\n",
64+
print("\nsyscall errors:\n")
6365

64-
print "%-30s %10s\n" % ("comm [pid]", "count"),
65-
print "%-30s %10s\n" % ("------------------------------", \
66-
"----------"),
66+
print("%-30s %10s" % ("comm [pid]", "count"))
67+
print("%-30s %10s" % ("------------------------------", "----------"))
6768

6869
comm_keys = syscalls.keys()
6970
for comm in comm_keys:
7071
pid_keys = syscalls[comm].keys()
7172
for pid in pid_keys:
72-
print "\n%s [%d]\n" % (comm, pid),
73+
print("\n%s [%d]" % (comm, pid))
7374
id_keys = syscalls[comm][pid].keys()
7475
for id in id_keys:
75-
print " syscall: %-16s\n" % syscall_name(id),
76+
print(" syscall: %-16s" % syscall_name(id))
7677
ret_keys = syscalls[comm][pid][id].keys()
77-
for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True):
78-
print " err = %-20s %10d\n" % (strerror(ret), val),
78+
for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True):
79+
print(" err = %-20s %10d" % (strerror(ret), val))

0 commit comments

Comments
 (0)