aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/failed-syscalls-by-pid.py
diff options
context:
space:
mode:
authorTony Jones <tonyj@suse.de>2019-02-22 18:06:08 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-02-25 15:16:48 -0500
commit9b2700efc57f46fe63beee5f64fcfe2746936b4e (patch)
treed65310426f84d902f82b57f052cc8a9b61ce52c0 /tools/perf/scripts/python/failed-syscalls-by-pid.py
parent02b03ec383e0c79d73aa4b402b3427a8b490ef9f (diff)
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>
Diffstat (limited to 'tools/perf/scripts/python/failed-syscalls-by-pid.py')
-rw-r--r--tools/perf/scripts/python/failed-syscalls-by-pid.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/perf/scripts/python/failed-syscalls-by-pid.py b/tools/perf/scripts/python/failed-syscalls-by-pid.py
index cafeff3d74db..3648e8b986ec 100644
--- a/tools/perf/scripts/python/failed-syscalls-by-pid.py
+++ b/tools/perf/scripts/python/failed-syscalls-by-pid.py
@@ -5,6 +5,8 @@
5# Displays system-wide failed system call totals, broken down by pid. 5# Displays system-wide failed system call totals, broken down by pid.
6# If a [comm] arg is specified, only syscalls called by [comm] are displayed. 6# If a [comm] arg is specified, only syscalls called by [comm] are displayed.
7 7
8from __future__ import print_function
9
8import os 10import os
9import sys 11import sys
10 12
@@ -32,7 +34,7 @@ if len(sys.argv) > 1:
32syscalls = autodict() 34syscalls = autodict()
33 35
34def trace_begin(): 36def trace_begin():
35 print "Press control+C to stop and show the summary" 37 print("Press control+C to stop and show the summary")
36 38
37def trace_end(): 39def trace_end():
38 print_error_totals() 40 print_error_totals()
@@ -57,22 +59,21 @@ def syscalls__sys_exit(event_name, context, common_cpu,
57 59
58def print_error_totals(): 60def print_error_totals():
59 if for_comm is not None: 61 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))
61 else: 63 else:
62 print "\nsyscall errors:\n\n", 64 print("\nsyscall errors:\n")
63 65
64 print "%-30s %10s\n" % ("comm [pid]", "count"), 66 print("%-30s %10s" % ("comm [pid]", "count"))
65 print "%-30s %10s\n" % ("------------------------------", \ 67 print("%-30s %10s" % ("------------------------------", "----------"))
66 "----------"),
67 68
68 comm_keys = syscalls.keys() 69 comm_keys = syscalls.keys()
69 for comm in comm_keys: 70 for comm in comm_keys:
70 pid_keys = syscalls[comm].keys() 71 pid_keys = syscalls[comm].keys()
71 for pid in pid_keys: 72 for pid in pid_keys:
72 print "\n%s [%d]\n" % (comm, pid), 73 print("\n%s [%d]" % (comm, pid))
73 id_keys = syscalls[comm][pid].keys() 74 id_keys = syscalls[comm][pid].keys()
74 for id in id_keys: 75 for id in id_keys:
75 print " syscall: %-16s\n" % syscall_name(id), 76 print(" syscall: %-16s" % syscall_name(id))
76 ret_keys = syscalls[comm][pid][id].keys() 77 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 for ret, val in sorted(syscalls[comm][pid][id].items(), key = lambda kv: (kv[1], kv[0]), reverse = True):
78 print " err = %-20s %10d\n" % (strerror(ret), val), 79 print(" err = %-20s %10d" % (strerror(ret), val))