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>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 16/18] trace: teach lttng backend to use format strings
Date: Tue, 12 Aug 2014 14:37:53 +0100	[thread overview]
Message-ID: <1407850675-11890-17-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1407850675-11890-1-git-send-email-stefanha@redhat.com>

From: Alex Bennée <alex.bennee@linaro.org>

This makes the UST backend pay attention to the format string arguments
that are defined when defining payload data. With this you can now
ensure integers are reported in hex mode if you want.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 scripts/tracetool/__init__.py            | 12 ++++++++++--
 scripts/tracetool/format/ust_events_h.py | 15 +++++++++++----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index a51e0f2..36c789d 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -136,6 +136,8 @@ class Event(object):
         Properties of the event.
     args : Arguments
         The event arguments.
+    arg_fmts : str
+        The format strings for each argument.
     """
 
     _CRE = re.compile("((?P<props>.*)\s+)?"
@@ -144,10 +146,11 @@ class Event(object):
                       "\s*"
                       "(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
                       "\s*")
+    _FMT = re.compile("(%\w+|%.*PRI\S+)")
 
     _VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec"])
 
-    def __init__(self, name, props, fmt, args, orig=None):
+    def __init__(self, name, props, fmt, args, arg_fmts, orig=None):
         """
         Parameters
         ----------
@@ -159,13 +162,17 @@ class Event(object):
             Event printing format (or formats).
         args : Arguments
             Event arguments.
+        arg_fmts : list of str
+            Format strings for each argument.
         orig : Event or None
             Original Event before transformation.
+
         """
         self.name = name
         self.properties = props
         self.fmt = fmt
         self.args = args
+        self.arg_fmts = arg_fmts
 
         if orig is None:
             self.original = weakref.ref(self)
@@ -203,6 +210,7 @@ class Event(object):
         if len(fmt_trans) > 0:
             fmt = [fmt_trans, fmt]
         args = Arguments.build(groups["args"])
+        arg_fmts = Event._FMT.findall(fmt)
 
         if "tcg-trans" in props:
             raise ValueError("Invalid property 'tcg-trans'")
@@ -213,7 +221,7 @@ class Event(object):
         if "tcg" in props and isinstance(fmt, str):
             raise ValueError("Events with 'tcg' property must have two formats")
 
-        return Event(name, props, fmt, args)
+        return Event(name, props, fmt, args, arg_fmts)
 
     def __repr__(self):
         """Evaluable string representation for this object."""
diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/format/ust_events_h.py
index 5102565..d189899 100644
--- a/scripts/tracetool/format/ust_events_h.py
+++ b/scripts/tracetool/format/ust_events_h.py
@@ -63,13 +63,20 @@ def generate(events, backend):
                 name=e.name,
                 args=", ".join(", ".join(i) for i in e.args))
 
-            for t, n in e.args:
-                if ('int' in t) or ('long' in t) or ('unsigned' in t) or ('size_t' in t):
+            types = e.args.types()
+            names = e.args.names()
+            fmts = e.arg_fmts
+            for t,n,f in zip(types, names, fmts):
+                if ('char *' in t) or ('char*' in t):
+                    out('       ctf_string(' + n + ', ' + n + ')')
+                elif ("%p" in f) or ("x" in f) or ("PRIx" in f):
+                    out('       ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
+                elif ("ptr" in t) or ("*" in t):
+                    out('       ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
+                elif ('int' in t) or ('long' in t) or ('unsigned' in t) or ('size_t' in t):
                     out('       ctf_integer(' + t + ', ' + n + ', ' + n + ')')
                 elif ('double' in t) or ('float' in t):
                     out('       ctf_float(' + t + ', ' + n + ', ' + n + ')')
-                elif ('char *' in t) or ('char*' in t):
-                    out('       ctf_string(' + n + ', ' + n + ')')
                 elif ('void *' in t) or ('void*' in t):
                     out('       ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')
 
-- 
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 ` [Qemu-devel] [PULL 07/18] trace: [tcg] Argument type transformation machinery Stefan Hajnoczi
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 ` Stefan Hajnoczi [this message]
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-17-git-send-email-stefanha@redhat.com \
    --to=stefanha@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).