aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xentrace/xentrace_format
diff options
context:
space:
mode:
authormwilli2@equilibrium.research.intel-research.net <mwilli2@equilibrium.research.intel-research.net>2004-05-12 13:41:47 +0000
committermwilli2@equilibrium.research.intel-research.net <mwilli2@equilibrium.research.intel-research.net>2004-05-12 13:41:47 +0000
commit9b9ca98b6ab16d657deaf37bd51f3290ad1d2df8 (patch)
tree78e3eb5693c326123e99a3011edb38e8d7a7ed2d /tools/xentrace/xentrace_format
parente3d8d5ffdd61b1de7510db9c883f96f2a95238ae (diff)
downloadxen-9b9ca98b6ab16d657deaf37bd51f3290ad1d2df8.tar.gz
xen-9b9ca98b6ab16d657deaf37bd51f3290ad1d2df8.tar.bz2
xen-9b9ca98b6ab16d657deaf37bd51f3290ad1d2df8.zip
bitkeeper revision 1.891.1.8 (40a2299bVaCq0t5_5UXpB7OSB1yLKA)
Update xentrace to produce binary output format and xentrace_format to correctly parse it.
Diffstat (limited to 'tools/xentrace/xentrace_format')
-rw-r--r--tools/xentrace/xentrace_format41
1 files changed, 20 insertions, 21 deletions
diff --git a/tools/xentrace/xentrace_format b/tools/xentrace/xentrace_format
index 8da4fc4d68..4014811249 100644
--- a/tools/xentrace/xentrace_format
+++ b/tools/xentrace/xentrace_format
@@ -4,14 +4,15 @@
# Program for reformatting trace buffer output according to user-supplied rules
-import re, sys, string, signal
+import re, sys, string, signal, struct
def usage():
print >> sys.stderr, \
"Usage: " + sys.argv[0] + """ defs-file
- Parses trace data in ASCII format and reformats it according to the
- rules in a file of definitions. The rules in this file should have
- the format ({ and } show grouping and are not part of the syntax):
+ Parses trace data in binary format, as output by Xentrace and
+ reformats it according to the rules in a file of definitions. The
+ rules in this file should have the format ({ and } show grouping
+ and are not part of the syntax):
{event_id}{whitespace}{text format string}
@@ -68,31 +69,29 @@ interrupted = 0
defs = read_defs(sys.argv[1])
-reg = re.compile('(\d+) (\d+) (\d+) (.*)')
+# 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"
while not interrupted:
try:
- line = sys.stdin.readline()
+ line = sys.stdin.read(struct.calcsize(TRCREC))
if not line:
break
-
- m = reg.match(line)
-
- if not m: print >> sys.stderr, "Invalid input line."
-
- s = string.split(m.group(4))
- args = {'cpu' : eval(m.group(1)),
- 'tsc' : eval(m.group(2)),
- 'event' : eval(m.group(3)) }
+ (cpu, tsc, event, d1, d2, d3, d4, d5) = struct.unpack(TRCREC, line)
- i = 1
- for item in s:
- args[str(i)] = eval(item)
- i += 1
+ args = {'cpu' : cpu,
+ 'tsc' : tsc,
+ 'event' : event,
+ '1' : d1,
+ '2' : d2,
+ '3' : d3,
+ '4' : d4,
+ '5' : d5 }
- if defs.has_key(m.group(3)): print defs[m.group(3)] % args
+ 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
- except IOError: sys.exit()
+ except IOError, struct.error: sys.exit()