qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] trace: tighten up trace-events regex to fix bad parse
@ 2014-09-22 16:15 Stefan Hajnoczi
  2014-09-22 17:35 ` Lluís Vilanova
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-09-22 16:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: Lluís Vilanova, Stefan Hajnoczi, Eric Auger

Use \w for properties and trace event names since they are both drawn
from [a-zA-Z0-9_] character sets.

The .* for matching properties was too aggressive and caused the
following failure with foo(int rc) "(this is a test)":

  Traceback (most recent call last):
    File "scripts/tracetool.py", line 139, in <module>
      main(sys.argv)
    File "scripts/tracetool.py", line 134, in main
      binary=binary, probe_prefix=probe_prefix)
    File "scripts/tracetool/__init__.py", line 334, in generate
      events = _read_events(fevents)
    File "scripts/tracetool/__init__.py", line 262, in _read_events
      res.append(Event.build(line))
    File "scripts/tracetool/__init__.py", line 225, in build
      return Event(name, props, fmt, args, arg_fmts)
    File "scripts/tracetool/__init__.py", line 185, in __init__
      % ", ".join(unknown_props))
  ValueError: Unknown properties: foo(int, rc)

Cc: Lluís Vilanova <vilanova@ac.upc.edu>
Reported-by: Eric Auger <eric.auger@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 scripts/tracetool/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 36c789d..474f11b 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -140,8 +140,8 @@ class Event(object):
         The format strings for each argument.
     """
 
-    _CRE = re.compile("((?P<props>.*)\s+)?"
-                      "(?P<name>[^(\s]+)"
+    _CRE = re.compile("((?P<props>\w*)\s+)?"
+                      "(?P<name>\w+)"
                       "\((?P<args>[^)]*)\)"
                       "\s*"
                       "(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] trace: tighten up trace-events regex to fix bad parse
  2014-09-22 16:15 [Qemu-devel] [PATCH] trace: tighten up trace-events regex to fix bad parse Stefan Hajnoczi
@ 2014-09-22 17:35 ` Lluís Vilanova
  2014-09-23  4:33   ` Eric Auger
  2014-09-23 10:33   ` Stefan Hajnoczi
  0 siblings, 2 replies; 4+ messages in thread
From: Lluís Vilanova @ 2014-09-22 17:35 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, Eric Auger

Stefan Hajnoczi writes:

> Use \w for properties and trace event names since they are both drawn
> from [a-zA-Z0-9_] character sets.

> The .* for matching properties was too aggressive and caused the
> following failure with foo(int rc) "(this is a test)":

>   Traceback (most recent call last):
>     File "scripts/tracetool.py", line 139, in <module>
>       main(sys.argv)
>     File "scripts/tracetool.py", line 134, in main
>       binary=binary, probe_prefix=probe_prefix)
>     File "scripts/tracetool/__init__.py", line 334, in generate
>       events = _read_events(fevents)
>     File "scripts/tracetool/__init__.py", line 262, in _read_events
>       res.append(Event.build(line))
>     File "scripts/tracetool/__init__.py", line 225, in build
>       return Event(name, props, fmt, args, arg_fmts)
>     File "scripts/tracetool/__init__.py", line 185, in __init__
>       % ", ".join(unknown_props))
>   ValueError: Unknown properties: foo(int, rc)

> Cc: Lluís Vilanova <vilanova@ac.upc.edu>
> Reported-by: Eric Auger <eric.auger@linaro.org>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  scripts/tracetool/__init__.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

> diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
> index 36c789d..474f11b 100644
> --- a/scripts/tracetool/__init__.py
> +++ b/scripts/tracetool/__init__.py
> @@ -140,8 +140,8 @@ class Event(object):
>          The format strings for each argument.
>      """
 
> -    _CRE = re.compile("((?P<props>.*)\s+)?"
> -                      "(?P<name>[^(\s]+)"
> +    _CRE = re.compile("((?P<props>\w*)\s+)?"
> +                      "(?P<name>\w+)"
>                        "\((?P<args>[^)]*)\)"
>                        "\s*"
>                        "(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"

The previous implementation allowed multiple properties. Maybe this should be
instead (which still allows multiple properties):

    "((?P<props>[\w\s]+)\s+)?"
    "(?P<name>\w+)\s*"
    ...


Thanks,
  Lluis

-- 
 "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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] trace: tighten up trace-events regex to fix bad parse
  2014-09-22 17:35 ` Lluís Vilanova
@ 2014-09-23  4:33   ` Eric Auger
  2014-09-23 10:33   ` Stefan Hajnoczi
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Auger @ 2014-09-23  4:33 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel, vilanova, Alexander Graf

Dear all,

Many thanks for the fix. I am currently travelling but I will test it
early next week with vfio PCI & platform case. Also following Alex
advises, I will move [RFC] vfio: migration to trace points into a PATCH.

Best Regards

Eric


On 09/22/2014 07:35 PM, Lluís Vilanova wrote:
> Stefan Hajnoczi writes:
> 
>> Use \w for properties and trace event names since they are both drawn
>> from [a-zA-Z0-9_] character sets.
> 
>> The .* for matching properties was too aggressive and caused the
>> following failure with foo(int rc) "(this is a test)":
> 
>>   Traceback (most recent call last):
>>     File "scripts/tracetool.py", line 139, in <module>
>>       main(sys.argv)
>>     File "scripts/tracetool.py", line 134, in main
>>       binary=binary, probe_prefix=probe_prefix)
>>     File "scripts/tracetool/__init__.py", line 334, in generate
>>       events = _read_events(fevents)
>>     File "scripts/tracetool/__init__.py", line 262, in _read_events
>>       res.append(Event.build(line))
>>     File "scripts/tracetool/__init__.py", line 225, in build
>>       return Event(name, props, fmt, args, arg_fmts)
>>     File "scripts/tracetool/__init__.py", line 185, in __init__
>>       % ", ".join(unknown_props))
>>   ValueError: Unknown properties: foo(int, rc)
> 
>> Cc: Lluís Vilanova <vilanova@ac.upc.edu>
>> Reported-by: Eric Auger <eric.auger@linaro.org>
>> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>> ---
>>  scripts/tracetool/__init__.py | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
>> diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
>> index 36c789d..474f11b 100644
>> --- a/scripts/tracetool/__init__.py
>> +++ b/scripts/tracetool/__init__.py
>> @@ -140,8 +140,8 @@ class Event(object):
>>          The format strings for each argument.
>>      """
>  
>> -    _CRE = re.compile("((?P<props>.*)\s+)?"
>> -                      "(?P<name>[^(\s]+)"
>> +    _CRE = re.compile("((?P<props>\w*)\s+)?"
>> +                      "(?P<name>\w+)"
>>                        "\((?P<args>[^)]*)\)"
>>                        "\s*"
>>                        "(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
> 
> The previous implementation allowed multiple properties. Maybe this should be
> instead (which still allows multiple properties):
> 
>     "((?P<props>[\w\s]+)\s+)?"
>     "(?P<name>\w+)\s*"
>     ...
> 
> 
> Thanks,
>   Lluis
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] trace: tighten up trace-events regex to fix bad parse
  2014-09-22 17:35 ` Lluís Vilanova
  2014-09-23  4:33   ` Eric Auger
@ 2014-09-23 10:33   ` Stefan Hajnoczi
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-09-23 10:33 UTC (permalink / raw)
  To: qemu-devel, Eric Auger

[-- Attachment #1: Type: text/plain, Size: 2299 bytes --]

On Mon, Sep 22, 2014 at 12:35:22PM -0500, Lluís Vilanova wrote:
> Stefan Hajnoczi writes:
> 
> > Use \w for properties and trace event names since they are both drawn
> > from [a-zA-Z0-9_] character sets.
> 
> > The .* for matching properties was too aggressive and caused the
> > following failure with foo(int rc) "(this is a test)":
> 
> >   Traceback (most recent call last):
> >     File "scripts/tracetool.py", line 139, in <module>
> >       main(sys.argv)
> >     File "scripts/tracetool.py", line 134, in main
> >       binary=binary, probe_prefix=probe_prefix)
> >     File "scripts/tracetool/__init__.py", line 334, in generate
> >       events = _read_events(fevents)
> >     File "scripts/tracetool/__init__.py", line 262, in _read_events
> >       res.append(Event.build(line))
> >     File "scripts/tracetool/__init__.py", line 225, in build
> >       return Event(name, props, fmt, args, arg_fmts)
> >     File "scripts/tracetool/__init__.py", line 185, in __init__
> >       % ", ".join(unknown_props))
> >   ValueError: Unknown properties: foo(int, rc)
> 
> > Cc: Lluís Vilanova <vilanova@ac.upc.edu>
> > Reported-by: Eric Auger <eric.auger@linaro.org>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  scripts/tracetool/__init__.py | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> > diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
> > index 36c789d..474f11b 100644
> > --- a/scripts/tracetool/__init__.py
> > +++ b/scripts/tracetool/__init__.py
> > @@ -140,8 +140,8 @@ class Event(object):
> >          The format strings for each argument.
> >      """
>  
> > -    _CRE = re.compile("((?P<props>.*)\s+)?"
> > -                      "(?P<name>[^(\s]+)"
> > +    _CRE = re.compile("((?P<props>\w*)\s+)?"
> > +                      "(?P<name>\w+)"
> >                        "\((?P<args>[^)]*)\)"
> >                        "\s*"
> >                        "(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
> 
> The previous implementation allowed multiple properties. Maybe this should be
> instead (which still allows multiple properties):
> 
>     "((?P<props>[\w\s]+)\s+)?"
>     "(?P<name>\w+)\s*"
>     ...

Ooops, good point!

I will send v2.

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-23 10:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-22 16:15 [Qemu-devel] [PATCH] trace: tighten up trace-events regex to fix bad parse Stefan Hajnoczi
2014-09-22 17:35 ` Lluís Vilanova
2014-09-23  4:33   ` Eric Auger
2014-09-23 10:33   ` Stefan Hajnoczi

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).