Received: from eggs.gnu.org ([2001:4830:134:3::10]:44657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XW7WZ-0003FW-Ed for qemu-devel@nongnu.org; Mon, 22 Sep 2014 13:35:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XW7WQ-0000kT-Uv for qemu-devel@nongnu.org; Mon, 22 Sep 2014 13:35:42 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:36428) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XW7WQ-0000jA-K8 for qemu-devel@nongnu.org; Mon, 22 Sep 2014 13:35:34 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <1411402514-24137-1-git-send-email-stefanha@redhat.com> Date: Mon, 22 Sep 2014 12:35:22 -0500 In-Reply-To: <1411402514-24137-1-git-send-email-stefanha@redhat.com> (Stefan Hajnoczi's message of "Mon, 22 Sep 2014 17:15:14 +0100") Message-ID: <87lhpb5zj9.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] trace: tighten up trace-events regex to fix bad parse List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, 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 > main(sys.argv) > File "scripts/tracetool.py", line 134, in main > binary=3Dbinary, probe_prefix=3Dprobe_prefix) > File "scripts/tracetool/__init__.py", line 334, in generate > events =3D _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=C3=ADs Vilanova > Reported-by: Eric Auger > Signed-off-by: Stefan Hajnoczi > --- > 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. > """ =20 > - _CRE =3D re.compile("((?P.*)\s+)?" > - "(?P[^(\s]+)" > + _CRE =3D re.compile("((?P\w*)\s+)?" > + "(?P\w+)" > "\((?P[^)]*)\)" > "\s*" > "(?:(?:(?P\".+),)?\s*(?P\".+))?" The previous implementation allowed multiple properties. Maybe this should = be instead (which still allows multiple properties): "((?P[\w\s]+)\s+)?" "(?P\w+)\s*" ... Thanks, Lluis --=20 "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