plugin/tracing: merge full-tracing plugin into generic version

The full-tracing plugin was used in the DSN paper. It additionally
traces the data that was accessed/written on a memory access and the
contents of some CPU registers.

Change-Id: I61f5230699009ce523aba341985b98148160556d
This commit is contained in:
Christian Dietrich
2013-03-15 15:35:37 +01:00
committed by Gerrit Code Review
parent cffafa411c
commit 4e8098a636
7 changed files with 281 additions and 186 deletions

View File

@ -0,0 +1,4 @@
all: trace_pb2.py
trace_pb2.py: ../../src/plugins/tracing/trace.proto
protoc --python_out=. --proto_path `dirname $<` $<

62
tools/dump-trace/dump-trace.py Executable file
View File

@ -0,0 +1,62 @@
#! /usr/bin/env python
# create python bindings before running:
# protoc --python_out=. trace.proto
import trace_pb2
import sys
import struct
from gzip import GzipFile
if len(sys.argv) != 2:
print "Usage:", sys.argv[0], "tracefile.pb"
sys.exit(-1)
trace_event = trace_pb2.Trace_Event()
def open_trace(filename):
f = open(filename, "rb")
if ord(f.read(1)) == 0x1f and ord(f.read(1)) == 0x8b:
f.seek(0,0)
return GzipFile(fileobj = f)
f.seek(0,0)
return f
try:
f = open_trace(sys.argv[1])
except IOError:
print sys.argv[1] + ": Could not open file."
sys.exit(-1)
while True:
# Read trace length
try:
lengthNO = f.read(4)
if len(lengthNO) == 0:
break
except IOError:
print "Could not read data from file"
# Read Trace-Event
length = struct.unpack('!I', lengthNO)[0]
trace_event.ParseFromString(f.read(length))
# This works for any type of pb message:
# print trace_event
# More compact dump for traces:
if not trace_event.HasField("memaddr"):
print "IP {0:x}".format(trace_event.ip)
else:
ext = ""
if trace_event.HasField("trace_ext"):
ext = "DATA {0:x}".format(trace_event.trace_ext.data)
for reg in trace_event.trace_ext.registers:
ext += " REG: {0} *{1:x}={2:x}".format(reg.id, reg.value, reg.value_deref)
if len(trace_event.trace_ext.stack) > 0:
ext += " STACK: " + "".join(["%x"%x for x in trace_event.trace_ext.stack])
print "MEM {0} {1:x} width {2:d} IP {3:x} {4}".format(
"R" if trace_event.accesstype == trace_pb2.Trace_Event.READ else "W",
trace_event.memaddr, trace_event.width, trace_event.ip, ext)
f.close()