qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: stefanha@redhat.com
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	qemu-devel@nongnu.org, mohamad.gebai@gmail.com
Subject: [Qemu-devel] [PATCH v2 1/3] trace: teach lttng backend to use format strings
Date: Tue, 15 Jul 2014 12:42:19 +0100	[thread overview]
Message-ID: <1405424541-21803-2-git-send-email-alex.bennee@linaro.org> (raw)
In-Reply-To: <1405424541-21803-1-git-send-email-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>

---

v2
  - remove silly debug statements

v3
  - fix spelling
  - rebase to latest tracetool

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index eccf552..0a65d6a 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -122,13 +122,16 @@ 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+)?(?P<name>[^(\s]+)\((?P<args>[^)]*)\)\s*(?P<fmt>\".*)?")
+    _FMT = re.compile("(%\w+|%.*PRI\S+)")
 
     _VALID_PROPS = set(["disable"])
 
-    def __init__(self, name, props, fmt, args):
+    def __init__(self, name, props, fmt, args, arg_fmts):
         """
         Parameters
         ----------
@@ -140,11 +143,15 @@ class Event(object):
             Event printing format.
         args : Arguments
             Event arguments.
+        arg_fmts : list of str
+            Format strings for each argument.
+
         """
         self.name = name
         self.properties = props
         self.fmt = fmt
         self.args = args
+        self.arg_fmts = arg_fmts
 
         unknown_props = set(self.properties) - self._VALID_PROPS
         if len(unknown_props) > 0:
@@ -173,8 +180,9 @@ class Event(object):
         props = groups["props"].split()
         fmt = groups["fmt"]
         args = Arguments.build(groups["args"])
+        arg_fmts = Event._FMT.findall(fmt)
 
-        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 + ')')
 
-- 
2.0.1

  reply	other threads:[~2014-07-15 11:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15 11:42 [Qemu-devel] [PATCH v2 0/3] some TCG related trace patches Alex Bennée
2014-07-15 11:42 ` Alex Bennée [this message]
2014-08-01  9:05   ` [Qemu-devel] [PATCH v2 1/3] trace: teach lttng backend to use format strings Alex Bennée
2014-08-01 12:54     ` Stefan Hajnoczi
2014-07-15 11:42 ` [Qemu-devel] [PATCH v2 2/3] trace: add some tcg tracing support Alex Bennée
2014-07-15 11:42 ` [Qemu-devel] [PATCH v2 3/3] trace: instrument and trace tcg tb flush activity Alex Bennée
2014-07-15 12:15   ` Andreas Färber
2014-07-15 13:12     ` Alex Bennée
2014-07-15 12:23   ` Peter Maydell
2014-07-15 13:07     ` Peter Maydell
2014-07-15 13:10     ` Alex Bennée
2014-07-15 13:19   ` Paolo Bonzini
2014-07-15 14:16     ` Alex Bennée
2014-07-15 20:11       ` Paolo Bonzini
2014-07-15 20:29         ` Peter Maydell
2014-07-15 20:38           ` Paolo Bonzini

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=1405424541-21803-2-git-send-email-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=mohamad.gebai@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).