aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xentrace/xentrace_format
diff options
context:
space:
mode:
authoriap10@tetris.cl.cam.ac.uk <iap10@tetris.cl.cam.ac.uk>2004-05-19 21:46:26 +0000
committeriap10@tetris.cl.cam.ac.uk <iap10@tetris.cl.cam.ac.uk>2004-05-19 21:46:26 +0000
commitba0805e639d30c031417ab91ccde71792e41be4b (patch)
tree686ffec484cb5bb9c9a2539ed2d362951a4fc25f /tools/xentrace/xentrace_format
parent2995b747c15256d51f805e1f45b924a192fd6bcd (diff)
downloadxen-ba0805e639d30c031417ab91ccde71792e41be4b.tar.gz
xen-ba0805e639d30c031417ab91ccde71792e41be4b.tar.bz2
xen-ba0805e639d30c031417ab91ccde71792e41be4b.zip
bitkeeper revision 1.911.1.1 (40abd5b2mqoey54uZKqDJrA-dD05Xw)
bandaid for xentrace. Really needs a Xen-visible trace buffer consumer index, and a way of kicking the trace deamon...
Diffstat (limited to 'tools/xentrace/xentrace_format')
-rw-r--r--tools/xentrace/xentrace_format52
1 files changed, 47 insertions, 5 deletions
diff --git a/tools/xentrace/xentrace_format b/tools/xentrace/xentrace_format
index 4014811249..d2e51265d4 100644
--- a/tools/xentrace/xentrace_format
+++ b/tools/xentrace/xentrace_format
@@ -4,7 +4,7 @@
# Program for reformatting trace buffer output according to user-supplied rules
-import re, sys, string, signal, struct
+import re, sys, string, signal, struct, os, getopt
def usage():
print >> sys.stderr, \
@@ -43,6 +43,9 @@ def read_defs(defs_file):
line = fd.readline()
if not line:
break
+
+ if line[0] == '#' or line[0] == '\n':
+ continue
m = reg.match(line)
@@ -58,29 +61,61 @@ def sighand(x,y):
##### Main code
+mhz = 0
+
if len(sys.argv) < 2:
usage()
+try:
+ opts, arg = getopt.getopt(sys.argv[1:], "c:" )
+
+ for opt in opts:
+ if opt[0] == '-c' : mhz = int(opt[1])
+
+except getopt.GetoptError:
+ usage()
+
+print mhz
+
signal.signal(signal.SIGTERM, sighand)
signal.signal(signal.SIGHUP, sighand)
signal.signal(signal.SIGINT, sighand)
interrupted = 0
-defs = read_defs(sys.argv[1])
+defs = read_defs(arg[0])
+
+print defs
# structure of trace record + prepended CPU id (as output by xentrace):
# CPU(I) TSC(Q) EVENT(L) D1(L) D2(L) D3(L) D4(L) D5(L)
TRCREC = "IQLLLLLL"
+last_tsc = [0,0,0,0,0,0,0,0]
+
+i=0
+
while not interrupted:
try:
+ i=i+1
line = sys.stdin.read(struct.calcsize(TRCREC))
if not line:
break
(cpu, tsc, event, d1, d2, d3, d4, d5) = struct.unpack(TRCREC, line)
+ #tsc = (tscH<<32) | tscL
+
+ #print i, tsc
+
+ if tsc < last_tsc[cpu]:
+ print "TSC stepped backward cpu %d ! %d %d" % (cpu,tsc,last_tsc[cpu])
+
+ last_tsc[cpu] = tsc
+
+ if mhz:
+ tsc = tsc / (mhz*1000000.0)
+
args = {'cpu' : cpu,
'tsc' : tsc,
'event' : event,
@@ -90,8 +125,15 @@ while not interrupted:
'4' : d4,
'5' : d5 }
- if defs.has_key(str(event)): print defs[str(event)] % args
- # silently skip lines we don't have a format for - a 'complain' option
- # should be added if needed
+ try:
+
+ if defs.has_key(str(event)):
+ print defs[str(event)] % args
+ else:
+ if defs.has_key(str(0)): print defs[str(0)] % args
+ except TypeError:
+ print defs[str(event)]
+ print args
+
except IOError, struct.error: sys.exit()