1 # Util.py - Python extension for perf trace, miscellaneous utility code
3 # Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com>
5 # This software may be distributed under the terms of the GNU General
6 # Public License ("GPL") version 2 as published by the Free Software
11 NSECS_PER_SEC
= 1000000000
16 def nsecs(secs
, nsecs
):
17 return secs
* NSECS_PER_SEC
+ nsecs
19 def nsecs_secs(nsecs
):
20 return nsecs
/ NSECS_PER_SEC
22 def nsecs_nsecs(nsecs
):
23 return nsecs
% NSECS_PER_SEC
26 str = "%5u.%09u" % (nsecs_secs(nsecs
), nsecs_nsecs(nsecs
)),
30 print("\x1b[H\x1b[2J")
32 audit_package_warned
= False
37 'x86_64': audit
.MACH_86_64
,
38 'alpha' : audit
.MACH_ALPHA
,
39 'ia64' : audit
.MACH_IA64
,
40 'ppc' : audit
.MACH_PPC
,
41 'ppc64' : audit
.MACH_PPC64
,
42 's390' : audit
.MACH_S390
,
43 's390x' : audit
.MACH_S390X
,
44 'i386' : audit
.MACH_X86
,
45 'i586' : audit
.MACH_X86
,
46 'i686' : audit
.MACH_X86
,
49 machine_to_id
['armeb'] = audit
.MACH_ARMEB
52 machine_id
= machine_to_id
[os
.uname()[4]]
54 if not audit_package_warned
:
55 audit_package_warned
= True
56 print "Install the audit-libs-python package to get syscall names"
60 return audit
.audit_syscall_to_name(id, machine_id
)
66 return errno
.errorcode
[abs(nr
)]
68 return "Unknown %d errno" % nr