trace: [ust] Fix format string computation in tcg-enabled events
TCG-enabled events start with two format strings. Delay per-argument format computation until requested ('Event.formats'). Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
1ba50f4ea0
commit
2321442920
@ -136,8 +136,7 @@ class Event(object):
|
|||||||
Properties of the event.
|
Properties of the event.
|
||||||
args : Arguments
|
args : Arguments
|
||||||
The event arguments.
|
The event arguments.
|
||||||
arg_fmts : str
|
|
||||||
The format strings for each argument.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_CRE = re.compile("((?P<props>.*)\s+)?"
|
_CRE = re.compile("((?P<props>.*)\s+)?"
|
||||||
@ -146,11 +145,10 @@ class Event(object):
|
|||||||
"\s*"
|
"\s*"
|
||||||
"(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
|
"(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
|
||||||
"\s*")
|
"\s*")
|
||||||
_FMT = re.compile("(%\w+|%.*PRI\S+)")
|
|
||||||
|
|
||||||
_VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec"])
|
_VALID_PROPS = set(["disable", "tcg", "tcg-trans", "tcg-exec"])
|
||||||
|
|
||||||
def __init__(self, name, props, fmt, args, arg_fmts, orig=None):
|
def __init__(self, name, props, fmt, args, orig=None):
|
||||||
"""
|
"""
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
@ -162,8 +160,6 @@ class Event(object):
|
|||||||
Event printing format (or formats).
|
Event printing format (or formats).
|
||||||
args : Arguments
|
args : Arguments
|
||||||
Event arguments.
|
Event arguments.
|
||||||
arg_fmts : list of str
|
|
||||||
Format strings for each argument.
|
|
||||||
orig : Event or None
|
orig : Event or None
|
||||||
Original Event before transformation.
|
Original Event before transformation.
|
||||||
|
|
||||||
@ -172,7 +168,6 @@ class Event(object):
|
|||||||
self.properties = props
|
self.properties = props
|
||||||
self.fmt = fmt
|
self.fmt = fmt
|
||||||
self.args = args
|
self.args = args
|
||||||
self.arg_fmts = arg_fmts
|
|
||||||
|
|
||||||
if orig is None:
|
if orig is None:
|
||||||
self.original = weakref.ref(self)
|
self.original = weakref.ref(self)
|
||||||
@ -210,7 +205,6 @@ class Event(object):
|
|||||||
if len(fmt_trans) > 0:
|
if len(fmt_trans) > 0:
|
||||||
fmt = [fmt_trans, fmt]
|
fmt = [fmt_trans, fmt]
|
||||||
args = Arguments.build(groups["args"])
|
args = Arguments.build(groups["args"])
|
||||||
arg_fmts = Event._FMT.findall(fmt)
|
|
||||||
|
|
||||||
if "tcg-trans" in props:
|
if "tcg-trans" in props:
|
||||||
raise ValueError("Invalid property 'tcg-trans'")
|
raise ValueError("Invalid property 'tcg-trans'")
|
||||||
@ -221,7 +215,7 @@ class Event(object):
|
|||||||
if "tcg" in props and isinstance(fmt, str):
|
if "tcg" in props and isinstance(fmt, str):
|
||||||
raise ValueError("Events with 'tcg' property must have two formats")
|
raise ValueError("Events with 'tcg' property must have two formats")
|
||||||
|
|
||||||
return Event(name, props, fmt, args, arg_fmts)
|
return Event(name, props, fmt, args)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
"""Evaluable string representation for this object."""
|
"""Evaluable string representation for this object."""
|
||||||
@ -234,6 +228,13 @@ class Event(object):
|
|||||||
self.args,
|
self.args,
|
||||||
fmt)
|
fmt)
|
||||||
|
|
||||||
|
_FMT = re.compile("(%\w+|%.*PRI\S+)")
|
||||||
|
|
||||||
|
def formats(self):
|
||||||
|
"""List of argument print formats."""
|
||||||
|
assert not isinstance(self.fmt, list)
|
||||||
|
return self._FMT.findall(self.fmt)
|
||||||
|
|
||||||
QEMU_TRACE = "trace_%(name)s"
|
QEMU_TRACE = "trace_%(name)s"
|
||||||
QEMU_TRACE_TCG = QEMU_TRACE + "_tcg"
|
QEMU_TRACE_TCG = QEMU_TRACE + "_tcg"
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ def generate(events, backend):
|
|||||||
|
|
||||||
types = e.args.types()
|
types = e.args.types()
|
||||||
names = e.args.names()
|
names = e.args.names()
|
||||||
fmts = e.arg_fmts
|
fmts = e.formats()
|
||||||
for t,n,f in zip(types, names, fmts):
|
for t,n,f in zip(types, names, fmts):
|
||||||
if ('char *' in t) or ('char*' in t):
|
if ('char *' in t) or ('char*' in t):
|
||||||
out(' ctf_string(' + n + ', ' + n + ')')
|
out(' ctf_string(' + n + ', ' + n + ')')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user