From: alex.bennee@linaro.org
To: qemu-devel@nongnu.org
Cc: "Mohamad Gebai" <mohamad.gebai@polymtl.ca>,
"Alex Bennée" <alex.bennee@linaro.org>,
vilanova@ac.upc.edu, stefanha@redhat.com,
mohamad.gebai@gmail.com
Subject: [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
Date: Mon, 24 Mar 2014 17:04:54 +0000 [thread overview]
Message-ID: <1395680694-27758-1-git-send-email-alex.bennee@linaro.org> (raw)
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>
---
scripts/tracetool/__init__.py | 13 +++++++++++--
scripts/tracetool/backend/ust.py | 16 ++++++++++++----
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 175df08..abcdc49 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -118,13 +118,16 @@ class Event(object):
Properties of the event.
args : Arguments
The event arguments.
+ arg_fmts : str
+ The format strings for each arugment.
"""
_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
----------
@@ -136,11 +139,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:
@@ -163,8 +170,10 @@ class Event(object):
props = groups["props"].split()
fmt = groups["fmt"]
args = Arguments.build(groups["args"])
+ print "%s: %s and %s" % (name, args, fmt)
+ 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/backend/ust.py b/scripts/tracetool/backend/ust.py
index 41c1c75..cb09958 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -56,13 +56,21 @@ def ust_events_h(events):
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
+ print "/* %s/%s/%s */" % (types, names, 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.1
next reply other threads:[~2014-03-24 17:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 17:04 alex.bennee [this message]
2014-03-24 17:35 ` [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings alex.bennee
2014-03-24 17:42 ` Eric Blake
2014-03-27 8:42 ` Stefan Hajnoczi
2014-03-25 9:56 ` Stefan Hajnoczi
2014-03-25 14:49 ` Alex Bennée
2014-03-26 8:27 ` Stefan Hajnoczi
2014-03-26 15:45 ` Mohamad Gebai
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=1395680694-27758-1-git-send-email-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=mohamad.gebai@gmail.com \
--cc=mohamad.gebai@polymtl.ca \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--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).