Patchwork [1/3] trace: Relax trace-events parsing regex in simpletrace.py

login
register
mail settings
Submitter Stefan Hajnoczi
Date Oct. 18, 2010, 12:42 p.m.
Message ID <1287405776-19651-2-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/68176/
State New
Headers show

Comments

Stefan Hajnoczi - Oct. 18, 2010, 12:42 p.m.
The regular expression to parse trace event definitions assumed the
format string would be a simple double-quoted string.  However, we now
use PRI?64 for portability which splits string literals.  The regular
expression can disregard the format string entirely since simpletrace.py
never needs to use it.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 simpletrace.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Blue Swirl - Oct. 20, 2010, 4:49 p.m.
Thanks, applied all.

On Mon, Oct 18, 2010 at 12:42 PM, Stefan Hajnoczi
<stefanha@linux.vnet.ibm.com> wrote:
> The regular expression to parse trace event definitions assumed the
> format string would be a simple double-quoted string.  However, we now
> use PRI?64 for portability which splits string literals.  The regular
> expression can disregard the format string entirely since simpletrace.py
> never needs to use it.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> ---
>  simpletrace.py |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/simpletrace.py b/simpletrace.py
> index c2cf168..553a727 100755
> --- a/simpletrace.py
> +++ b/simpletrace.py
> @@ -19,7 +19,7 @@ header_version  = 0
>
>  trace_fmt = '=QQQQQQQQ'
>  trace_len = struct.calcsize(trace_fmt)
> -event_re  = re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\)\s+"([^"]*)"')
> +event_re  = re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\).*')
>
>  def err(msg):
>     sys.stderr.write(msg + '\n')
> @@ -39,7 +39,7 @@ def parse_events(fobj):
>         if m is None:
>             continue
>
> -        disable, name, args, fmt = m.groups()
> +        disable, name, args = m.groups()
>         events[event_num] = (name,) + get_argnames(args)
>         event_num += 1
>     return events
> --
> 1.7.1
>
>

Patch

diff --git a/simpletrace.py b/simpletrace.py
index c2cf168..553a727 100755
--- a/simpletrace.py
+++ b/simpletrace.py
@@ -19,7 +19,7 @@  header_version  = 0
 
 trace_fmt = '=QQQQQQQQ'
 trace_len = struct.calcsize(trace_fmt)
-event_re  = re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\)\s+"([^"]*)"')
+event_re  = re.compile(r'(disable\s+)?([a-zA-Z0-9_]+)\(([^)]*)\).*')
 
 def err(msg):
     sys.stderr.write(msg + '\n')
@@ -39,7 +39,7 @@  def parse_events(fobj):
         if m is None:
             continue
 
-        disable, name, args, fmt = m.groups()
+        disable, name, args = m.groups()
         events[event_num] = (name,) + get_argnames(args)
         event_num += 1
     return events