From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Lluís Vilanova" <vilanova@ac.upc.edu>,
"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 08/18] trace: [tcg] Add 'tcg' event property
Date: Tue, 12 Aug 2014 14:37:45 +0100 [thread overview]
Message-ID: <1407850675-11890-9-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1407850675-11890-1-git-send-email-stefanha@redhat.com>
From: Lluís Vilanova <vilanova@ac.upc.edu>
Transforms event:
tcg name(...) "...", "..."
into two internal events:
tcg-trans name_trans(...) "..."
tcg-exec name_exec(...) "..."
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
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"',
--
1.9.3
next prev parent reply other threads:[~2014-08-12 13:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-12 13:37 [Qemu-devel] [PULL 00/18] Tracing patches Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 01/18] trace: extract stap_escape() function for reuse Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 02/18] trace: add tracetool simpletrace_stap format Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 03/18] simpletrace: add simpletrace.py --no-header option Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 04/18] trace: install simpletrace SystemTap tapset Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 05/18] trace: [tcg] Add documentation Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 06/18] trace: [tcg] Argument type transformation rules Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 07/18] trace: [tcg] Argument type transformation machinery Stefan Hajnoczi
2014-08-12 13:37 ` Stefan Hajnoczi [this message]
2014-08-12 13:37 ` [Qemu-devel] [PULL 09/18] trace: [tcg] Declare TCG tracing helper routines Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 10/18] trace: [tcg] Define " Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 11/18] trace: [tcg] Define TCG tracing helper routine wrappers Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 12/18] trace: [tcg] Include TCG-tracing helpers Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 13/18] trace: [tcg] Generate TCG tracing routines Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 14/18] trace: [tcg] Include event definitions in "trace.h" Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 15/18] trace: [tcg] Include TCG-tracing header on all targets Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 16/18] trace: teach lttng backend to use format strings Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 17/18] trace: add some tcg tracing support Stefan Hajnoczi
2014-08-12 13:37 ` [Qemu-devel] [PULL 18/18] virtio-rng: add some trace events Stefan Hajnoczi
2014-08-15 16:43 ` [Qemu-devel] [PULL 00/18] Tracing patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407850675-11890-9-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=vilanova@ac.upc.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).