* [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
@ 2014-03-24 17:04 alex.bennee
2014-03-24 17:35 ` alex.bennee
2014-03-25 9:56 ` Stefan Hajnoczi
0 siblings, 2 replies; 8+ messages in thread
From: alex.bennee @ 2014-03-24 17:04 UTC (permalink / raw)
To: qemu-devel
Cc: Mohamad Gebai, Alex Bennée, vilanova, stefanha,
mohamad.gebai
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
2014-03-24 17:04 [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings alex.bennee
@ 2014-03-24 17:35 ` alex.bennee
2014-03-24 17:42 ` Eric Blake
2014-03-27 8:42 ` Stefan Hajnoczi
2014-03-25 9:56 ` Stefan Hajnoczi
1 sibling, 2 replies; 8+ messages in thread
From: alex.bennee @ 2014-03-24 17:35 UTC (permalink / raw)
To: qemu-devel
Cc: Mohamad Gebai, Alex Bennée, vilanova, stefanha,
mohamad.gebai
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>
---
v2
- remove silly debug statements
---
scripts/tracetool/__init__.py | 12 ++++++++++--
scripts/tracetool/backend/ust.py | 17 ++++++++++++-----
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 175df08..71e2ab5 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,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/backend/ust.py b/scripts/tracetool/backend/ust.py
index 41c1c75..6223f20 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -56,13 +56,20 @@ 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
+ 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 + ')')
@@ -79,4 +86,4 @@ def ust_events_h(events):
')',
'',
name = e.name,
- )
\ No newline at end of file
+ )
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
2014-03-24 17:35 ` alex.bennee
@ 2014-03-24 17:42 ` Eric Blake
2014-03-27 8:42 ` Stefan Hajnoczi
1 sibling, 0 replies; 8+ messages in thread
From: Eric Blake @ 2014-03-24 17:42 UTC (permalink / raw)
To: alex.bennee, qemu-devel; +Cc: Mohamad Gebai, vilanova, stefanha, mohamad.gebai
[-- Attachment #1: Type: text/plain, Size: 647 bytes --]
On 03/24/2014 11:35 AM, alex.bennee@linaro.org wrote:
> 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>
>
> ---
> args : Arguments
> The event arguments.
> + arg_fmts : str
> + The format strings for each arugment.
s/arugment/argument/
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
2014-03-24 17:04 [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings alex.bennee
2014-03-24 17:35 ` alex.bennee
@ 2014-03-25 9:56 ` Stefan Hajnoczi
2014-03-25 14:49 ` Alex Bennée
1 sibling, 1 reply; 8+ messages in thread
From: Stefan Hajnoczi @ 2014-03-25 9:56 UTC (permalink / raw)
To: alex.bennee; +Cc: Mohamad Gebai, mohamad.gebai, qemu-devel, vilanova
On Mon, Mar 24, 2014 at 05:04:54PM +0000, alex.bennee@linaro.org wrote:
> 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(-)
How are strings handled, can LTTng copy them from the QEMU process'
memory space?
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
2014-03-25 9:56 ` Stefan Hajnoczi
@ 2014-03-25 14:49 ` Alex Bennée
2014-03-26 8:27 ` Stefan Hajnoczi
0 siblings, 1 reply; 8+ messages in thread
From: Alex Bennée @ 2014-03-25 14:49 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Mohamad Gebai, mohamad.gebai, qemu-devel, vilanova
Stefan Hajnoczi <stefanha@redhat.com> writes:
> On Mon, Mar 24, 2014 at 05:04:54PM +0000, alex.bennee@linaro.org wrote:
>> 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(-)
>
> How are strings handled, can LTTng copy them from the QEMU process'
> memory space?
lttng provides ctf_string for passing strings to the payload. But I
wouldn't expect to use them for the result of format string calculations
as that would defeat the point of the low impact tracing.
There are a number of trace-events that pass strings for various things.
I've not actually experimented with the output of any of them though.
>
> Stefan
--
Alex Bennée
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
2014-03-25 14:49 ` Alex Bennée
@ 2014-03-26 8:27 ` Stefan Hajnoczi
2014-03-26 15:45 ` Mohamad Gebai
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Hajnoczi @ 2014-03-26 8:27 UTC (permalink / raw)
To: Alex Bennée; +Cc: Mohamad Gebai, mohamad.gebai, qemu-devel, vilanova
On Tue, Mar 25, 2014 at 02:49:42PM +0000, Alex Bennée wrote:
>
> Stefan Hajnoczi <stefanha@redhat.com> writes:
>
> > On Mon, Mar 24, 2014 at 05:04:54PM +0000, alex.bennee@linaro.org wrote:
> >> 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(-)
> >
> > How are strings handled, can LTTng copy them from the QEMU process'
> > memory space?
>
> lttng provides ctf_string for passing strings to the payload. But I
> wouldn't expect to use them for the result of format string calculations
> as that would defeat the point of the low impact tracing.
>
> There are a number of trace-events that pass strings for various things.
> I've not actually experimented with the output of any of them though.
Sounds like it should work but can you test it? Try enabling the
bdrv_open_common() trace event when booting a guest. You should see the
filename of the disk image file.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
2014-03-26 8:27 ` Stefan Hajnoczi
@ 2014-03-26 15:45 ` Mohamad Gebai
0 siblings, 0 replies; 8+ messages in thread
From: Mohamad Gebai @ 2014-03-26 15:45 UTC (permalink / raw)
To: Stefan Hajnoczi, Alex Bennée; +Cc: mohamad.gebai, qemu-devel, vilanova
I can confirm that it works for me, I can see the disk image file name
in the payload of brdv_open_common events.
Mohamad
On 03/26/2014 04:27 AM, Stefan Hajnoczi wrote:
> On Tue, Mar 25, 2014 at 02:49:42PM +0000, Alex Bennée wrote:
>> Stefan Hajnoczi <stefanha@redhat.com> writes:
>>
>>> On Mon, Mar 24, 2014 at 05:04:54PM +0000, alex.bennee@linaro.org wrote:
>>>> 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(-)
>>> How are strings handled, can LTTng copy them from the QEMU process'
>>> memory space?
>> lttng provides ctf_string for passing strings to the payload. But I
>> wouldn't expect to use them for the result of format string calculations
>> as that would defeat the point of the low impact tracing.
>>
>> There are a number of trace-events that pass strings for various things.
>> I've not actually experimented with the output of any of them though.
> Sounds like it should work but can you test it? Try enabling the
> bdrv_open_common() trace event when booting a guest. You should see the
> filename of the disk image file.
>
> Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings
2014-03-24 17:35 ` alex.bennee
2014-03-24 17:42 ` Eric Blake
@ 2014-03-27 8:42 ` Stefan Hajnoczi
1 sibling, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2014-03-27 8:42 UTC (permalink / raw)
To: alex.bennee; +Cc: Mohamad Gebai, mohamad.gebai, qemu-devel, stefanha, vilanova
On Mon, Mar 24, 2014 at 05:35:26PM +0000, alex.bennee@linaro.org wrote:
> 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>
>
> ---
>
> v2
> - remove silly debug statements
> ---
> scripts/tracetool/__init__.py | 12 ++++++++++--
> scripts/tracetool/backend/ust.py | 17 ++++++++++++-----
> 2 files changed, 22 insertions(+), 7 deletions(-)
This conflicts with Lluis' tracing cleanup patch series that is merged
for QEMU 2.1.
Please rebase on:
git://github.com/stefanha/qemu.git tracing-next
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-03-27 8:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-24 17:04 [Qemu-devel] [PATCH] trace: teach lttng backend to use format strings alex.bennee
2014-03-24 17:35 ` 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
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).