[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/12] trace: [tracetool] Allow argument types to be
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH 05/12] trace: [tracetool] Allow argument types to be transformed |
Date: |
Fri, 31 Jan 2014 17:09:30 +0100 |
User-agent: |
StGit/0.16 |
Signed-off-by: Lluís Vilanova <address@hidden>
---
scripts/tracetool/__init__.py | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 1170aab..aab6d31 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -15,6 +15,7 @@ __email__ = "address@hidden"
import re
import sys
+import weakref
import tracetool.format
import tracetool.backend
@@ -105,6 +106,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.
@@ -125,7 +138,7 @@ class Event(object):
_VALID_PROPS = set(["disable", "tcg"])
- def __init__(self, name, props, fmt, args):
+ def __init__(self, name, props, fmt, args, orig=None):
"""
Parameters
----------
@@ -137,12 +150,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" % ",
".join(unknown_props))
@@ -181,6 +201,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,
+ self.properties,
+ self.fmt,
+ self.args.transform(*trans),
+ self)
+
def _read_events(fobj):
res = []
- [Qemu-devel] [PATCH 00/12] trace: [tcg] Allow tracing guest events in TCG-generated code, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 01/12] trace: [tcg] Add documentation, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 02/12] trace: [tracetool, tcg] Allow TCG types in trace event declarations, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 03/12] trace: [tracetool] Add method 'Event.api' to get the name of public routines, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 04/12] trace: [tracetool, tcg] Provide TCG-related type transformation rules, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 05/12] trace: [tracetool] Allow argument types to be transformed,
Lluís Vilanova <=
- [Qemu-devel] [PATCH 06/12] trace: [tcg] Declare TCG tracing helper routines, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 07/12] trace: [tcg] Define TCG tracing helper routines, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 09/12] trace: [tcg] Generate TCG tracing routines, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 10/12] trace: [trivial] Include event definitions in "trace.h", Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 12/12] trace: [all] Add "guest_vmem" event, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 11/12] trace: [tcg] Include TCG-tracing header on all targets, Lluís Vilanova, 2014/01/31
- [Qemu-devel] [PATCH 08/12] trace: [tcg] Include TCG-tracing helpers on all helper.h, Lluís Vilanova, 2014/01/31