qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 07/18] trace: [tcg] Argument type transformation machinery
Date: Tue, 12 Aug 2014 14:37:44 +0100	[thread overview]
Message-ID: <1407850675-11890-8-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>

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 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 e8e8edc..bd3fd85 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 = []
-- 
1.9.3

  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 ` Stefan Hajnoczi [this message]
2014-08-12 13:37 ` [Qemu-devel] [PULL 08/18] trace: [tcg] Add 'tcg' event property Stefan Hajnoczi
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-8-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).