summaryrefslogtreecommitdiff
path: root/tools/trace/tinter
diff options
context:
space:
mode:
authorNélio Laranjeiro2009-07-13 16:56:36 +0200
committerNélio Laranjeiro2009-07-13 16:56:36 +0200
commitbc6e46cce9e2f6e4555a2c6cff1521a522156c6d (patch)
treecb36983f58beaa124d2ea081e8f902a8727d40b3 /tools/trace/tinter
parent41813460998b22f7ea3ac35ae6f8f9cda3886ac9 (diff)
*tools/trace:
* Added the possibility to add a callback file containing the function to decode traces. See the example/trace.trc to use it, the file containing the callback must be provided using the -c option in the interpretor.
Diffstat (limited to 'tools/trace/tinter')
-rw-r--r--tools/trace/tinter/tinter.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/trace/tinter/tinter.py b/tools/trace/tinter/tinter.py
index 1491f6a8..f326d27f 100644
--- a/tools/trace/tinter/tinter.py
+++ b/tools/trace/tinter/tinter.py
@@ -10,12 +10,13 @@ except:
class TInter:
- def __init__(self, infile, outfile, prgm):
+ def __init__(self, infile, outfile, prgm, cb):
self.__infile = infile
self.__events = None
self.__outfile = outfile
self.__file = None
self.__host = THost(prgm)
+ self.__cb_file = cb.strip('.py').replace('/', '.')
def __events_get (self):
infile = open (self.__infile, 'r')
@@ -23,20 +24,28 @@ class TInter:
infile.close()
return events
+ def __callback (self, event, data):
+ if event.callback == None:
+ string = event.string_get()
+ string = string % tuple (data)
+ else:
+ exec "from " + self.__cb_file + " import " + event.callback
+ string = locals()[event.callback](data)
+ return string
+
def __event_print (self, events, memory):
if len(memory) > 0:
cmd = get_size (memory, 2)
memory = memory[2:]
if cmd < len(events):
e = events[cmd]
- string = e.string_get()
vals = [ ]
for i in range (0, e.param_nb()):
p = e.param_get(i)
size = p.length()
vals.append (get_size (memory, size))
memory = memory[size:]
- string = string % tuple (vals)
+ string = self.__callback (e, vals)
if self.__file == None:
print string[1:len(string)-1]