[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 04/10] trace: [tcg] Add 'tcg' event property
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH v2 04/10] trace: [tcg] Add 'tcg' event property |
Date: |
Wed, 28 May 2014 19:31:55 +0200 |
User-agent: |
StGit/0.17.1-dirty |
Transforms event:
tcg name(...) "...", "..."
into two internal events:
tcg-trans name_trans(...) "..."
tcg-exec name_exec(...) "..."
Signed-off-by: Lluís Vilanova <address@hidden>
---
scripts/tracetool/__init__.py | 64 +++++++++++++++++++++++++++++++---
scripts/tracetool/format/events_h.py | 5 +++
2 files changed, 64 insertions(+), 5 deletions(-)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index bd3fd85..de48c80 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -19,6 +19,7 @@ import weakref
import tracetool.format
import tracetool.backend
+import tracetool.transform
def error_write(*lines):
@@ -137,9 +138,14 @@ class Event(object):
The event arguments.
"""
- _CRE =
re.compile("((?P<props>.*)\s+)?(?P<name>[^(\s]+)\((?P<args>[^)]*)\)\s*(?P<fmt>\".*)?")
+ _CRE = re.compile("((?P<props>.*)\s+)?"
+ "(?P<name>[^(\s]+)"
+ "\((?P<args>[^)]*)\)"
+ "\s*"
+ "(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
+ "\s*")
- _VALID_PROPS = set(["disable"])
+ _VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec"])
def __init__(self, name, props, fmt, args, orig=None):
"""
@@ -149,8 +155,8 @@ class Event(object):
Event name.
props : list of str
Property names.
- fmt : str
- Event printing format.
+ fmt : str, list of str
+ Event printing format (or formats).
args : Arguments
Event arguments.
orig : Event or None
@@ -170,6 +176,7 @@ class Event(object):
if len(unknown_props) > 0:
raise ValueError("Unknown properties: %s"
% ", ".join(unknown_props))
+ assert isinstance(self.fmt, str) or len(self.fmt) == 2
def copy(self):
"""Create a new copy."""
@@ -192,16 +199,32 @@ class Event(object):
name = groups["name"]
props = groups["props"].split()
fmt = groups["fmt"]
+ fmt_trans = groups["fmt_trans"]
+ if len(fmt_trans) > 0:
+ fmt = [fmt_trans, fmt]
args = Arguments.build(groups["args"])
+ if "tcg-trans" in props:
+ raise ValueError("Invalid property 'tcg-trans'")
+ if "tcg-exec" in props:
+ raise ValueError("Invalid property 'tcg-exec'")
+ if "tcg" not in props and not isinstance(fmt, str):
+ raise ValueError("Only events with 'tcg' property can have two
formats")
+ if "tcg" in props and isinstance(fmt, str):
+ raise ValueError("Events with 'tcg' property must have two
formats")
+
return Event(name, props, fmt, args)
def __repr__(self):
"""Evaluable string representation for this object."""
+ if isinstance(self.fmt, str):
+ fmt = self.fmt
+ else:
+ fmt = "%s, %s" % (self.fmt[0], self.fmt[1])
return "Event('%s %s(%s) %s')" % (" ".join(self.properties),
self.name,
self.args,
- self.fmt)
+ fmt)
QEMU_TRACE = "trace_%(name)s"
@@ -300,4 +323,35 @@ def generate(fevents, format, backends,
events = _read_events(fevents)
+ # transform TCG-enabled events
+ new_events = []
+ for event in events:
+ if "tcg" not in event.properties:
+ new_events.append(event)
+ else:
+ event_trans = event.copy()
+ event_trans.name += "_trans"
+ event_trans.properties += ["tcg-trans"]
+ event_trans.fmt = event.fmt[0]
+ args_trans = []
+ for atrans, aorig in zip(
+ event_trans.transform(tracetool.transform.TCG_2_HOST).args,
+ event.args):
+ if atrans == aorig:
+ args_trans.append(atrans)
+ event_trans.args = Arguments(args_trans)
+ event_trans = event_trans.copy()
+
+ event_exec = event.copy()
+ event_exec.name += "_exec"
+ event_exec.properties += ["tcg-exec"]
+ event_exec.fmt = event.fmt[1]
+ event_exec = event_exec.transform(tracetool.transform.TCG_2_HOST)
+
+ new_event = [event_trans, event_exec]
+ event.event_trans, event.event_exec = new_event
+
+ new_events.extend(new_event)
+ events = new_events
+
tracetool.format.generate(events, format, backend)
diff --git a/scripts/tracetool/format/events_h.py
b/scripts/tracetool/format/events_h.py
index 25d913b..9f114a3 100644
--- a/scripts/tracetool/format/events_h.py
+++ b/scripts/tracetool/format/events_h.py
@@ -40,6 +40,11 @@ def generate(events, backend):
enabled = 0
else:
enabled = 1
+ if "tcg-trans" in e.properties:
+ # a single define for the two "sub-events"
+ out('#define TRACE_%(name)s_ENABLED %(enabled)d',
+ name=e.original.original.name.upper(),
+ enabled=enabled)
out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
out('#include "trace/event-internal.h"',
- [Qemu-devel] [PATCH v2 01/10] trace: [tcg] Add documentation, Lluís Vilanova, 2014/05/28
- [Qemu-devel] [PATCH v2 02/10] trace: [tcg] Argument type transformation rules, Lluís Vilanova, 2014/05/28
- [Qemu-devel] [PATCH v2 03/10] trace: [tcg] Argument type transformation machinery, Lluís Vilanova, 2014/05/28
- [Qemu-devel] [PATCH v2 04/10] trace: [tcg] Add 'tcg' event property,
Lluís Vilanova <=
- [Qemu-devel] [PATCH v2 05/10] trace: [tcg] Declare TCG tracing helper routines, Lluís Vilanova, 2014/05/28
- [Qemu-devel] [PATCH v2 06/10] trace: [tcg] Define TCG tracing helper routines, Lluís Vilanova, 2014/05/28
- [Qemu-devel] [PATCH v2 08/10] trace: [tcg] Generate TCG tracing routines, Lluís Vilanova, 2014/05/28
- [Qemu-devel] [PATCH v2 09/10] trace: [tcg] Include event definitions in "trace.h", Lluís Vilanova, 2014/05/28
- [Qemu-devel] [PATCH v2 07/10] trace: [tcg] Include TCG-tracing helpers on all helper.h, Lluís Vilanova, 2014/05/28
- Re: [Qemu-devel] [PATCH v2 01/10] trace: [tcg] Add documentation, Lluís Vilanova, 2014/05/28
- [Qemu-devel] [PATCH v2 10/10] trace: [tcg] Include TCG-tracing header on all targets, Lluís Vilanova, 2014/05/28