Skip to contentSkip to conversation

tracing: QEMU 1.1-rc3+ fixes

PATCH In review Stefan Hajnoczi 2 participants 4 messages May 22, 2012

lore
Share & tools
lore
#0 lore raw

cover tracing: QEMU 1.1-rc3+ fixes

Two issues have been reported with the new tracetool Python rewrite:

1. Using parenthesis in ./trace-events format strings produces an exception from tracetool.py.

2. The 'simple' trace backend event numbering is wrong when the ./trace-events file contains disabled events (this is the case by default).

These patches fix these issues.

Stefan Hajnoczi (2):
simpletrace: skip disabled trace event numbering
tracetool: allow parenthesis in trace-events format strings

 scripts/simpletrace.py        |    5 +++--
 scripts/tracetool/__init__.py |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.10
#1 lore raw

PATCH 1/2 simpletrace: skip disabled trace event numbering

The simple trace code generator has been rewritten for QEMU 1.1 and now assigns event numbers only to enabled events. This means we must skip disabled events when pretty-printing traces in simpletrace.py.

Note this means old binary traces may be pretty printed incorrectly since they use a different event numbering when the "disable" keyword is present in ./trace-events. It's unfortunate but not easy to avoid at this stage. Always use the simpletrace.py that came with the QEMU binary to ensure correctly pretty-printing.

---
 scripts/simpletrace.py |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
scripts/simpletrace.py +3 -2
index f55e5e6..db39b02 100755
@@ -37,8 +37,9 @@ def parse_events(fobj):
             continue
 
         disable, name, args = m.groups()
-        events[event_num] = (name,) + get_argnames(args)
-        event_num += 1
+        if not disable:
+            events[event_num] = (name,) + get_argnames(args)
+            event_num += 1
     return events
 
 def read_record(fobj):
Signature · 1 line
1.7.10
#2 lore raw

PATCH 2/2 tracetool: allow parenthesis in trace-events format strings

In reply to Stefan Hajnoczi

The regular expression used to parse ./trace-events fails on the following input:

test_paren(int n) "(%d)"

The problem is that the regular expression uses greedy matching and '"' becomes the name of the event while 'test_paren(int n) ' becomes the properties of the event.

Prevent greedy matching from going too far by explicitly saying the name cannot have a '"'. This forces the regular expression engine to backtrack to the desired match.

---
 scripts/tracetool/__init__.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tracetool/__init__.py +1 -1
index 175df08..148f553 100644
@@ -120,7 +120,7 @@ class Event(object):
         The event arguments.
     """
 
-    _CRE = re.compile("((?P<props>.*)\s+)?(?P<name>[^(\s]+)\((?P<args>[^)]*)\)\s*(?P<fmt>\".*)?")
+    _CRE = re.compile("((?P<props>.*)\s+)?(?P<name>[^\"(\s]+)\((?P<args>[^)]*)\)\s*(?P<fmt>\".*)?")
 
     _VALID_PROPS = set(["disable"])
 
Signature · 1 line
1.7.10
Reviewed-by on v1 2/2
#3 lore raw

Re: [Qemu-devel] [PATCH 1.1 2/2] tracetool: allow parenthesis in trace-events format strings

Quoted 9 lines · Stefan Hajnoczi

The regular expression used to parse ./trace-events fails on the following input:

test_paren(int n) "(%d)"

The problem is that the regular expression uses greedy matching and '"' becomes the name of the event while 'test_paren(int n) ' becomes the properties of the event.

Quoted 6 lines

Prevent greedy matching from going too far by explicitly saying the name cannot have a '"'. This forces the regular expression engine to backtrack to the desired match.

Quoted 19 lines
---
 scripts/tracetool/__init__.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tracetool/__init__.py +1 -1
index 175df08..148f553 100644
@@ -120,7 +120,7 @@ class Event(object):
         The event arguments.
     """
 
-    _CRE = re.compile("((?P<props>.*)\s+)?(?P<name>[^(\s]+)\((?P<args>[^)]*)\)\s*(?P<fmt>\".*)?")
+    _CRE = re.compile("((?P<props>.*)\s+)?(?P<name>[^\"(\s]+)\((?P<args>[^)]*)\)\s*(?P<fmt>\".*)?")
 
     _VALID_PROPS = set(["disable"])
 
Signature · 1 line
1.7.10
Signature · 4 lines
 "And it's much the same thing with knowledge, for whenever you learn
 something new, the whole world becomes that much richer."
 -- The Princess of Pure Reason, as told by Norton Juster in The Phantom
 Tollbooth