Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 218668
b: refs/heads/master
c: 6cc7361
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Oct 25, 2010
1 parent c42945a commit 672f7b3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 66a301c380d4e463424db572b348de4913ec191a
refs/heads/master: 6cc7361440e499abb3a30cdbcfedad03e43c92ae
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Public License ("GPL") version 2 as published by the Free Software
# Foundation.

import errno, os

NSECS_PER_SEC = 1000000000

def avg(total, n):
Expand All @@ -26,3 +28,38 @@ def nsecs_str(nsecs):

def clear_term():
print("\x1b[H\x1b[2J")

audit_package_warned = False

try:
import audit
machine_to_id = {
'x86_64': audit.MACH_86_64,
'alpha' : audit.MACH_ALPHA,
'armeb' : audit.MACH_ARMEB,
'ia64' : audit.MACH_IA64,
'ppc' : audit.MACH_PPC,
'ppc64' : audit.MACH_PPC64,
's390' : audit.MACH_S390,
's390x' : audit.MACH_S390X,
'i386' : audit.MACH_X86,
'i586' : audit.MACH_X86,
'i686' : audit.MACH_X86,
}
machine_id = machine_to_id[os.uname()[4]]
except:
if not audit_package_warned:
audit_package_warned = True
print "Install the audit-libs-python package to get syscall names"

def syscall_name(id):
try:
return audit.audit_syscall_to_name(id, machine_id)
except:
return str(id)

def strerror(nr):
try:
return errno.errorcode[abs(nr)]
except:
return "Unknown %d errno" % nr
21 changes: 13 additions & 8 deletions trunk/tools/perf/scripts/python/failed-syscalls-by-pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,36 @@

from perf_trace_context import *
from Core import *
from Util import *

usage = "perf trace -s syscall-counts-by-pid.py [comm]\n";
usage = "perf trace -s syscall-counts-by-pid.py [comm|pid]\n";

for_comm = None
for_pid = None

if len(sys.argv) > 2:
sys.exit(usage)

if len(sys.argv) > 1:
for_comm = sys.argv[1]
try:
for_pid = int(sys.argv[1])
except:
for_comm = sys.argv[1]

syscalls = autodict()

def trace_begin():
pass
print "Press control+C to stop and show the summary"

def trace_end():
print_error_totals()

def raw_syscalls__sys_exit(event_name, context, common_cpu,
common_secs, common_nsecs, common_pid, common_comm,
id, ret):
if for_comm is not None:
if common_comm != for_comm:
return
if (for_comm and common_comm != for_comm) or \
(for_pid and common_pid != for_pid ):
return

if ret < 0:
try:
Expand All @@ -62,7 +67,7 @@ def print_error_totals():
print "\n%s [%d]\n" % (comm, pid),
id_keys = syscalls[comm][pid].keys()
for id in id_keys:
print " syscall: %-16d\n" % (id),
print " syscall: %-16s\n" % syscall_name(id),
ret_keys = syscalls[comm][pid][id].keys()
for ret, val in sorted(syscalls[comm][pid][id].iteritems(), key = lambda(k, v): (v, k), reverse = True):
print " err = %-20d %10d\n" % (ret, val),
print " err = %-20s %10d\n" % (strerror(ret), val),

0 comments on commit 672f7b3

Please sign in to comment.