[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 3/3] trace: Forbid dynamic field width in event format
From: |
Eric Blake |
Subject: |
Re: [PATCH v2 3/3] trace: Forbid dynamic field width in event format |
Date: |
Fri, 8 Nov 2019 10:07:38 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 |
On 11/8/19 8:40 AM, Philippe Mathieu-Daudé wrote:
Since not all trace backends support dynamic field width in
format (dtrace via stap does not), forbid them.
Add a check to refuse field width in new formats:
+++ b/scripts/tracetool/__init__.py
@@ -206,6 +206,7 @@ class Event(object):
"\s*"
"(?:(?:(?P<fmt_trans>\".+),)?\s*(?P<fmt>\".+))?"
"\s*")
+ _DFWRE = re.compile(".*(%0?\*).*")
The use of leading and trailing .* is pointless if the RE itself is used
unanchored and where you only care if the () matched.
This doesn't catch all valid uses of * in a printf format. Better might
be something like:
_DFWRE = re.compile("%[\d\.\- +#']*\*")
which matches only if there is a %, any number of characters that can
form a printf flag, as well as a numeric field width but dynamic precision.
+ if Event._DFWRE.match(fmt):
+ raise ValueError("Event format must not contain field width '%*'")
if len(fmt_trans) > 0:
fmt = [fmt_trans, fmt]
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- Re: [PATCH v2 1/3] hw/block/pflash: Remove dynamic field width from trace events, (continued)
[PATCH v2 2/3] hw/mips/gt64xxx: Remove dynamic field width from trace events, Philippe Mathieu-Daudé, 2019/11/08
[PATCH v2 3/3] trace: Forbid dynamic field width in event format, Philippe Mathieu-Daudé, 2019/11/08
- Re: [PATCH v2 3/3] trace: Forbid dynamic field width in event format,
Eric Blake <=