python: Use a sequential number to identify each call.

TODO: Modify the trace driver to generate these on the XML file itself.
This commit is contained in:
José Fonseca 2009-03-25 13:44:32 +00:00
parent 9d97c3d0be
commit ecfa99ece1
2 changed files with 15 additions and 2 deletions

View file

@ -101,7 +101,8 @@ class Pointer(Node):
class Call:
def __init__(self, klass, method, args, ret):
def __init__(self, no, klass, method, args, ret):
self.no = no
self.klass = klass
self.method = method
self.args = args
@ -187,6 +188,7 @@ class PrettyPrinter:
self.formatter.address(node.address)
def visit_call(self, node):
self.formatter.text('%s ' % node.no)
if node.klass is not None:
self.formatter.function(node.klass + '::' + node.method)
else:

View file

@ -190,6 +190,10 @@ class XmlParser:
class TraceParser(XmlParser):
def __init__(self, fp):
XmlParser.__init__(self, fp)
self.last_call_no = 0
def parse(self):
self.element_start('trace')
while self.token.type not in (ELEMENT_END, EOF):
@ -200,6 +204,13 @@ class TraceParser(XmlParser):
def parse_call(self):
attrs = self.element_start('call')
try:
no = int(attrs['no'])
except KeyError:
self.last_call_no += 1
no = self.last_call_no
else:
self.last_call_no = no
klass = attrs['class']
method = attrs['method']
args = []
@ -217,7 +228,7 @@ class TraceParser(XmlParser):
raise TokenMismatch("<arg ...> or <ret ...>", self.token)
self.element_end('call')
return Call(klass, method, args, ret)
return Call(no, klass, method, args, ret)
def parse_arg(self):
attrs = self.element_start('arg')