aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorLluís Vilanova <vilanova@ac.upc.edu>2014-05-30 14:11:38 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2014-08-12 14:26:11 +0100
commitb55835ac109b7f5f11a3f12bf445f75b76bc9f01 (patch)
tree97270a08bf81a6f510a668417e0f382c6c724e60 /scripts
parente6d6c4bebf493317deec329069b7e872c2237684 (diff)
trace: [tcg] Argument type transformation machinery
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/tracetool/__init__.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index e8e8edcc4c..bd3fd85d78 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -15,6 +15,7 @@ __email__ = "stefanha@linux.vnet.ibm.com"
import re
import sys
+import weakref
import tracetool.format
import tracetool.backend
@@ -108,6 +109,18 @@ class Arguments:
"""List of argument types."""
return [ type_ for type_, _ in self._args ]
+ def transform(self, *trans):
+ """Return a new Arguments instance with transformed types.
+
+ The types in the resulting Arguments instance are transformed according
+ to tracetool.transform.transform_type.
+ """
+ res = []
+ for type_, name in self._args:
+ res.append((tracetool.transform.transform_type(type_, *trans),
+ name))
+ return Arguments(res)
+
class Event(object):
"""Event description.
@@ -128,7 +141,7 @@ class Event(object):
_VALID_PROPS = set(["disable"])
- def __init__(self, name, props, fmt, args):
+ def __init__(self, name, props, fmt, args, orig=None):
"""
Parameters
----------
@@ -140,12 +153,19 @@ class Event(object):
Event printing format.
args : Arguments
Event arguments.
+ orig : Event or None
+ Original Event before transformation.
"""
self.name = name
self.properties = props
self.fmt = fmt
self.args = args
+ if orig is None:
+ self.original = weakref.ref(self)
+ else:
+ self.original = orig
+
unknown_props = set(self.properties) - self._VALID_PROPS
if len(unknown_props) > 0:
raise ValueError("Unknown properties: %s"
@@ -190,6 +210,14 @@ class Event(object):
fmt = Event.QEMU_TRACE
return fmt % {"name": self.name}
+ def transform(self, *trans):
+ """Return a new Event with transformed Arguments."""
+ return Event(self.name,
+ list(self.properties),
+ self.fmt,
+ self.args.transform(*trans),
+ self)
+
def _read_events(fobj):
res = []