aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/Perf-Trace-Util/lib
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-10-25 13:15:10 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-10-25 16:46:41 -0400
commit6cc7361440e499abb3a30cdbcfedad03e43c92ae (patch)
tree4df3f4ab170faf7277c6cbf138ddcfcdcf68fc37 /tools/perf/scripts/python/Perf-Trace-Util/lib
parent66a301c380d4e463424db572b348de4913ec191a (diff)
perf python scripting: Improve the failed-syscalls-by-pid script
. Print message at script start telling how to get te summary . Print the syscall name using the audit-lib-python package, if installed . Print the errno string . Accept both pid (if numeric) or COMM name Now it looks like this: [root@emilia ~]# perf trace failed-syscalls-by-pid Press control+C to stop and show the summary ^C syscall errors: comm [pid] count ------------------------------ ---------- automount [1670] syscall: futex err = ETIMEDOUT 39 irqbalance [1462] syscall: openat err = ENOENT 4 perf [7888] syscall: lseek err = ESPIPE 1 syscall: open err = ENOENT 24 perf [7889] syscall: ioctl err = EINVAL 1 syscall: readlink err = EINVAL 2 syscall: open err = ENOENT 389 syscall: stat err = ENOENT 141 syscall: lseek err = ESPIPE 3 [root@emilia ~]# [root@emilia ~]# perf trace failed-syscalls-by-pid 1670 Press control+C to stop and show the summary ^C syscall errors: comm [pid] count ------------------------------ ---------- automount [1670] syscall: futex err = ETIMEDOUT 2 [root@emilia ~]# [root@emilia ~]# [root@emilia ~]# [root@emilia ~]# perf trace failed-syscalls-by-pid automount Press control+C to stop and show the summary ^C syscall errors for automount: comm [pid] count ------------------------------ ---------- automount [1669] syscall: futex err = ETIMEDOUT 1 automount [1670] syscall: futex err = ETIMEDOUT 5 [root@emilia ~]# Cc: David S. Miller <davem@davemloft.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/Perf-Trace-Util/lib')
-rw-r--r--tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
index 9689bc0acd9f..9d15f484308c 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
+++ b/tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
@@ -6,6 +6,8 @@
6# Public License ("GPL") version 2 as published by the Free Software 6# Public License ("GPL") version 2 as published by the Free Software
7# Foundation. 7# Foundation.
8 8
9import errno, os
10
9NSECS_PER_SEC = 1000000000 11NSECS_PER_SEC = 1000000000
10 12
11def avg(total, n): 13def avg(total, n):
@@ -26,3 +28,38 @@ def nsecs_str(nsecs):
26 28
27def clear_term(): 29def clear_term():
28 print("\x1b[H\x1b[2J") 30 print("\x1b[H\x1b[2J")
31
32audit_package_warned = False
33
34try:
35 import audit
36 machine_to_id = {
37 'x86_64': audit.MACH_86_64,
38 'alpha' : audit.MACH_ALPHA,
39 'armeb' : audit.MACH_ARMEB,
40 'ia64' : audit.MACH_IA64,
41 'ppc' : audit.MACH_PPC,
42 'ppc64' : audit.MACH_PPC64,
43 's390' : audit.MACH_S390,
44 's390x' : audit.MACH_S390X,
45 'i386' : audit.MACH_X86,
46 'i586' : audit.MACH_X86,
47 'i686' : audit.MACH_X86,
48 }
49 machine_id = machine_to_id[os.uname()[4]]
50except:
51 if not audit_package_warned:
52 audit_package_warned = True
53 print "Install the audit-libs-python package to get syscall names"
54
55def syscall_name(id):
56 try:
57 return audit.audit_syscall_to_name(id, machine_id)
58 except:
59 return str(id)
60
61def strerror(nr):
62 try:
63 return errno.errorcode[abs(nr)]
64 except:
65 return "Unknown %d errno" % nr